9 #include "parser/tb_parser.h"
10 #include "tb_linklist.h"
15 TB_NODE_READ_FLAGS_NONE = 0,
33 TBNode() : m_name(
nullptr), m_parent(
nullptr), m_cycle_id(0) {}
59 void Add(
TBNode *n) { m_children.AddLast(n); n->m_parent =
this; }
68 void Remove(
TBNode *n) { m_children.Remove(n); n->m_parent =
nullptr; }
126 inline TBNode *GetParent()
const {
return m_parent; }
127 inline TBNode *GetFirstChild()
const {
return m_children.GetFirst(); }
128 inline TBNode *GetLastChild()
const {
return m_children.GetLast(); }
130 friend class TBNodeTarget;
131 friend class TBNodeRefTree;
132 TBNode *GetNodeFollowRef(
const char *request,
134 TBNode *GetNodeInternal(
const char *name,
int name_len)
const;
137 TBLinkListOf<TBNode> m_children;
144 #endif // TB_NODE_TREE_H
static const char * GetNextNodeSeparator(const char *request)
Get the next position in request that is a sub node separator, or the end of the string.
Definition: tb_node_tree.cpp:32
float GetValueFloat(const char *request, float def)
Get a value from the given request as an float.
Definition: tb_node_tree.cpp:108
bool ReadFile(const TBStr &filename, TB_NODE_READ_FLAGS flags=TB_NODE_READ_FLAGS_NONE)
Read a tree of nodes from file into this node.
Definition: tb_node_tree.cpp:290
void ReadData(const char *data, TB_NODE_READ_FLAGS flags=TB_NODE_READ_FLAGS_NONE)
Read a tree of nodes from a null terminated string buffer.
Definition: tb_node_tree.cpp:304
bool WriteNode(TBStr &str, int depth=0)
Recursively write a node and it's children to a string at depth.
Definition: tb_node_tree.cpp:338
static TBNode * Create(TBStr name)
Create a new node with the given name.
Definition: tb_node_tree.cpp:23
void AddBefore(TBNode *n, TBNode *reference)
Add node before the reference node (which must be a child to this node).
Definition: tb_node_tree.h:62
GET_MISS_POLICY
Definition: tb_node_tree.h:78
GetNode will return nullptr if the node doesn't exist.
Definition: tb_node_tree.h:80
bool WriteFile(const TBStr &filename)
Write a node and it's children to a file.
Definition: tb_node_tree.cpp:325
TBValue & GetValueFollowRef()
Returns the value of this node.
Definition: tb_node_tree.cpp:97
void Remove(TBNode *n)
Remove child node n from this node.
Definition: tb_node_tree.h:68
void Clear()
Clear the contens of this node.
Definition: tb_node_tree.cpp:319
void AddAfter(TBNode *n, TBNode *reference)
Add node after the reference node (which must be a child to this node).
Definition: tb_node_tree.h:65
const TBStr & GetName() const
Returns the name of this node.
Definition: tb_node_tree.h:94
void Add(TBNode *n)
Add node as child to this node.
Definition: tb_node_tree.h:59
bool CloneChildren(TBNode *source)
Create duplicates of all items in source and add them to this node.
Definition: tb_node_tree.cpp:78
void Delete(TBNode *n)
Remove and delete child node n from this node.
Definition: tb_node_tree.h:71
TBStr is a simple string class.
Definition: tb_str.h:62
TBNode is a tree node with a string name and a value (TBValue).
Definition: tb_node_tree.h:30
TBNode * GetNode(const char *request, GET_MISS_POLICY mp=GET_MISS_POLICY_NULL)
Get a node from the given request.
Definition: tb_node_tree.cpp:39
TB_NODE_READ_FLAGS
Definition: tb_node_tree.h:14
GetNode will create all missing nodes for the request.
Definition: tb_node_tree.h:82
TBValue holds value of a specific type.
Definition: tb_value.h:59
Definition: tb_linklist.h:83
TBStr GetValueStringRaw(const char *request, const char *def)
Same as GetValueString, but won't look up language string references.
Definition: tb_node_tree.cpp:132
TBValue & GetValue()
Returns the value of this node.
Definition: tb_node_tree.h:97
Read nodes without clearing first.
Definition: tb_node_tree.h:18
int GetValueInt(const char *request, int def)
Get a value from the given request as an integer.
Definition: tb_node_tree.cpp:102
TBStr GetValueString(const char *request, const char *def)
Get a value from the given request as an string.
Definition: tb_node_tree.cpp:114