class skTreeNode

This class encapsulates a node in a tree

Public Methods

skTreeNode()
Default Constructor - blank label, data and an empty children list
virtual ~skTreeNode()
Destructor
skTreeNode(const skTreeNode& )
Copy Constructor - does a deep copy
skTreeNode(const skString& label)
Constructor - creates a treenode with the given label
skTreeNode(const skString& label, const skString& data)
Constructor - creates a treenode with the given label and data
skTreeNode(const skString& label, bool data)
Constructor - creates a treenode with the given label and data (converted to a string form)
skTreeNode(const skString& label, int data)
Constructor - creates a treenode with the given label and data (converted to a string form)
skTreeNode(const skString& label, long data)
Constructor - creates a treenode with the given label and data (converted to a string form)
skTreeNode(const skString& label, float data)
Constructor - creates a treenode with the given label and data (converted to a string form)
skTreeNode& operator=(const skTreeNode& )
Assignment operator - does a deep copy
skString label() const
Returns this node's label
void label(const skString& s)
Changes this node's label
skString data() const
Returns this node's data
void data(const skString& s)
Changes this node's data
bool boolData() const
Returns this node's data as a boolean value
void boolData(bool)
Changes this node's data - converting the value to a string
int intData() const
Returns this node's data as an integer value
void intData(int)
Changes this node's data - converting the value to a string
long longData() const
Returns this node's data as a long integer value
void longData(long)
Changes this node's data - converting the value to a string
float floatData() const
Returns this node's data as a float value
void floatData(float)
Changes this node's data - converting the value to a string
void prependChild(skTreeNode*)
adds the given node to the start of the child list for this node
void addChild(skTreeNode*)
adds the given node to the end of the child list for this node
void setChild(skTreeNode*)
Assigns the given node to the first node with the matching label in the child list of this node
void deleteChild(skTreeNode*)
deletes the given node from the list of children at this node
bool containsChild(skTreeNode*)
Returns true if the child list of this node contains the given node
skTreeNode* findChild(const skString& label) const
This method searches for a node whose label matches the one given
skTreeNode* findChild(const skString& label, const skString& data) const
This method searches for a node whose label and data matches the ones given
skString findChildData(const skString& label, const skString& defaultVal) const
Finds the data associated with the first child whose label matches that given
bool findChildboolData(const skString& label, bool defaultVal=false) const
Finds the data associated with the first child whose label matches that given as a boolean
int findChildIntData(const skString& label, int defaultVal=0) const
Finds the data associated with the first child whose label matches that given as an integer
long findChildLongData(const skString& label, long defaultVal=0) const
Finds the data associated with the first child whose label matches that given as a long integer
float findChildFloatData(const skString& label, float defaultVal=0.0f) const
Finds the data associated with the first child whose label matches that given as a float
skString nthChildData(USize index) const
Returns the data for nth child in the list of children at this node
int nthChildIntData(USize index) const
Returns the data for nth child in the list of children at this node as an integer
void write(ostream& out, USize tabstops) const
Writes this node to an output stream with the given indentation
bool write(const skString& file) const
Writes this node out to a file
skTreeNode* nthChild(USize i) const
Returns a child from the list at this node
USize numChildren() const
Returns the number of children at this node
void copyItems(skTreeNode& node)
makes a deep copy of the items from the other node, but does not change the label or data of this node
void moveItemsFrom(skTreeNode& node)
Moves the items from the child list of the given node into this node
void clear()
deletes all children from the list
static skTreeNode* read(const skString& file)
Reads a treenode from the given file

Documentation

This class encapsulates a node in a tree. The node has a label, a piece of data and a list of subitems
skTreeNode()
Default Constructor - blank label, data and an empty children list

virtual ~skTreeNode()
Destructor

skTreeNode(const skTreeNode& )
Copy Constructor - does a deep copy

skTreeNode(const skString& label)
Constructor - creates a treenode with the given label

skTreeNode(const skString& label, const skString& data)
Constructor - creates a treenode with the given label and data

skTreeNode(const skString& label, bool data)
Constructor - creates a treenode with the given label and data (converted to a string form)

skTreeNode(const skString& label, int data)
Constructor - creates a treenode with the given label and data (converted to a string form)

skTreeNode(const skString& label, long data)
Constructor - creates a treenode with the given label and data (converted to a string form)

skTreeNode(const skString& label, float data)
Constructor - creates a treenode with the given label and data (converted to a string form)

skTreeNode& operator=(const skTreeNode& )
Assignment operator - does a deep copy

skString label() const
Returns this node's label

void label(const skString& s)
Changes this node's label

skString data() const
Returns this node's data

void data(const skString& s)
Changes this node's data

bool boolData() const
Returns this node's data as a boolean value

void boolData(bool)
Changes this node's data - converting the value to a string

int intData() const
Returns this node's data as an integer value

void intData(int)
Changes this node's data - converting the value to a string

long longData() const
Returns this node's data as a long integer value

void longData(long)
Changes this node's data - converting the value to a string

float floatData() const
Returns this node's data as a float value

void floatData(float)
Changes this node's data - converting the value to a string

void prependChild(skTreeNode*)
adds the given node to the start of the child list for this node

void addChild(skTreeNode*)
adds the given node to the end of the child list for this node

void setChild(skTreeNode*)
Assigns the given node to the first node with the matching label in the child list of this node. If no match is found, the node is added to the end of the list

void deleteChild(skTreeNode*)
deletes the given node from the list of children at this node

bool containsChild(skTreeNode*)
Returns true if the child list of this node contains the given node

skTreeNode* findChild(const skString& label) const
This method searches for a node whose label matches the one given
Returns:
the first match, or 0 if none found

skTreeNode* findChild(const skString& label, const skString& data) const
This method searches for a node whose label and data matches the ones given
Returns:
the first match, or 0 if none found

skString findChildData(const skString& label, const skString& defaultVal) const
Finds the data associated with the first child whose label matches that given
Returns:
the value of a matched child's data, or the default value
Parameters:
label - - the label to look for
defaultVal - - the value to return if a match is not found

bool findChildboolData(const skString& label, bool defaultVal=false) const
Finds the data associated with the first child whose label matches that given as a boolean
Returns:
the value of a matched child's data, or the default value
Parameters:
label - - the label to look for
defaultVal - - the value to return if a match is not found

int findChildIntData(const skString& label, int defaultVal=0) const
Finds the data associated with the first child whose label matches that given as an integer
Returns:
the value of a matched child's data, or the default value
Parameters:
label - - the label to look for
defaultVal - - the value to return if a match is not found

long findChildLongData(const skString& label, long defaultVal=0) const
Finds the data associated with the first child whose label matches that given as a long integer
Returns:
the value of a matched child's data, or the default value
Parameters:
label - - the label to look for
defaultVal - - the value to return if a match is not found

float findChildFloatData(const skString& label, float defaultVal=0.0f) const
Finds the data associated with the first child whose label matches that given as a float
Returns:
the value of a matched child's data, or the default value
Parameters:
label - - the label to look for
defaultVal - - the value to return if a match is not found

skString nthChildData(USize index) const
Returns the data for nth child in the list of children at this node

int nthChildIntData(USize index) const
Returns the data for nth child in the list of children at this node as an integer

void write(ostream& out, USize tabstops) const
Writes this node to an output stream with the given indentation

bool write(const skString& file) const
Writes this node out to a file
Returns:
true if the file could be written, or false if there was a problem

skTreeNode* nthChild(USize i) const
Returns a child from the list at this node
Throws:
skBoundsException if the index is outside the range of the list
Returns:
the child
Parameters:
i - - the index of the item

USize numChildren() const
Returns the number of children at this node

void copyItems(skTreeNode& node)
makes a deep copy of the items from the other node, but does not change the label or data of this node

void moveItemsFrom(skTreeNode& node)
Moves the items from the child list of the given node into this node

void clear()
deletes all children from the list

static skTreeNode* read(const skString& file)
Reads a treenode from the given file
Throws:
skTreeNodeReaderException if there was an error in the file


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de