Code

still WIP. added tree-descending code
[inkscape.git] / src / extension / script / InkscapeInterpreter.cpp
1 /**
2  * Python Interpreter wrapper for Inkscape
3  *
4  * Authors:
5  *   Bob Jamison <rjamison@titan.com>
6  *
7  * Copyright (C) 2004 Authors
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include "InkscapeInterpreter.h"
14 #include <fstream>
16 namespace Inkscape {
17 namespace Extension {
18 namespace Script {
20 /*
21  *
22  */
23 InkscapeInterpreter::InkscapeInterpreter()
24 {
25 }
27     
29 /*
30  *
31  */
32 InkscapeInterpreter::~InkscapeInterpreter()
33 {
35 }
37     
38     
40 /*
41  *  Interpret an in-memory string
42  */
43 bool InkscapeInterpreter::interpretScript(Glib::ustring &script,
44                                  Glib::ustring &output,
45                                  Glib::ustring &error)
46 {
47     //do nothing.  let the subclasses implement this
48     return true;
49 }
51     
52     
54 /*
55  *  Interpret a named file
56  */
57 bool InkscapeInterpreter::interpretUri(Glib::ustring &uri,
58                                  Glib::ustring &output,
59                                  Glib::ustring &error)
60 {
61     char *curi = (char *)uri.raw().c_str();
62     std::ifstream ins(curi);
63     if (!ins.good())
64         {
65         printf("interpretUri: Could not open %s for reading\n", curi);
66         return false;
67         }
68         
69     Glib::ustring buf;
70     
71     while (!ins.eof())
72         {
73         gunichar ch = (gunichar) ins.get();
74         buf.push_back(ch);
75         }
77     ins.close();
78     
79     bool ret = interpretScript(buf, output, error);
81     return ret;
83 }
87 }  // namespace Script
88 }  // namespace Extension
89 }  // namespace Inkscape
91 //#########################################################################
92 //# E N D    O F    F I L E
93 //#########################################################################