source: tags/1.0/perl/Rappture.xs @ 4790

Last change on this file since 4790 was 872, checked in by dkearney, 16 years ago

mainly code cleanups that i've made and stored in my repository over time.

File size: 1.7 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 = "")
17char *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
40const char *
41RpLibrary::get( path )
42char *path
43        CODE:
44                string result;
45                result = THIS->get(path);
46                RETVAL = result.c_str();
47        OUTPUT:
48                RETVAL
49
50void
51RpLibrary::put( path, value, append )
52char *path
53char *value
54int append
55        CODE:
56                THIS->put(path,value,"",append);
57
58void
59RpLibrary::putFile( path, fileName, compress, append )
60char *path
61char *fileName
62int compress
63int append
64        CODE:
65                THIS->putFile(path,fileName,compress,append);
66
67void
68RpLibrary::result()
69        CODE:
70                THIS->put("tool.version.rappture.language", "perl");
71                THIS->result();
72
73MODULE = Rappture               PACKAGE = Rappture::RpUnits
74
75const char *
76convert( fromVal, toUnitsName, showUnits = 1 )
77const char *fromVal
78const char *toUnitsName
79int showUnits
80        CODE:
81                string result;
82                result = RpUnits::convert(fromVal,toUnitsName,showUnits);
83
84                if (result.empty())
85                    XSRETURN_UNDEF;
86
87                RETVAL = result.c_str();
88        OUTPUT:
89                RETVAL
90
91MODULE = Rappture               PACKAGE = Rappture::Utils
92
93int
94progress( percent, message )
95int percent
96const char *message
97        CODE:
98                RETVAL = Rappture::Utils::progress(percent,message);
99        OUTPUT:
100                RETVAL
Note: See TracBrowser for help on using the repository browser.