Inheritance diagram for SectionT:
The configuration section contains the list of the child elements and the list of the child sections.
Because the SectionT class is derived from the ElementT class, it also contains name, value (!), prefix and suffix comments.
Единый список секций и параметров служит для организации проивольного порядка секций и параметров. Т.е. секции и параметры могут чередоваться. Так, например, при чтении секции из файла конфигурации сохраняется относительный порядок дочерних секций и параметров.
The Str template parameter defines the string container type. A usual Str types are std::wstring or std::string.
typedef inherited::String String |
typedef inherited::Char Char |
typedef ElementListT<String> ElementList |
List of child elements.
typedef SectionListT<String> SectionList |
List of child sections.
SectionT | ( | ) | [inline] |
Default constructor.
The created section has no child elements and no child sections.
Create with specified name.
This constructor creates the empty section with name section_name.
[in] | section_name | The section's name. |
Create with specified name.
This constructor creates the empty section with name section_name.
[in] | section_name | The section's name. |
Copy constructor.
This constructor initializes the section by other.
[in] | other | The other section. |
virtual ~SectionT | ( | ) | [inline, virtual] |
Destructor.
The destructor removes all child elements and all child sections.
Assignment operator.
[in] | other | The other section. |
Reimplemented from ElementT.
Merge configuration.
This method replaces the some child elements and some child sections with corresponding child elements and child sections of other section. The only elements with the same names will be replaces. If element with specified name not exists yet, it will be added.
For examples, let two section A and B:
<A> elem1 = "A_value1" elem2 = "A_value2" </A> <B> elem1 = "B_value1" elem3 = "B_value3" </B>
After the command A.merge(B), the A section will be:
<A> elem1 = "B_value1" elem2 = "A_value2" elem3 = "B_value3" </B>
[in] | other | The other section. |
bool equal | ( | const ThisType & | other | ) | const [inline] |
Are two sections equal?
The two sections are equal is they have the same names, the same values, the same prefix and suffix comments and the same child elements and child sections.
[in] | other | The other section. |
Reimplemented from ElementT.
void swap | ( | ThisType & | other | ) | [inline] |
Swap sections.
This method swaps the two sections.
[in,out] | other | The other section. |
Reimplemented from ElementT.
static const ThisType& EMPTY | ( | ) | [inline, static] |
Get empty section.
This static method returns a constant reference to the empty section. This empty section may be used as default value.
void f(const Section &cfg) { const Section &sub_cfg = cfg.sections.get("child", Section::EMPTY()); // ... }
Reimplemented from ElementT.
const String& name | ( | ) | const [inline, inherited] |
Get element's name.
This method returns a constant reference to the element's name.
String& name | ( | ) | [inline, inherited] |
Get/set element's name.
This method returns a non-constant reference to the element's name.
const String& val | ( | ) | const [inline, inherited] |
Get element's value.
This method returns a constant reference to the element's value.
String& val | ( | ) | [inline, inherited] |
Get/set element's value.
This method returns a non-constant reference to the element's value.
const String& prefix | ( | ) | const [inline, inherited] |
Get element's prefix comment.
This method returns a constant reference to the element's prefix comment.
String& prefix | ( | ) | [inline, inherited] |
Get/set element's prefix comment.
This method returns a non-constant reference to the element's prefix comment.
const String& suffix | ( | ) | const [inline, inherited] |
Get element's suffix comment.
This method returns a constant reference to the element's suffix comment.
String& suffix | ( | ) | [inline, inherited] |
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, inherited] |
Get element's full name.
This method returns the element's full name using default separator ":".
Are two sections equal?
This operator is equivalent to the:
x.equal(y);
[in] | x | The first section. |
[in] | y | The second section. |
Are two sections non-equal?
This operator is equivalent to the:
!x.equal(y);
[in] | x | The first section. |
[in] | y | The second section. |
Swap two sections.
This function is equivalent to the:
x.swap(y);
[in,out] | x | The first section. |
[in,out] | y | The second section. |
std::basic_istream< Ch, Tr > & operator>> | ( | std::basic_istream< Ch, Tr > & | is, | |
SectionT< Str > & | cfg | |||
) | [related] |
Разобрать из потока ввода.
Оператор разбирает секцию cfg из потока ввода is.
[in] | is | Поток ввода |
[out] | cfg | Секция |
std::basic_ostream< Ch, Tr > & operator<< | ( | std::basic_ostream< Ch, Tr > & | os, | |
const SectionT< Str > & | section | |||
) | [related] |
Write to output stream.
Оператор выводит секцию cfg в поток вывода os.
Используется простое форматирование с параметрами по умолчанию.
[in] | os | Output stream. |
[in] | section | Configuration section. |
Swap two elements.
This function is equivalent to the:
x.swap(y);
[in,out] | x | The first element. |
[in,out] | y | The second element. |
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. |
List of the child elements.
Because ElementList has operator()() and operator[]() you cat use the following code:
void f(const Section &cfg) { cfg.elements().get("elem_name"); cfg.elements.get("elem_name"); cfg.elements["elem_name"]; }
List of the child sections.
Because ElementList has operator()() and operator[]() you cat use the following code:
void f(const Section &cfg) { cfg.sections().get("child_name"); cfg.sections.get("child_name"); cfg.sections["child_name"]; }