Inheritance diagram for ElementT:
This class represents a custom configuration element. The configuration element contains name, value and optional prefix and suffix comments. For example:
# prefix comment elem_name = "elem_value" # suffix comment
If the example will be parsed, then the element will have the following properties:
The fullName() method returns a configuration element's full name, including full path (i.e. names of all parents, see SectionT class).
It is possible to implicit assign the configuration element's value.
void f(Element &elem) { elem.val() = "new value"; // -or- elem = "new value"; }
The equal() method compares two configuration elements. Two configuration elements are equal if they have the same names, same values, and same prefix and suffix comments. The == and != operators also available.
The Str template parameter defines the string container type. A usual Str types are std::wstring or std::string.
ElementT | ( | ) | [inline] |
Default constructor.
This constructor creates a empty configuration element: the name, value, prefix and suffix comments are empty.
Create with specified name.
This constructor initializes element name by element_name. The value, prefix and suffix comments are empty.
[in] | element_name | The element's name. |
Create with specified name.
This constructor initializes element name by element_name. The value, prefix and suffix comments are empty.
[in] | element_name | The element's name. |
Copy constructor.
This constructor initializes the element by other.
[in] | other | The other element. |
virtual ~ElementT | ( | ) | [inline, virtual] |
Destructor.
The virtual destructor is used for derived classes.
Assignment operator.
[in] | other | The other element. |
Reimplemented in SectionT.
Assign a new element's value.
This assignment operator allows to implicit set the element's value.
[in] | new_val | The new element's value. |
Assign a new element's value.
This assignment operator allows to implicit set the element's value.
[in] | new_val | The new element's value. |
const String& name | ( | ) | const [inline] |
Get element's name.
This method returns a constant reference to the element's name.
String& name | ( | ) | [inline] |
Get/set element's name.
This method returns a non-constant reference to the element's name.
const String& val | ( | ) | const [inline] |
Get element's value.
This method returns a constant reference to the element's value.
String& val | ( | ) | [inline] |
Get/set element's value.
This method returns a non-constant reference to the element's value.
const String& prefix | ( | ) | const [inline] |
Get element's prefix comment.
This method returns a constant reference to the element's prefix comment.
String& prefix | ( | ) | [inline] |
Get/set element's prefix comment.
This method returns a non-constant reference to the element's prefix comment.
const String& suffix | ( | ) | const [inline] |
Get element's suffix comment.
This method returns a constant reference to the element's suffix comment.
String& suffix | ( | ) | [inline] |
Get/set element's suffix comment.
This method returns a non-constant reference to the element's suffix comment.
Get element's full name.
This method returns the element's full name, including all parents. The parent names are separated by sep string. For example, if sep is equal to the "|", then the full name of element "param1" will be "root|section|param1":
<root>
<section>
param1 = "value1"
</section>
</root>
[in] | sep | The separator. |
Get element's full name.
This method returns the element's full name, including all parents. The parent names are separated by sep string. For example, if sep is equal to the "|", then the full name of element "param1" will be "root|section|param1":
<root>
<section>
param1 = "value1"
</section>
</root>
[in] | sep | The separator. |
const String fullName | ( | ) | const [inline] |
Get element's full name.
This method returns the element's full name using default separator ":".
bool equal | ( | const ThisType & | other | ) | const [inline] |
Are two elements equal?
The two elements are equal if they have the same names, the same values and the same prefix and suffix comments.
[in] | other | The other element. |
Reimplemented in SectionT.
void swap | ( | ThisType & | other | ) | [inline] |
Swap two elements.
This method swaps the two elements. The parents are not changed.
[in,out] | other | The other element. |
Reimplemented in SectionT.
static const ThisType& EMPTY | ( | ) | [inline, static] |
Get empty element.
This static method returns a constant reference to the empty element. This empty element may be used as default value.
void f(const Section &cfg) { const Element &elem = cfg.elements.get("param", Element::EMPTY()); // ... }
Reimplemented in SectionT.
Are two elements equal?
This operator is equivalent to the:
x.equal(y);
[in] | x | The first element. |
[in] | y | The second element. |
Are two elements non-equal?
This operator is equivalent to the:
!x.equal(y);
[in] | x | The first element. |
[in] | y | The second element. |
Swap two elements.
This function is equivalent to the:
x.swap(y);
[in,out] | x | The first element. |
[in,out] | y | The second element. |