summaryrefslogtreecommitdiffstats
path: root/src/extension/script/InkscapeInterpreter.cpp
blob: c28163489a2aa12c4a55d7103ea25b991930b29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
 * Python Interpreter wrapper for Inkscape
 *
 * Authors:
 *   Bob Jamison <rjamison@titan.com>
 *
 * Copyright (C) 2004 Authors
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#include "InkscapeInterpreter.h"

#include <fstream>

namespace Inkscape {
namespace Extension {
namespace Script {

/*
 *
 */
InkscapeInterpreter::InkscapeInterpreter()
{
}



/*
 *
 */
InkscapeInterpreter::~InkscapeInterpreter()
{

}




/*
 *  Interpret an in-memory string
 */
bool InkscapeInterpreter::interpretScript(const Glib::ustring &script,
                                          Glib::ustring &output,
                                          Glib::ustring &error)
{
    //do nothing.  let the subclasses implement this
    return true;
}




/*
 *  Interpret a named file
 */
bool InkscapeInterpreter::interpretUri(const Glib::ustring &uri,
                                       Glib::ustring &output,
                                       Glib::ustring &error)
{
    char *curi = (char *)uri.raw().c_str();
    std::ifstream ins(curi);
    if (!ins.good())
        {
        g_error("interpretUri: Could not open %s for reading\n", curi);
        return false;
        }

    Glib::ustring buf;

    while (!ins.eof())
        {
        gunichar ch = (gunichar) ins.get();
        buf.push_back(ch);
        }

    ins.close();

    bool ret = interpretScript(buf, output, error);

    return ret;

}



}  // namespace Script
}  // namespace Extension
}  // namespace Inkscape

//#########################################################################
//# E N D    O F    F I L E
//#########################################################################