source: trunk/perl/Rappture.xs @ 591

Last change on this file since 591 was 591, checked in by dkearney, 14 years ago

Added putFile capability to octave, matlab, fortran, perl bindings
Adjusted the core putFile function and all put functions to accept unsigned ints
added enum flags for binary and text file for the putFile function in c/c++

File size: 1.5 KB
Line 
1#include "RpLibrary.h"
2#include "RpUnits.h"
3#include <string>
4
5#include "EXTERN.h"
6#include "perl.h"
7#include "XSUB.h"
8
9#include "ppport.h"
10
11using namespace std;
12
13MODULE = Rappture               PACKAGE = Rappture::RpLibrary
14PROTOTYPES: ENABLE
15
16RpLibrary *
17RpLibrary::new(filename = "")
18char *filename
19        CODE:
20        RpLibrary *library;
21                if ((filename == NULL) || (*filename == '\0'))
22                        library = new RpLibrary();
23                else
24                        library = new RpLibrary(filename);
25
26                if (library->isNull())
27                {
28                        delete library;
29                        XSRETURN_UNDEF;
30                }
31                else
32                        RETVAL = library;
33        OUTPUT:
34                RETVAL
35
36void *
37RpLibrary::DESTROY()
38        CODE:
39                RETVAL = 0;
40
41const char *
42RpLibrary::get( path )
43char *path
44        CODE:
45                string result;
46                result = THIS->get(path);
47                RETVAL = result.c_str();
48        OUTPUT:
49                RETVAL
50
51void
52RpLibrary::put( path, value, append )
53char *path
54char *value
55int append
56        CODE:
57                THIS->put(path,value,"",append);
58
59void
60RpLibrary::putFile( path, fileName, fileType, append )
61char *path
62char *fileName
63int fileType
64int append
65        CODE:
66                THIS->putFile(path,fileName,fileType,append);
67
68void
69RpLibrary::result()
70
71MODULE = Rappture               PACKAGE = Rappture::RpUnits
72
73const char *
74convert( fromVal, toUnitsName, showUnits = 1 )
75const char *fromVal
76const char *toUnitsName
77int showUnits
78        CODE:
79                string result;
80                result = RpUnits::convert(fromVal,toUnitsName,showUnits);
81
82                if (result.empty())
83                    XSRETURN_UNDEF;
84
85                RETVAL = result.c_str();
86        OUTPUT:
87                RETVAL
Note: See TracBrowser for help on using the repository browser.