From 179fa413b047bede6e32109e2ce82437c5fb8d34 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Mon, 16 Jan 2006 02:36:01 +0000 Subject: moving trunk for module inkscape (bzr r1) --- src/xml/croco-node-iface.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/xml/croco-node-iface.cpp (limited to 'src/xml/croco-node-iface.cpp') diff --git a/src/xml/croco-node-iface.cpp b/src/xml/croco-node-iface.cpp new file mode 100644 index 000000000..0464e4fb7 --- /dev/null +++ b/src/xml/croco-node-iface.cpp @@ -0,0 +1,68 @@ +#include "xml/croco-node-iface.h" +#include "xml/node.h" +#include + +static char const * +local_part(char const *const qname) +{ + char const *ret = std::strrchr(qname, ':'); + if (ret) + return ++ret; + else + return qname; +} + +namespace Inkscape { +namespace XML { + +extern "C" { + +static CRXMLNodePtr get_parent(CRXMLNodePtr n) { return static_cast(n)->parent(); } +static CRXMLNodePtr get_first_child(CRXMLNodePtr n) { return static_cast(n)->firstChild(); } +static CRXMLNodePtr get_next(CRXMLNodePtr n) { return static_cast(n)->next(); } + +static CRXMLNodePtr get_prev(CRXMLNodePtr cn) +{ + Node const *n = static_cast(cn); + unsigned const n_pos = n->position(); + if (n_pos) { + return n->parent()->nthChild(n_pos - 1); + } else { + return NULL; + } +} + +static char *get_attr(CRXMLNodePtr n, char const *a) +{ + return g_strdup(static_cast(n)->attribute(a)); +} + +static char const *get_local_name(CRXMLNodePtr n) { return local_part(static_cast(n)->name()); } +static gboolean is_element_node(CRXMLNodePtr n) { return static_cast(n)->type() == ELEMENT_NODE; } +} + +CRNodeIface const croco_node_iface = { + get_parent, + get_first_child, + get_next, + get_prev, + get_local_name, + get_attr, + g_free, + is_element_node +}; + +} +} + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3