|
ContRap-Core
|
Class XMLDataPool is a query class object for XML-trees. More...
#include <xmldatapool.h>
Data Structures | |
| class | PoolEntry |
| Class PoolEntry is an internal structure for nodes in the XML data pool. More... | |
Public Member Functions | |
| XMLDataPool (const std::string &text="") | |
| Creates a new parser. | |
| virtual | ~XMLDataPool () |
| Cleans up the memory. | |
| void | clear () |
| Clears the contents of the pool. | |
| bool | set_value (const std::string &key, const std::string &value) |
| Sets a value at the given key. | |
| bool | set_bool (const std::string &key, bool value) |
| Sets a boolean value at the given key. | |
| bool | set_double (const std::string &key, double value) |
| Sets a double value at the given key. | |
| bool | add_value (const std::string &key, const std::string &tag, const std::string &value) |
| Adds a value at the given key. | |
| void | set_attribute (const std::string &key, const std::string &attribute, const std::string &value) |
| Sets an attribute at the given key. | |
| int | get_children (const std::string &key, const std::string &tag) |
| Returns the number of children of a given key. | |
| const std::string & | get_value (const std::string &key) |
| Returns a value. | |
| const std::string & | get_string (const std::string &key) |
| Returns a string value. | |
| int | get_int (const std::string &key) |
| Returns an integer value. | |
| double | get_double (const std::string &key) |
| Returns an double value. | |
| bool | get_bool (const std::string &key) |
| Returns an boolen value. | |
| const std::string & | get_attribute (const std::string &key, const std::string &attribute) |
| Returns a value of an attribute. | |
| const std::string & | get_string (const std::string &key, const std::string &attribute) |
| Returns a string of an attribute. | |
| int | get_int (const std::string &key, const std::string &attribute) |
| Returns an integer value. | |
| double | get_double (const std::string &key, const std::string &attribute) |
| Returns an double value. | |
| bool | get_bool (const std::string &key, const std::string &attribute) |
| Returns an boolen value. | |
| std::vector< std::string > | get_values (const std::string &key, const std::string &tag) |
| Returns the list of the values of the given key with the given end tag. | |
| std::vector< std::string > | get_values (const std::string &key) |
| Returns the list of all the values of the given key. | |
| std::map< std::string, std::string > * | get_attrubutes (const std::string &key) |
| Returns the map of all attributes. | |
| void | remove (const std::string &key) |
| Removes the data at the position given by the key and all its children. | |
| void | clear (const std::string &key) |
| Clears the contents inside the given key without removing the key's root. | |
| bool | is_set (const std::string &key) |
| Returns true if the key has an entry. | |
| int | find (const std::string &key, const std::string &tag, const std::string &subtag, const std::string &value) |
| Finds the order number of an entry with the given tag set to a specified value. | |
| int | find_attribute (const std::string &key, const std::string &tag, const std::string &attribute, const std::string &value) |
| Finds the order number of an entry with the given attribute set to a specified value. | |
| void | copy (XMLDataPool &source, const std::string &source_key, const std::string &destination_key) |
| Copies contents from one XML pool to the current. | |
| void | swap (const std::string &first_key, const std::string &second_key) |
| Swaps two entries within the current pool. | |
| bool | load (const std::string &file_name="") |
| Loads the contents of the pool from a file. | |
| bool | save (const std::string &file_name="") |
| Saves the contents of the pool to a file. | |
Protected Member Functions | |
| virtual bool | start () |
| XML parser event functions. | |
| virtual bool | enter (const std::string &tag, std::map< std::string, std::string > &attributes, bool end) |
| Event functions are called on entering, parsing and leaving tags. | |
| virtual bool | content (const std::string &tag, std::map< std::string, std::string > &attributes, const std::string &value, int count) |
| virtual bool | leave (const std::string &tag, std::map< std::string, std::string > &attributes) |
| PoolEntry * | get_entry (const std::string &key, bool add=false) |
| Returns the entry for a key. | |
| void | save_rec (std::ofstream &stream, PoolEntry *entry, int depth) |
| Recursive save procedure. | |
Protected Attributes | |
| PoolEntry | root |
| Pool data structure. | |
| std::stack< PoolEntry * > | stack |
| Currently parsed key. | |
| std::string | file_name |
| File name. | |
| std::string | empty_string |
| Empty string. | |
Class XMLDataPool is a query class object for XML-trees.
| crp::XMLDataPool::XMLDataPool | ( | const std::string & | text = "" | ) |
Creates a new parser.
| text | XML-formatted string |
| virtual crp::XMLDataPool::~XMLDataPool | ( | ) | [virtual] |
Cleans up the memory.
| bool crp::XMLDataPool::add_value | ( | const std::string & | key, |
| const std::string & | tag, | ||
| const std::string & | value | ||
| ) |
Adds a value at the given key.
| key | Key of the entry with tags separated by ':' |
| tag | Tag of the value |
| value | value Value to set |
| void crp::XMLDataPool::clear | ( | ) |
Clears the contents of the pool.
| void crp::XMLDataPool::clear | ( | const std::string & | key | ) |
Clears the contents inside the given key without removing the key's root.
| key | Key of the entry with tags separated by ':' |
| virtual bool crp::XMLDataPool::content | ( | const std::string & | tag, |
| std::map< std::string, std::string > & | attributes, | ||
| const std::string & | value, | ||
| int | count | ||
| ) | [protected, virtual] |
Reimplemented from crp::XMLParser.
| void crp::XMLDataPool::copy | ( | XMLDataPool & | source, |
| const std::string & | source_key, | ||
| const std::string & | destination_key | ||
| ) |
Copies contents from one XML pool to the current.
| source | Source pool |
| source_key | Key within the source pool |
| destination_key | Key within the destination pool |
| virtual bool crp::XMLDataPool::enter | ( | const std::string & | tag, |
| std::map< std::string, std::string > & | attributes, | ||
| bool | end | ||
| ) | [protected, virtual] |
Event functions are called on entering, parsing and leaving tags.
A false returned by an event function results in an error break.
Reimplemented from crp::XMLParser.
| int crp::XMLDataPool::find | ( | const std::string & | key, |
| const std::string & | tag, | ||
| const std::string & | subtag, | ||
| const std::string & | value | ||
| ) |
Finds the order number of an entry with the given tag set to a specified value.
| key | Key to the root entry |
| tag | Base tag of the child entry |
| subtag | Tag of a child check for equality |
| value | Value of the tag |
| int crp::XMLDataPool::find_attribute | ( | const std::string & | key, |
| const std::string & | tag, | ||
| const std::string & | attribute, | ||
| const std::string & | value | ||
| ) |
Finds the order number of an entry with the given attribute set to a specified value.
| key | Key to the root entry |
| tag | Base tag of the child entry |
| subtag | Tag of a child check for equality |
| value | Value of the tag |
| const std::string& crp::XMLDataPool::get_attribute | ( | const std::string & | key, |
| const std::string & | attribute | ||
| ) |
Returns a value of an attribute.
| key | Key of the entry with tags separated by ':' |
| attribute | Name of the attribute |
| std::map<std::string, std::string>* crp::XMLDataPool::get_attrubutes | ( | const std::string & | key | ) |
Returns the map of all attributes.
| key | Key to a list of values |
| bool crp::XMLDataPool::get_bool | ( | const std::string & | key, |
| const std::string & | attribute | ||
| ) |
Returns an boolen value.
| key | Key of the entry with tags separated by ':' |
| attribute | Name of the attribute |
| bool crp::XMLDataPool::get_bool | ( | const std::string & | key | ) |
Returns an boolen value.
| key | Key of the entry with tags separated by ':' |
| int crp::XMLDataPool::get_children | ( | const std::string & | key, |
| const std::string & | tag | ||
| ) |
Returns the number of children of a given key.
| key | Key of the entry with tags separated by ':' |
| double crp::XMLDataPool::get_double | ( | const std::string & | key, |
| const std::string & | attribute | ||
| ) |
Returns an double value.
| key | Key of the entry with tags separated by ':' |
| attribute | Name of the attribute |
| double crp::XMLDataPool::get_double | ( | const std::string & | key | ) |
Returns an double value.
| key | Key of the entry with tags separated by ':' |
| PoolEntry* crp::XMLDataPool::get_entry | ( | const std::string & | key, |
| bool | add = false |
||
| ) | [protected] |
Returns the entry for a key.
| int crp::XMLDataPool::get_int | ( | const std::string & | key | ) |
Returns an integer value.
| key | Key of the entry with tags separated by ':' |
| int crp::XMLDataPool::get_int | ( | const std::string & | key, |
| const std::string & | attribute | ||
| ) |
Returns an integer value.
| key | Key of the entry with tags separated by ':' |
| attribute | Name of the attribute |
| const std::string& crp::XMLDataPool::get_string | ( | const std::string & | key | ) | [inline] |
Returns a string value.
| key | Key of the entry with tags separated by ':' |
| const std::string& crp::XMLDataPool::get_string | ( | const std::string & | key, |
| const std::string & | attribute | ||
| ) | [inline] |
Returns a string of an attribute.
| key | Key of the entry with tags separated by ':' |
| attribute | Name of the attribute |
| const std::string& crp::XMLDataPool::get_value | ( | const std::string & | key | ) |
Returns a value.
| key | Key of the entry with tags separated by ':' |
| std::vector<std::string> crp::XMLDataPool::get_values | ( | const std::string & | key, |
| const std::string & | tag | ||
| ) |
Returns the list of the values of the given key with the given end tag.
| key | Key to a list of values |
| tag | End tag key:tag |
| std::vector<std::string> crp::XMLDataPool::get_values | ( | const std::string & | key | ) |
Returns the list of all the values of the given key.
| key | Key to a list of values |
| bool crp::XMLDataPool::is_set | ( | const std::string & | key | ) |
Returns true if the key has an entry.
| key | Key of the entry with tags separated by ':' |
| virtual bool crp::XMLDataPool::leave | ( | const std::string & | tag, |
| std::map< std::string, std::string > & | attributes | ||
| ) | [protected, virtual] |
Reimplemented from crp::XMLParser.
| bool crp::XMLDataPool::load | ( | const std::string & | file_name = "" | ) |
Loads the contents of the pool from a file.
An empty file name leads to a reload.
| file_name | Name of the file |
| void crp::XMLDataPool::remove | ( | const std::string & | key | ) |
Removes the data at the position given by the key and all its children.
| key | Key of the entry with tags separated by ':' |
| bool crp::XMLDataPool::save | ( | const std::string & | file_name = "" | ) |
Saves the contents of the pool to a file.
An empty file name leads to overwriting the last saved file.
| file_name | Name of the file |
| void crp::XMLDataPool::save_rec | ( | std::ofstream & | stream, |
| PoolEntry * | entry, | ||
| int | depth | ||
| ) | [protected] |
Recursive save procedure.
| void crp::XMLDataPool::set_attribute | ( | const std::string & | key, |
| const std::string & | attribute, | ||
| const std::string & | value | ||
| ) |
Sets an attribute at the given key.
| key | Key of the entry with tags separated by ':' |
| attribute | Attribute of the key value Value to set |
| bool crp::XMLDataPool::set_bool | ( | const std::string & | key, |
| bool | value | ||
| ) | [inline] |
Sets a boolean value at the given key.
| key | Key of the entry with tags separated by ':' |
| value | value Value to set |
| bool crp::XMLDataPool::set_double | ( | const std::string & | key, |
| double | value | ||
| ) | [inline] |
Sets a double value at the given key.
| key | Key of the entry with tags separated by ':' |
| value | value Value to set |
| bool crp::XMLDataPool::set_value | ( | const std::string & | key, |
| const std::string & | value | ||
| ) |
Sets a value at the given key.
| key | Key of the entry with tags separated by ':' |
| value | value Value to set |
| virtual bool crp::XMLDataPool::start | ( | ) | [protected, virtual] |
XML parser event functions.
Reimplemented from crp::XMLParser.
| void crp::XMLDataPool::swap | ( | const std::string & | first_key, |
| const std::string & | second_key | ||
| ) |
Swaps two entries within the current pool.
| first_key | Key of the first entry |
| second_key | Key of the second entry |
std::string crp::XMLDataPool::empty_string [protected] |
Empty string.
std::string crp::XMLDataPool::file_name [protected] |
File name.
PoolEntry crp::XMLDataPool::root [protected] |
Pool data structure.
std::stack<PoolEntry*> crp::XMLDataPool::stack [protected] |
Currently parsed key.
1.7.3