node: Information

Top  Previous  Next

Scripts > Class elements and c++ instructions > Interpreted C++ instructions > node / dnode > node: Information

 

Information about the data of a node itself or about its position inside of a tree can be obtained by the following functions:

 

 

str                   label() const

void                  setLabel(const str& xsLabel)

str                   value() const

void                  setValue(const str& xsValue)

unsigned int          id() const

void                  setId(unsigned int xuiId)

 

bool                  hasChildren() const

bool                  isDescendant( const node& xNode ) const

bool                  isAncestor( const node& xNode ) const

bool                  isSibling( const node& xNode ) const

unsigned int          level() const

unsigned int          descendentsCount() const

unsigned int          childCount() const

 

void                setAttrib(const str& xsLabel, const str& xsValue)

str                attrib(const str& xsLabel)

 

 

str        label() const

 

Returns the value of the label.

 

 

void        setLabel(const str& xsLabel)

 

Sets the label of the node..

 

 

str        value() const

 

Returns the value of the node.

 

 

void        setValue(const str& xsValue)

 

Sets the value of the node.

 

 

unsigned int        id() const

void        setId(unsigned int xuiId)

 

These functions are reserved for further developments of the TextTransformers. The id type may change in future.

 

 

bool        hasChildren() const

 

The function returns true, if the node has a child node; otherwise false will be returned.

 

 

bool        isDescendant( const node& xNode ) const

 

By isDescendant you can determine, whether the passed node xNode contains to the branch, which has its origin in the actual node.

 

 

bool        isAncestor( const node& xNode ) const

 

By isAncestor you can determine, whether the actual nodes contains to the branch, which has its origin in the passed node xNode.

 

 

bool        isSibling( const node& xNode ) const

 

By isSibling you can determine, whether the passed node xNode follows in the sequence of siblings of the actual node.

 

 

unsigned int        level() const

 

This function returns 0 for the root node; the first child of the root has the level 1 and so on

 

unsigned int        descendentsCount() const

 

This function returns the number of nodes in the branch, which has its origin in the actual node.

 

unsigned int        childCount() const

 

This function returns the number of nodes, which immediately are subordinated to the actual node.

 

 

Attributes

 

Attributes consist of a key and an accompanying value. E.g. attributes are useful for the storage of ini entries: while the sections of the ini file are represented by nodes, the values of the section can be put as attributes.

 

void                setAttrib(const str& xsLabel, const str& xsValue)

 

For every node arbitrarily many attributes can be set with setAttrib. An attribute has a name xsLabel and a value belonging to it, xsValue. If the name isn't existing in the list of the attributes yet, then new attribute is inserted. If the name already exists, the according value will be overwritten with the new value.

 

 

str                attrib(const str& xsLabel)

 

By attrib the value with the name xsLabel can be read.

 

 

 

Example:

 

a) Parsing the ini file:

 

{{node n = xIni.add("[FONT]", ""); }}

 

"NAME"  "=" Value     {{ n.setAttrib("NAME", State.lp_str()); }}

"COLOR" "=" Value     {{ n.setAttrib("COLOR", State.lp_str()); }}

 

 

b) Using the values:

 

node n = Ini.findNextLabel("[FONT]")

 

SetValues(n.attrib("NAME"), n.attrib("COLOR"));

 



This page belongs to the TextTransformer Documentation

Home  Content  German