fluidvis
Public Member Functions | Public Attributes | List of all members
sx::XTag Struct Reference

#include <SXParser.h>

Inheritance diagram for sx::XTag:
sx::XNode

Public Member Functions

EXPA XTag ()
 
EXPA ~XTag ()
 
EXPA void getTags (string location, vector< XTag * > &nodes)
 
EXPA XTaggetFirst (string location)
 
EXPA XTaggetFirst ()
 
EXPA string getStrAttribute (string ID)
 
EXPA double getRealAttribute (string ID)
 
EXPA void getDirectTexts (vector< string > &texts)
 
EXPA void getTexts (vector< string > &texts)
 
EXPA string getDirectTexts ()
 
EXPA string getTexts ()
 
EXPA void flattenTag (XTag &tag, map< string, vector< double >> &ambiguousReals, map< string, vector< string >> &ambiguousStrings)
 
- Public Member Functions inherited from sx::XNode
virtual EXPA ~XNode ()
 

Public Attributes

string name
 
map< string, string > stringAttribs
 
map< string, double > realAttribs
 
vector< XNode * > nodes
 

Additional Inherited Members

- Protected Member Functions inherited from sx::XNode
EXPA XNode ()
 

Detailed Description

tag node of the SX tag language, having a name assigned , and holding texts, attributes, and trees of tags

Constructor & Destructor Documentation

EXPA sx::XTag::XTag ( )

default constructor, initializing an empty node

EXPA sx::XTag::~XTag ( )

deconstructor, deconstructing every element attached to the tag (for instance as a (sub)child node, or a text node)

Member Function Documentation

EXPA void sx::XTag::flattenTag ( XTag tag,
map< string, vector< double >> &  ambiguousReals,
map< string, vector< string >> &  ambiguousStrings 
)

Collects all the text, textless leaf tags and attributes of the tree, and stores it in the node tag. Textless leaf tags with attributes are replaced by empty tags with the same names. The order of the texts and nodes is preserved. If attributes with the same identifyer appear multiple times in different nodes, their values are stored in the maps ambiguousReals and ambiguousStrings. Nodes of the tree are traversed from left to right, from the root to the leafs, and ambiguous attributes are owerwritten in the same order.

Parameters
tagA tag node, in which the outcome is stored
ambiguousRealsIf in different nodes real attributes with the same identifyer appear, the values are stored in a vector associated with the attribute name in ambiguousReals.
ambiguousStringsIf in different nodes string attributes with the same identifyer appear, the values are stored in a vector associated with the attribute name in ambiguousStrings.
EXPA void sx::XTag::getDirectTexts ( vector< string > &  texts)

Stores all texts of the direct textnode children the given order in texts.

Parameters
textsstores texts in this parameter
EXPA string sx::XTag::getDirectTexts ( )

Concatenates the text of all direct child nodes of type XText, and returns it.

Returns
concatenation of all direct textnode children
EXPA XTag* sx::XTag::getFirst ( string  location)

Searches the first node from left given by path location, and returns it.

Parameters
locationSpecification of a nodes location. Let be <n1> a child node of this, <n2> a childnode of <n1>, and so on, up to a node <nm>, such that the sequence forms a branch of a childtree of this, then the location of <nm> can be specified by a the sequence of names concatenated by points, like: <n1>.<n2>.<n3>. ... .<nm-2>.<nm-1>.<nm> If one of the names in the part equals the string '*', all nodes of that path are taken into consideration. Nodes always require to have a nonempty name, hence an empty location will lead to an empty outcome.
Returns
first node from left with path location
Exceptions
ifno such first node exists, an exception Exception of type EX_NODATA is thrown
EXPA XTag* sx::XTag::getFirst ( )

Returns the first childnode.

Returns
first childnode from left
Exceptions
ifno such first node exists, an exception Exception of type EX_NODATA is thrown
EXPA double sx::XTag::getRealAttribute ( string  ID)

Returns the value of the real attribute with identifyer ID.

Parameters
IDidentifyer of the attribute
Returns
value of the attribute
Exceptions
ifno attribute with ID exists, an exception Exception of type EX_NODATA is thrown
EXPA string sx::XTag::getStrAttribute ( string  ID)

Returns the value of the string attribute with identifyer ID.

Parameters
IDidentifyer of the attribute
Returns
value of the attribute
Exceptions
ifno attribute with ID exists, an exception Exception of type EX_NODATA is thrown
EXPA void sx::XTag::getTags ( string  location,
vector< XTag * > &  nodes 
)

Searches all nodes given by path location, and stores the outcome in the list nodes.

Parameters
locationSpecification of a nodes location. Let be <n1> a child node of this, <n2> a childnode of <n1>, and so on, up to a node <nm>, such that the sequence forms a branch of a childtree of this, then the location of <nm> can be specified by a the sequence of names concatenated by points, like: <n1>.<n2>.<n3>. ... .<nm-2>.<nm-1>.<nm> If one of the names in the part equals the string '*', all nodes of that path are taken into consideration. Nodes always require to have a nonempty name, hence an empty location will lead to an empty outcome.
textsnodes specified by the string location are stored in vector nodes
EXPA void sx::XTag::getTexts ( vector< string > &  texts)

Stores all texts of the text nodes in the given order in texts.

Parameters
textsstores texts in this parameter
EXPA string sx::XTag::getTexts ( )

Concatenates the text of all child nodes of type XText, and returns it.

Returns
concatenation of all textnode children

Member Data Documentation

string sx::XTag::name

name of the node

vector<XNode *> sx::XTag::nodes

List of child nodes

map<string,double> sx::XTag::realAttribs

Number attributes associated with numbers. Number attributes only need to be unique over the set of all number attributes.

map<string,string> sx::XTag::stringAttribs

String attributes associated with string. The attributes only need to be unique over the set of all string attributes in the same tag.


The documentation for this struct was generated from the following file: