Xmlb.BuilderNode¶
- Subclasses:
 None
Methods¶
- Inherited:
 - Structs:
 
class  | 
  | 
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
Virtual Methods¶
- Inherited:
 
Properties¶
None
Signals¶
- Inherited:
 
Fields¶
- Inherited:
 
Name  | 
Type  | 
Access  | 
Description  | 
|---|---|---|---|
parent_instance  | 
r  | 
Class Details¶
- class Xmlb.BuilderNode(**kwargs)¶
 - Bases:
 - Abstract:
 No
- Structure:
 
- classmethod new(element)¶
 - Parameters:
 element (
str) – An element name, e.g. “component”- Returns:
 a new
Xmlb.BuilderNode- Return type:
 
Creates a new builder node.
New in version 0.1.0.
- add_child(child)¶
 - Parameters:
 child (
Xmlb.BuilderNode) – AXmlb.BuilderNode
Adds a child builder node.
New in version 0.1.0.
- add_flag(flag)¶
 - Parameters:
 flag (
Xmlb.BuilderNodeFlags) – aXmlb.BuilderNodeFlags
Adds a flag to the builder node.
New in version 0.1.0.
- add_token(token)¶
 - Parameters:
 token (
str) – a new token
Adds a token to the builder node.
New in version 0.3.1.
- depth()¶
 - Return type:
 
Gets the depth of the node tree, where 0 is the root node.
New in version 0.1.1.
- export(flags)¶
 - Parameters:
 flags (
Xmlb.NodeExportFlags) – someXmlb.NodeExportFlags, e.g.Xmlb.NodeExportFlags.NONE- Raises:
 - Returns:
 XML data, or
Nonefor an error- Return type:
 
Exports the node to XML.
New in version 0.1.5.
- get_attr(name)¶
 - 
Gets an attribute from the builder node.
New in version 0.1.0.
 
- get_attr_as_uint(name)¶
 - Parameters:
 name (
str) – attribute name, e.g.priority- Returns:
 integer, or 0 if unset
- Return type:
 
Gets an attribute from the builder node.
New in version 0.1.3.
- get_child(element, text)¶
 - Parameters:
 - Returns:
 a new
Xmlb.BuilderNode, orNoneif not found- Return type:
 
Finds a child builder node by the element name, and optionally text value.
New in version 0.1.1.
- get_children()¶
 - Returns:
 children
- Return type:
 
Gets the children of the builder node.
New in version 0.1.0.
- get_element()¶
 - 
Gets the element from the builder node.
New in version 0.1.0.
 
- get_first_child()¶
 - Returns:
 a
Xmlb.BuilderNode, orNone- Return type:
 
Gets the first child of the builder node.
New in version 0.1.12.
- get_last_child()¶
 - Returns:
 a
Xmlb.BuilderNode, orNone- Return type:
 
Gets the last child of the builder node.
New in version 0.1.12.
- get_parent()¶
 - Returns:
 a new
Xmlb.BuilderNode, orNoneno parent exists.- Return type:
 
Gets the parent node for the current node.
New in version 0.1.1.
- get_tail()¶
 - 
Gets the tail from the builder node.
New in version 0.1.12.
 
- get_text()¶
 - 
Gets the text from the builder node.
New in version 0.1.0.
 
- get_text_as_uint()¶
 - Returns:
 integer, or 0 if unset
- Return type:
 
Gets the text from the builder node.
New in version 0.1.3.
- get_tokens()¶
 - 
Gets the tokens of the builder node.
New in version 0.3.1.
 
- has_flag(flag)¶
 - Parameters:
 flag (
Xmlb.BuilderNodeFlags) – aXmlb.BuilderNodeFlags- Returns:
 Trueif flag is set- Return type:
 
Checks a flag on the builder node.
New in version 0.1.0.
- remove_attr(name)¶
 - Parameters:
 name (
str) – attribute name, e.g.type
Removes an attribute from the builder node.
New in version 0.1.0.
- remove_child(child)¶
 - Parameters:
 child (
Xmlb.BuilderNode) – AXmlb.BuilderNode
Removes a child builder node.
New in version 0.1.1.
- set_attr(name, value)¶
 - 
Adds an attribute to the builder node.
New in version 0.1.0.
 
- set_element(element)¶
 - Parameters:
 element (
str) – a string element
Sets the element name on the builder node.
New in version 0.1.0.
- set_tail(tail, tail_len)¶
 - Parameters:
 
Sets the tail on the builder node.
New in version 0.1.12.
- set_text(text, text_len)¶
 - Parameters:
 
Sets the text on the builder node.
New in version 0.1.0.
- sort_children(func, *user_data)¶
 - Parameters:
 func (
Xmlb.BuilderNodeSortFunc) – aXmlb.BuilderNodeSortFuncuser_data (
objectorNone) – user pointer to pass to func, orNone
Sorts the node children using a custom sort function.
New in version 0.1.3.
- tokenize_text()¶
 Tokenize text added with
Xmlb.BuilderNode.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
Xmlb.BuilderNode.set_text().The transliteration locale (e.g.
en_GB) is read from thexml:langnode attribute if set.New in version 0.3.1.
- traverse(order, flags, max_depth, func, *user_data)¶
 - Parameters:
 order (
GLib.TraverseType) – aGLib.TraverseType, e.g.GLib.TraverseType.PRE_ORDERflags (
GLib.TraverseFlags) – aGLib.TraverseFlags, e.g.GLib.TraverseFlags.ALLmax_depth (
int) – the maximum depth of the traversal, or -1 for no limitfunc (
Xmlb.BuilderNodeTraverseFunc) – aXmlb.BuilderNodeTraverseFuncuser_data (
objectorNone) – user pointer to pass to func, orNone
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
Truefrom func.New in version 0.1.1.
- unlink()¶
 Unlinks a
Xmlb.BuilderNodefrom a tree, resulting in two separate trees.This should not be used from the function called by
Xmlb.BuilderNode.traverse() otherwise the entire tree will not be traversed.Instead use
Xmlb.BuilderNode.add_flag(bn,:obj:Xmlb.BuilderNodeFlags.IGNORE);New in version 0.1.1.