SectionT Class Template Reference

Inheritance diagram for SectionT:

ElementT List of all members.

Detailed Description

template<typename Str>
class omni::conf::SectionT< Str >

Configuration section.

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.

See also:
Configuration tools

Main typedefs

Child elements & child sections

Constructors & destructor

Assignments

Auxiliary

Name & value

Prefix & suffix comments

Full name

Related Functions

(Note that these are not member functions.)

Member Typedef Documentation

typedef inherited::String String

String type.

Reimplemented from ElementT.

typedef inherited::Char Char

Char type.

Reimplemented from ElementT.

typedef ElementListT<String> ElementList

List of child elements.

typedef SectionListT<String> SectionList

List of child sections.


Constructor & Destructor Documentation

SectionT (  )  [inline]

Default constructor.

The created section has no child elements and no child sections.

SectionT ( const String section_name  )  [inline, explicit]

Create with specified name.

This constructor creates the empty section with name section_name.

Parameters:
[in] section_name The section's name.

SectionT ( const Char section_name  )  [inline, explicit]

Create with specified name.

This constructor creates the empty section with name section_name.

Parameters:
[in] section_name The section's name.

SectionT ( const ThisType other  )  [inline]

Copy constructor.

This constructor initializes the section by other.

Parameters:
[in] other The other section.

virtual ~SectionT (  )  [inline, virtual]

Destructor.

The destructor removes all child elements and all child sections.


Member Function Documentation

ThisType& operator= ( const ThisType other  )  [inline]

Assignment operator.

Parameters:
[in] other The other section.
Returns:
Self reference.

Reimplemented from ElementT.

ThisType& merge ( const ThisType other  )  [inline]

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>

Parameters:
[in] other The other section.
Returns:
Self reference.

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.

Parameters:
[in] other The other section.
Returns:
true if two sections are equal, otherwise false.

Reimplemented from ElementT.

void swap ( ThisType other  )  [inline]

Swap sections.

This method swaps the two sections.

Parameters:
[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());

    // ...
  }

Returns:
The empty section.

Reimplemented from ElementT.

const String& name (  )  const [inline, inherited]

Get element's name.

This method returns a constant reference to the element's name.

Returns:
Constant name reference.

String& name (  )  [inline, inherited]

Get/set element's name.

This method returns a non-constant reference to the element's name.

Returns:
Non-constant name reference.

const String& val (  )  const [inline, inherited]

Get element's value.

This method returns a constant reference to the element's value.

Returns:
Constant value reference.

String& val (  )  [inline, inherited]

Get/set element's value.

This method returns a non-constant reference to the element's value.

Returns:
Non-constant value reference.

const String& prefix (  )  const [inline, inherited]

Get element's prefix comment.

This method returns a constant reference to the element's prefix comment.

Returns:
Constant prefix comment reference.

String& prefix (  )  [inline, inherited]

Get/set element's prefix comment.

This method returns a non-constant reference to the element's prefix comment.

Returns:
Non-constant prefix comment reference.

const String& suffix (  )  const [inline, inherited]

Get element's suffix comment.

This method returns a constant reference to the element's suffix comment.

Returns:
Constant suffix comment reference.

String& suffix (  )  [inline, inherited]

Get/set element's suffix comment.

This method returns a non-constant reference to the element's suffix comment.

Returns:
Non-constant suffix comment reference.

const String fullName ( const String sep  )  const [inline, inherited]

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>

Parameters:
[in] sep The separator.
Returns:
The element's full name.

const String fullName ( const Char sep  )  const [inline, inherited]

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>

Parameters:
[in] sep The separator.
Returns:
The element's full name.

const String fullName (  )  const [inline, inherited]

Get element's full name.

This method returns the element's full name using default separator ":".

Returns:
The element's full name.


Friends And Related Function Documentation

bool operator== ( const SectionT< Str > &  x,
const SectionT< Str > &  y 
) [related]

Are two sections equal?

This operator is equivalent to the:

  x.equal(y);

Parameters:
[in] x The first section.
[in] y The second section.
Returns:
true if two sections are equal, otherwise false.

bool operator!= ( const SectionT< Str > &  x,
const SectionT< Str > &  y 
) [related]

Are two sections non-equal?

This operator is equivalent to the:

  !x.equal(y);

Parameters:
[in] x The first section.
[in] y The second section.
Returns:
true if two sections are non-equal, otherwise false.

void swap ( SectionT< Str > &  x,
SectionT< Str > &  y 
) [related]

Swap two sections.

This function is equivalent to the:

  x.swap(y);

Parameters:
[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.

Parameters:
[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.

Используется простое форматирование с параметрами по умолчанию.

Parameters:
[in] os Output stream.
[in] section Configuration section.
Returns:
Output stream.

void swap ( ElementT< Str > &  x,
ElementT< Str > &  y 
) [related, inherited]

Swap two elements.

This function is equivalent to the:

  x.swap(y);

Parameters:
[in,out] x The first element.
[in,out] y The second element.

bool operator== ( const ElementT< Str > &  x,
const ElementT< Str > &  y 
) [related, inherited]

Are two elements equal?

This operator is equivalent to the:

  x.equal(y);

Parameters:
[in] x The first element.
[in] y The second element.
Returns:
true if two elements are equal, otherwise false.

bool operator!= ( const ElementT< Str > &  x,
const ElementT< Str > &  y 
) [related, inherited]

Are two elements non-equal?

This operator is equivalent to the:

  !x.equal(y);

Parameters:
[in] x The first element.
[in] y The second element.
Returns:
true if two elements are non-equal, otherwise false.


Member Data Documentation

ElementList elements

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"];
  }

See also:
ElementListT

SectionList sections

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"];
  }

See also:
SectionListT


Generated on Wed Jun 6 17:27:47 2007 for OMNI by  doxygen 1.5.2