ucommon
7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
![]() ![]() |
Embed data objects into a tree structured memory database. More...
#include <linked.h>
Public Member Functions | |
treemap (char *name=NULL) | |
Construct a typed root node for the tree. More... | |
treemap (const treemap &source) | |
Construct a copy of the treemap object. More... | |
treemap (treemap *parent, char *name) | |
Construct a child node on an existing tree. More... | |
treemap (treemap *parent, char *name, T &reference) | |
Construct a child node on an existing tree and assign it's value. More... | |
const T & | get (void) const |
Return the typed value of this node. More... | |
const T & | operator* () const |
Return typed value of this node by pointer reference. More... | |
bool | is_attribute (void) const |
Test if this node is a leaf node for a tree pointer table. More... | |
const T | getPointer (void) const |
Get the pointer of a pointer based value tree. More... | |
const T & | getData (void) const |
Get the data value of a data based value tree. More... | |
void | setPointer (const T pointer) |
Set the pointer of a pointer based value tree. More... | |
void | set (const T &reference) |
Set the value of a data based value tree. More... | |
void | operator= (const T &data) |
Assign the value of our node. More... | |
treemap * | getIndexed (unsigned index) const |
Get child member node by index. More... | |
treemap * | getParent (void) const |
Get the typed parent node for our node. More... | |
treemap * | getChild (const char *name) const |
Get direct typed child node of our node of specified name. More... | |
treemap * | getLeaf (const char *name) const |
Find a direct typed leaf node on our node. More... | |
T | getValue (const char *name) const |
Get the value pointer of a leaf node of a pointer tree. More... | |
treemap * | find (const char *name) const |
Find a subnode from our node by name. More... | |
treemap * | path (const char *path) const |
Find a subnode by pathname. More... | |
treemap * | leaf (const char *name) const |
Search for a leaf node of our node. More... | |
treemap * | getFirst (void) const |
Get first child of our node. More... | |
![]() | |
NamedTree * | find (const char *name) const |
Find a child node of our object with the specified name. More... | |
NamedTree * | path (const char *path) const |
Find a subnode by a dot separated list of node names. More... | |
NamedTree * | leaf (const char *name) const |
Find a child leaf node of our object with the specified name. More... | |
NamedTree * | getChild (const char *name) const |
Find a direct child of our node which matches the specified name. More... | |
NamedTree * | getLeaf (const char *name) const |
Find a direct leaf node on our node. More... | |
NamedTree * | getFirst (void) const |
Get first child node in our ordered list of children. More... | |
NamedTree * | getParent (void) const |
Get parent node we are listed as a child on. More... | |
NamedTree * | getIndexed (unsigned index) const |
Get child by index number. More... | |
OrderedIndex * | getIndex (void) const |
Get the ordered index of our child nodes. More... | |
operator bool () const | |
Test if this node has a name. More... | |
bool | operator! () const |
Test if this node is unnamed. More... | |
void | setId (char *name) |
Set or replace the name id of this node. More... | |
void | remove (void) |
Remove our node from our parent list. More... | |
bool | is_leaf (void) const |
Test if node has children. More... | |
bool | is_root (void) const |
Test if node is root node. More... | |
void | relistTail (NamedTree *trunk) |
Add leaf to a trunk, by order. More... | |
void | relistHead (NamedTree *trunk) |
Add leaf to a trunk, by reverse order. More... | |
void | relist (NamedTree *trunk=NULL) |
Default relist is by tail... More... | |
![]() | |
void | add (NamedObject **hash, char *name, unsigned size=1) |
Add object to hash indexed list. More... | |
NamedObject * | getNext (void) const |
Get next effective object when iterating. More... | |
char * | getId (void) const |
Get the named id string of this object. More... | |
virtual int | compare (const char *name) const |
Compare the name of our object to see if equal. More... | |
bool | equal (const char *name) const |
Equal function which calls compare. More... | |
bool | operator== (const char *name) const |
Comparison operator between our name and a string. More... | |
bool | operator!= (const char *name) const |
Comparison operator between our name and a string. More... | |
![]() | |
void | enlistTail (OrderedIndex *index) |
List our ordered object at end of a linked list on an index. More... | |
void | enlistHead (OrderedIndex *index) |
List our ordered object at start of a linked list on an index. More... | |
virtual void | enlist (OrderedIndex *index) |
List our ordered object in default strategy mode. More... | |
void | delist (OrderedIndex *index) |
Remove our ordered object from an existing index. More... | |
OrderedObject * | getNext (void) const |
Get next ordered member when iterating. More... | |
![]() | |
virtual | ~LinkedObject () |
virtual void | release (void) __OVERRIDE |
Release list, mark as no longer linked. More... | |
virtual void | retain (void) __OVERRIDE |
Retain by marking as self referenced list. More... | |
void | enlist (LinkedObject **root) |
Add our object to an existing linked list through a pointer. More... | |
void | delist (LinkedObject **root) |
Locate and remove ourselves from a list of objects. More... | |
bool | is_member (LinkedObject *list) const |
Search to see if we are a member of a specific list. More... | |
LinkedObject * | getNext (void) const |
Get next effective object when iterating. More... | |
Static Public Member Functions | |
static T | getPointer (treemap *node) |
Return value from tree element when value is a pointer. More... | |
![]() | |
static void | purge (NamedObject **hash, unsigned size) |
Purge a hash indexed table of named objects. More... | |
static NamedObject ** | index (NamedObject **hash, unsigned size) |
Convert a hash index into a linear object pointer array. More... | |
static unsigned | count (NamedObject **hash, unsigned size) |
Count the total named objects in a hash table. More... | |
static NamedObject * | find (NamedObject *root, const char *name) |
Find a named object from a simple list. More... | |
static NamedObject * | remove (NamedObject **root, const char *name) |
Remove a named object from a simple list. More... | |
static NamedObject * | map (NamedObject **hash, const char *name, unsigned size) |
Find a named object through a hash map table. More... | |
static NamedObject * | remove (NamedObject **hash, const char *name, unsigned size) |
Remove an object from a hash map table. More... | |
static NamedObject * | skip (NamedObject **hash, NamedObject *current, unsigned size) |
Iterate through a hash map table. More... | |
static unsigned | keyindex (const char *name, unsigned size) |
Internal function to convert a name to a hash index number. More... | |
static NamedObject ** | sort (NamedObject **list, size_t count=0) |
Sort an array of named objects in alphabetical order. More... | |
![]() | |
static void | purge (LinkedObject *root) |
Release all objects from a list. More... | |
static unsigned | count (const LinkedObject *root) |
Count the number of linked objects in a list. More... | |
static LinkedObject * | getIndexed (LinkedObject *root, unsigned index) |
Get member by index. More... | |
Protected Attributes | |
T | value |
![]() | |
NamedTree * | Parent |
OrderedIndex | Child |
![]() | |
char * | Id |
![]() | |
LinkedObject * | Next |
Additional Inherited Members | |
![]() | |
NamedTree (char *name=NULL) | |
Create a stand-alone or root tree node, with an optional name. More... | |
NamedTree (NamedTree *parent, char *name) | |
Create a tree node as a child of an existing node. More... | |
NamedTree (const NamedTree &source) | |
Construct a copy of the tree. More... | |
virtual | ~NamedTree () |
Delete node in a tree. More... | |
void | purge (void) |
Performs object destruction. More... | |
![]() | |
NamedObject () | |
Create an empty unnamed cell object. More... | |
NamedObject (NamedObject **hash, char *name, unsigned size=1) | |
Create a named object and add to hash indexed list. More... | |
NamedObject (OrderedIndex *index, char *name) | |
Created a named object on an ordered list. More... | |
~NamedObject () | |
Destroy named object. More... | |
virtual void | clearId (void) |
The behavior of clearing id's can be overridden if they are not assigned as strdup's from the heap... More... | |
![]() | |
OrderedObject (OrderedIndex *index) | |
Construct an ordered object aot end of a an index. More... | |
OrderedObject () | |
Construct an ordered object unattached. More... | |
OrderedObject (const OrderedObject &from) | |
![]() | |
LinkedObject (LinkedObject **root) | |
Construct base class attached to a chain of objects. More... | |
LinkedObject () | |
Construct base class unattached to anyone. More... | |
LinkedObject (const LinkedObject &from) | |
Embed data objects into a tree structured memory database.
This can be used to form XML document trees or other data structures that can be organized in trees. The NamedTree class is used to manage the structure of the tree, and the type specified is embedded as a data value object which can be manipulated. Name identifiers are assumed to be dynamically allocated if tree node elements are deletable.
Embedded values can either be of direct types that are then stored as part of the template object, or of class types that are data pointers. The latter might be used for trees that contain data which might be parsed dynamically from a document and/or saved on a heap. Pointer trees assume that NULL pointers are for nodes that are empty, and that NULL data value nodes with children are trunk nodes. Generally data values are then allocated with a pointer stored in pure leaf nodes.
|
inline |
|
inline |
Construct a copy of the treemap object.
source | of copy for new object. |
Definition at line 1222 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
|
inline |
Construct a child node on an existing tree and assign it's value.
parent | of this node to attach. |
name | of this node. |
reference | to value to assign to this node. |
Definition at line 1239 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
Find a subnode from our node by name.
This performs a recursive search.
name | to search for. |
Definition at line 1370 of file linked.h.
References ucommon::NamedTree::find().
|
inline |
Return the typed value of this node.
Definition at line 1247 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
Get direct typed child node of our node of specified name.
This does not perform a recursive search.
name | of child node. |
Definition at line 1339 of file linked.h.
References ucommon::NamedTree::getChild().
|
inline |
Get the data value of a data based value tree.
Definition at line 1288 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
Get first child of our node.
This is useful for iterating children.
Definition at line 1398 of file linked.h.
References ucommon::NamedTree::getFirst().
|
inline |
Get child member node by index.
index | of child member. |
Definition at line 1321 of file linked.h.
References ucommon::NamedTree::Child, ucommon::OrderedIndex::getIndexed(), and ucommon::NamedObject::index().
|
inline |
Find a direct typed leaf node on our node.
A leaf node is a node that has no children of it's own. This does not perform a recursive search.
name | of leaf child node to find. |
Definition at line 1349 of file linked.h.
References ucommon::NamedTree::getLeaf().
Referenced by ucommon::treemap< T >::getValue().
|
inline |
Get the typed parent node for our node.
Definition at line 1329 of file linked.h.
References ucommon::NamedTree::Parent.
|
inlinestatic |
Return value from tree element when value is a pointer.
node | in our typed tree. |
Definition at line 1264 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
Get the pointer of a pointer based value tree.
Definition at line 1280 of file linked.h.
References ucommon::treemap< T >::value.
Referenced by ucommon::treemap< T >::getValue().
|
inline |
Get the value pointer of a leaf node of a pointer tree.
This allows one to find a leaf node and return it's pointer value in a single operation.
name | of leaf node. |
Definition at line 1360 of file linked.h.
References ucommon::treemap< T >::getLeaf(), and ucommon::treemap< T >::getPointer().
|
inline |
Test if this node is a leaf node for a tree pointer table.
Definition at line 1272 of file linked.h.
References ucommon::OrderedIndex::begin(), ucommon::NamedTree::Child, and ucommon::treemap< T >::value.
|
inline |
Search for a leaf node of our node.
This performs a recursive search.
name | to search for. |
Definition at line 1390 of file linked.h.
References ucommon::NamedTree::leaf().
|
inline |
Return typed value of this node by pointer reference.
Definition at line 1255 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
Assign the value of our node.
data | value to assign. |
Definition at line 1312 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
Find a subnode by pathname.
This is the same as the NamedTree path member function.
path | name to search for node. |
Definition at line 1380 of file linked.h.
References ucommon::NamedTree::path(), and ucommon::treemap< T >::path().
Referenced by ucommon::treemap< T >::path().
|
inline |
Set the value of a data based value tree.
reference | to value to copy into node. |
Definition at line 1304 of file linked.h.
References ucommon::treemap< T >::value.
|
inline |
Set the pointer of a pointer based value tree.
pointer | to set. |
Definition at line 1296 of file linked.h.
References ucommon::treemap< T >::value.
|
protected |
Definition at line 1208 of file linked.h.
Referenced by ucommon::treemap< T >::get(), ucommon::treemap< T >::getData(), ucommon::treemap< T >::getPointer(), ucommon::treemap< T >::is_attribute(), ucommon::treemap< T >::operator*(), ucommon::treemap< T >::operator=(), ucommon::treemap< T >::set(), ucommon::treemap< T >::setPointer(), and ucommon::treemap< T >::treemap().