Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
croco-node-iface.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors: see git history
6 *
7 * Copyright (C) 2018 Authors
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10#include <cstring>
11#include <string>
12#include <glib.h>
13
15#include "xml/node.h"
16
17static char const *
18local_part(char const *const qname)
19{
20 char const *ret = std::strrchr(qname, ':');
21 if (ret)
22 return ++ret;
23 else
24 return qname;
25}
26
27namespace Inkscape {
28namespace XML {
29
30extern "C" {
31
32static CRXMLNodePtr get_parent(CRXMLNodePtr n) { return static_cast<Node const *>(n)->parent(); }
33static CRXMLNodePtr get_first_child(CRXMLNodePtr n) { return static_cast<Node const *>(n)->firstChild(); }
34static CRXMLNodePtr get_next(CRXMLNodePtr n) { return static_cast<Node const *>(n)->next(); }
35
37{
38 Node const *n = static_cast<Node const *>(cn);
39 unsigned const n_pos = n->position();
40 if (n_pos) {
41 return n->parent()->nthChild(n_pos - 1);
42 } else {
43 return nullptr;
44 }
45}
46
47static char *get_attr(CRXMLNodePtr n, char const *a)
48{
49 return g_strdup(static_cast<Node const *>(n)->attribute(a));
50}
51
52static char const *get_local_name(CRXMLNodePtr n) { return local_part(static_cast<Node const *>(n)->name()); }
53static gboolean is_element_node(CRXMLNodePtr n) { return static_cast<Node const *>(n)->type() == NodeType::ELEMENT_NODE; }
54}
55
72
73}
74}
75
76
77/*
78 Local Variables:
79 mode:c++
80 c-file-style:"stroustrup"
81 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
82 indent-tabs-mode:nil
83 fill-column:99
84 End:
85*/
86// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Interface for refcounted XML nodes.
Definition node.h:80
G_BEGIN_DECLS typedef gconstpointer CRXMLNodePtr
static char const * local_part(char const *const qname)
TODO: insert short description here.
static char const *const parent
Definition dir-util.cpp:70
static CRXMLNodePtr get_first_child(CRXMLNodePtr n)
static char * get_attr(CRXMLNodePtr n, char const *a)
static CRXMLNodePtr get_next(CRXMLNodePtr n)
static CRXMLNodePtr get_parent(CRXMLNodePtr n)
CRNodeIface const croco_node_iface
Interface for XML nodes used by libcroco.
static char const * get_local_name(CRXMLNodePtr n)
@ ELEMENT_NODE
Regular element node, e.g. <group />.
static CRXMLNodePtr get_prev(CRXMLNodePtr cn)
static gboolean is_element_node(CRXMLNodePtr n)
Helper class to stream background task notifications as a series of messages.
Glib::ustring name
Definition toolbars.cpp:55
Interface for XML nodes.