diff options
| author | Bob Jamison <ishmalius@gmail.com> | 2008-03-13 21:02:36 +0000 |
|---|---|---|
| committer | ishmal <ishmal@users.sourceforge.net> | 2008-03-13 21:02:36 +0000 |
| commit | 5c70e99f50efbb030a700201c710499afef90a45 (patch) | |
| tree | 339b9fbd22b48525ef072ca3302562093df33580 /src/xml/repr-io.cpp | |
| parent | fix compile (diff) | |
| download | inkscape-5c70e99f50efbb030a700201c710499afef90a45.tar.gz inkscape-5c70e99f50efbb030a700201c710499afef90a45.zip | |
Add convenience functions to read from/write to Glib::ustrings.
(bzr r5086)
Diffstat (limited to 'src/xml/repr-io.cpp')
| -rw-r--r-- | src/xml/repr-io.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 26537d750..bd9e4a2e0 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -26,6 +26,7 @@ #include "io/sys.h" #include "io/uristream.h" +#include "io/stringstream.h" #include "io/gzipstream.h" #include "prefs-utils.h" @@ -315,6 +316,16 @@ sp_repr_read_mem (const gchar * buffer, gint length, const gchar *default_ns) return rdoc; } +/** + * Reads and parses XML from a buffer, returning it as an Document + */ +Document * +sp_repr_read_buf (const Glib::ustring &buf, const gchar *default_ns) +{ + return sp_repr_read_mem(buf.c_str(), buf.size(), default_ns); +} + + namespace Inkscape { struct compare_quark_ids { @@ -729,6 +740,23 @@ sp_repr_write_stream (Node *repr, Writer &out, gint indent_level, } } + +Glib::ustring +sp_repr_write_buf(Node *repr, gint indent_level, + bool add_whitespace, Glib::QueryQuark elide_prefix, + int inlineattrs, int indent) +{ + Glib::ustring buf; + Inkscape::IO::StringOutputStream souts; + Inkscape::IO::OutputStreamWriter outs(souts); + sp_repr_write_stream(repr, outs, indent_level, add_whitespace, + elide_prefix, inlineattrs, indent); + outs.close(); + buf = souts.getString(); + return buf; +} + + void sp_repr_write_stream_element (Node * repr, Writer & out, gint indent_level, bool add_whitespace, |
