Top |
#define | XB_TYPE_BUILDER_NODE |
struct | XbBuilderNodeClass |
enum | XbBuilderNodeFlags |
XbBuilderNode |
gboolean (*XbBuilderNodeTraverseFunc) (XbBuilderNode *bn
,gpointer user_data
);
gint (*XbBuilderNodeSortFunc) (XbBuilderNode *bn1
,XbBuilderNode *bn2
,gpointer user_data
);
XbBuilderNode *
xb_builder_node_new (const gchar *element
);
Creates a new builder node.
Since: 0.1.0
XbBuilderNode * xb_builder_node_insert (XbBuilderNode *parent
,const gchar *element
,...
);
Creates a new builder node.
[skip]
parent |
A XbBuilderNode, or |
|
element |
An element name, e.g. "component" |
|
... |
any attributes to add to the node, terminated by |
Since: 0.1.0
void xb_builder_node_insert_text (XbBuilderNode *parent
,const gchar *element
,const gchar *text
,...
);
Creates a new builder node with optional node text.
[skip]
parent |
A XbBuilderNode, or |
|
element |
An element name, e.g. "id" |
|
text |
node text, e.g. "gimp.desktop". |
[allow-none] |
... |
any attributes to add to the node, terminated by |
Since: 0.1.0
gboolean xb_builder_node_has_flag (XbBuilderNode *self
,XbBuilderNodeFlags flag
);
Checks a flag on the builder node.
Since: 0.1.0
void xb_builder_node_add_flag (XbBuilderNode *self
,XbBuilderNodeFlags flag
);
Adds a flag to the builder node.
Since: 0.1.0
const gchar *
xb_builder_node_get_element (XbBuilderNode *self
);
Gets the element from the builder node.
Since: 0.1.0
void xb_builder_node_set_element (XbBuilderNode *self
,const gchar *element
);
Sets the element name on the builder node.
Since: 0.1.0
const gchar *
xb_builder_node_get_text (XbBuilderNode *self
);
Gets the text from the builder node.
Since: 0.1.0
guint64
xb_builder_node_get_text_as_uint (XbBuilderNode *self
);
Gets the text from the builder node.
Since: 0.1.3
void xb_builder_node_set_text (XbBuilderNode *self
,const gchar *text
,gssize text_len
);
Sets the text on the builder node.
self |
||
text |
a string. |
[allow-none] |
text_len |
length of |
Since: 0.1.0
void
xb_builder_node_tokenize_text (XbBuilderNode *self
);
Tokenize text added with xb_builder_node_set_text()
.
When searching, libxmlb often has to tokenize strings before they can be compared. This is done in the "fast path" and makes searching for non-ASCII text much slower.
Adding the tokens to the deduplicated string table allows much faster searching at the expense of a ~5% size increase of the silo.
This function adds all valid UTF-8 and ASCII search words generated from
the value of xb_builder_node_set_text()
.
The transliteration locale (e.g. en_GB
) is read from the xml:lang
node attribute if set.
Since: 0.3.1
const gchar *
xb_builder_node_get_tail (XbBuilderNode *self
);
Gets the tail from the builder node.
Since: 0.1.12
void xb_builder_node_set_tail (XbBuilderNode *self
,const gchar *tail
,gssize tail_len
);
Sets the tail on the builder node.
self |
||
tail |
a string. |
[allow-none] |
tail_len |
length of |
Since: 0.1.12
const gchar * xb_builder_node_get_attr (XbBuilderNode *self
,const gchar *name
);
Gets an attribute from the builder node.
Since: 0.1.0
guint64 xb_builder_node_get_attr_as_uint (XbBuilderNode *self
,const gchar *name
);
Gets an attribute from the builder node.
Since: 0.1.3
void xb_builder_node_set_attr (XbBuilderNode *self
,const gchar *name
,const gchar *value
);
Adds an attribute to the builder node.
Since: 0.1.0
void xb_builder_node_remove_attr (XbBuilderNode *self
,const gchar *name
);
Removes an attribute from the builder node.
Since: 0.1.0
void xb_builder_node_add_child (XbBuilderNode *self
,XbBuilderNode *child
);
Adds a child builder node.
Since: 0.1.0
void xb_builder_node_remove_child (XbBuilderNode *self
,XbBuilderNode *child
);
Removes a child builder node.
Since: 0.1.1
GPtrArray *
xb_builder_node_get_children (XbBuilderNode *self
);
Gets the children of the builder node.
Since: 0.1.0
XbBuilderNode *
xb_builder_node_get_first_child (XbBuilderNode *self
);
Gets the first child of the builder node.
Since: 0.1.12
XbBuilderNode *
xb_builder_node_get_last_child (XbBuilderNode *self
);
Gets the last child of the builder node.
Since: 0.1.12
XbBuilderNode * xb_builder_node_get_child (XbBuilderNode *self
,const gchar *element
,const gchar *text
);
Finds a child builder node by the element name, and optionally text value.
self |
||
element |
An element name, e.g. "url" |
|
text |
node text, e.g. "gimp.desktop". |
[allow-none] |
Since: 0.1.1
void
xb_builder_node_unlink (XbBuilderNode *self
);
Unlinks a XbBuilderNode from a tree, resulting in two separate trees.
This should not be used from the function called by xb_builder_node_traverse()
otherwise the entire tree will not be traversed.
Instead use xb_builder_node_add_flag(bn,XB_BUILDER_NODE_FLAG_IGNORE);
Since: 0.1.1
XbBuilderNode *
xb_builder_node_get_parent (XbBuilderNode *self
);
Gets the parent node for the current node.
Since: 0.1.1
guint
xb_builder_node_depth (XbBuilderNode *self
);
Gets the depth of the node tree, where 0 is the root node.
Since: 0.1.1
void xb_builder_node_traverse (XbBuilderNode *self
,GTraverseType order
,GTraverseFlags flags
,gint max_depth
,XbBuilderNodeTraverseFunc func
,gpointer user_data
);
Traverses a tree starting from self
. It calls the given function for each
node visited.
The traversal can be halted at any point by returning TRUE from func
.
self |
||
order |
a GTraverseType, e.g. |
|
flags |
a GTraverseFlags, e.g. |
|
max_depth |
the maximum depth of the traversal, or -1 for no limit |
|
func |
[scope call] | |
user_data |
user pointer to pass to |
Since: 0.1.1
void xb_builder_node_sort_children (XbBuilderNode *self
,XbBuilderNodeSortFunc func
,gpointer user_data
);
Sorts the node children using a custom sort function.
Since: 0.1.3
gchar * xb_builder_node_export (XbBuilderNode *self
,XbNodeExportFlags flags
,GError **error
);
Exports the node to XML.
self |
||
flags |
some XbNodeExportFlags, e.g. XB_NODE_EXPORT_FLAG_NONE |
|
error |
the GError, or |
Since: 0.1.5
GPtrArray *
xb_builder_node_get_tokens (XbBuilderNode *self
);
Gets the tokens of the builder node.
Since: 0.3.1
void xb_builder_node_add_token (XbBuilderNode *self
,const gchar *token
);
Adds a token to the builder node.
Since: 0.3.1