source: trunk/lang/perl/Rappture.xs @ 4346

Last change on this file since 4346 was 2549, checked in by gah, 13 years ago
File size: 2.0 KB
Line 
1#include "rappture.h"
2#include <string>
3
4#include "EXTERN.h"
5#include "perl.h"
6#include "XSUB.h"
7
8#include "ppport.h"
9
10using namespace std;
11
12MODULE = Rappture        PACKAGE = Rappture::RpLibrary
13PROTOTYPES: ENABLE
14
15RpLibrary *
16RpLibrary::new(filename = "")
17const char *filename
18    CODE:
19        RpLibrary *library;
20        if ((filename == NULL) || (*filename == '\0'))
21            library = new RpLibrary();
22        else
23            library = new RpLibrary(filename);
24
25        if (library->isNull())
26                {
27                        delete library;
28            XSRETURN_UNDEF;
29                }
30        else
31            RETVAL = library;
32    OUTPUT:
33        RETVAL
34
35void *
36RpLibrary::DESTROY()
37    CODE:
38        RETVAL = 0;
39    OUTPUT:
40        RETVAL
41
42SV *
43RpLibrary::get( path )
44const char *path
45    CODE:
46        string result;
47        result = THIS->get(path);
48        RETVAL = newSVpvn(result.data(),result.length());
49    OUTPUT:
50        RETVAL
51
52void
53RpLibrary::put( path, value, append )
54const char *path
55const char *value
56int append
57    CODE:
58        THIS->put(path,value,"",append);
59
60void
61RpLibrary::putFile( path, fileName, compress, append )
62const char *path
63const char *fileName
64int compress
65int append
66    CODE:
67        THIS->putFile(path,fileName,compress,append);
68
69void
70RpLibrary::result()
71    CODE:
72        THIS->put("tool.version.rappture.language", "perl");
73        THIS->result();
74
75MODULE = Rappture        PACKAGE = Rappture::RpUnits
76
77const char *
78convert( fromVal, toUnitsName, showUnits = 1 )
79const char *fromVal
80const char *toUnitsName
81int showUnits
82    CODE:
83        string result;
84        result = RpUnits::convert(fromVal,toUnitsName,showUnits);
85
86                if (result.empty())
87                    XSRETURN_UNDEF;
88
89        RETVAL = result.c_str();
90    OUTPUT:
91        RETVAL
92
93MODULE = Rappture        PACKAGE = Rappture::Utils
94
95int
96progress( percent, message )
97int percent
98const char *message
99    CODE:
100        RETVAL = Rappture::Utils::progress(percent,message);
101    OUTPUT:
102        RETVAL
Note: See TracBrowser for help on using the repository browser.