Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends

ts::config::Configuration Class Reference

Container for a configuration. More...

#include <TsValue.h>

Collaboration diagram for ts::config::Configuration:
Collaboration graph
[legend]

Public Types

typedef Configuration self
 Self reference type.

Public Member Functions

bool operator! () const
 Check if configuration is (not) valid.
 operator detail::PseudoBool::Type () const
 Check if the configuration is valid.
Value getRoot () const
 Get the root Value of the configuration.
size_t childCount () const
 Get the number of child values on the root value.
Value operator[] (size_t idx) const
 Root value child access by index.
Value operator[] (ConstBuffer const &name) const
 Root value child access by name.
Value operator[] (char const *name) const
 Root value child access by name.
Value find (char const *path)
 Find a value.
Buffer alloc (size_t n)
 Allocate a local buffer of size n.

Static Public Member Functions

static Rv< selfloadFromPath (char const *path)
 Load a configuration from a file.

Protected Attributes

detail::ValueTable _table
 Table of values from the configuration.

Friends

class Value

Detailed Description

Container for a configuration.

This is a wrapper class that holds a shared reference to a configuration.

Definition at line 346 of file TsValue.h.


Member Typedef Documentation

Self reference type.

Definition at line 349 of file TsValue.h.


Member Function Documentation

Buffer ts::config::Configuration::alloc ( size_t  n  )  [inline]

Allocate a local buffer of size n.

This buffer will persist until the implementation instance is destroyed.

Returns:
The allocated buffer.
Parameters:
n requested size of buffer.

Definition at line 732 of file TsValue.h.

References _table, and ts::config::detail::ValueTable::alloc().

size_t ts::config::Configuration::childCount (  )  const [inline]

Get the number of child values on the root value.

Definition at line 733 of file TsValue.h.

References ts::config::Value::childCount(), and getRoot().

Value ts::config::Configuration::find ( char const *  path  )  [inline]

Find a value.

Returns:
The value if found, an void valid if not.
Parameters:
path configuration path to value.

Definition at line 731 of file TsValue.h.

References ts::config::Value::find(), and getRoot().

Value ts::config::Configuration::getRoot (  )  const

Get the root Value of the configuration.

The root is always a group and has no name.

Returns:
The root value.

Definition at line 327 of file TsValue.cc.

References _table, ts::config::detail::ValueTable::forceRootItem(), and Value.

Referenced by ts::config::Builder::build(), childCount(), find(), operator[](), and ts::config::Value::operator[]().

Rv< Configuration > ts::config::Configuration::loadFromPath ( char const *  path  )  [static]

Load a configuration from a file.

Note:
Check the returned errata for problems during configuration load. It is probably not a good idea to use the configuration in any error are reported.
Returns:
A new Configuration and errata.
Parameters:
path file system path.

Definition at line 333 of file TsValue.cc.

References _fileno, ts::Buffer::_ptr, ts::Buffer::_size, ts::msg::logf_errno(), ts::Rv< R >::result(), and ts::msg::WARN.

ts::config::Configuration::operator detail::PseudoBool::Type (  )  const [inline]

Check if the configuration is valid.

Returns:
The equivalent of true if this does not contain a value, the equivalent of false if it does.

Definition at line 730 of file TsValue.h.

References _table.

bool ts::config::Configuration::operator! (  )  const [inline]

Check if configuration is (not) valid.

Returns:
true if this configuration is invalid, false otherwise.

Definition at line 729 of file TsValue.h.

References _table.

Value ts::config::Configuration::operator[] ( char const *  name  )  const [inline]

Root value child access by name.

Returns:
The child or a Void value if there is no child with name.
Parameters:
name Null terminated string.

Definition at line 736 of file TsValue.h.

References getRoot().

Value ts::config::Configuration::operator[] ( ConstBuffer const &  name  )  const [inline]

Root value child access by name.

Returns:
The child or a Void value if there is no child with name.

Definition at line 735 of file TsValue.h.

References getRoot().

Value ts::config::Configuration::operator[] ( size_t  idx  )  const [inline]

Root value child access by index.

Returns:
The child or a Void value if there is no child with name.
Parameters:
idx Index of child value.

Definition at line 734 of file TsValue.h.

References getRoot().


Friends And Related Function Documentation

friend class Value [friend]

Definition at line 347 of file TsValue.h.

Referenced by getRoot().


Field Documentation


The documentation for this class was generated from the following files: