ElementT Class Template Reference

Inheritance diagram for ElementT:

SectionT List of all members.

Detailed Description

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

Configuration element.

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.

See also:
Configuration tools

Main typedefs

Constructors & destructor

Assignments

Name & value

Prefix & suffix comments

Full name

Auxiliary

Related Functions

(Note that these are not member functions.)

Member Typedef Documentation

typedef implementation_defined_1 String

String type.

Reimplemented in SectionT.

typedef implementation_defined_2 Char

Char type.

Reimplemented in SectionT.


Constructor & Destructor Documentation

ElementT (  )  [inline]

Default constructor.

This constructor creates a empty configuration element: the name, value, prefix and suffix comments are empty.

ElementT ( const String element_name  )  [inline, explicit]

Create with specified name.

This constructor initializes element name by element_name. The value, prefix and suffix comments are empty.

Parameters:
[in] element_name The element's name.

ElementT ( const Char element_name  )  [inline, explicit]

Create with specified name.

This constructor initializes element name by element_name. The value, prefix and suffix comments are empty.

Parameters:
[in] element_name The element's name.

ElementT ( const ThisType other  )  [inline]

Copy constructor.

This constructor initializes the element by other.

Parameters:
[in] other The other element.

virtual ~ElementT (  )  [inline, virtual]

Destructor.

The virtual destructor is used for derived classes.


Member Function Documentation

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

Assignment operator.

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

Reimplemented in SectionT.

ThisType& operator= ( const String new_val  )  [inline]

Assign a new element's value.

This assignment operator allows to implicit set the element's value.

Parameters:
[in] new_val The new element's value.
Returns:
Self reference.

ThisType& operator= ( const Char new_val  )  [inline]

Assign a new element's value.

This assignment operator allows to implicit set the element's value.

Parameters:
[in] new_val The new element's value.
Returns:
Self reference.

const String& name (  )  const [inline]

Get element's name.

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

Returns:
Constant name reference.

String& name (  )  [inline]

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]

Get element's value.

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

Returns:
Constant value reference.

String& val (  )  [inline]

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]

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]

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]

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]

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]

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]

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]

Get element's full name.

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

Returns:
The element's full name.

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.

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

Reimplemented in SectionT.

void swap ( ThisType other  )  [inline]

Swap two elements.

This method swaps the two elements. The parents are not changed.

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

    // ...
  }

Returns:
The empty element.

Reimplemented in SectionT.


Friends And Related Function Documentation

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

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]

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.

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

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.


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