PWToolBox::Configuration::ConfigurationSection Class Reference

This represents a configuration section in the configuration. More...

#include <ConfigurationSection.h>

List of all members.

Public Types

typedef boost::shared_ptr<
ConfigurationSection
SharedPtr
 A shared pointer to this type.
typedef boost::shared_ptr<
ConfigurationSection const > 
ConstSharedPtr
 A shared pointer to constant data of this type.
typedef std::vector< ConfigurationSetting::SharedPtrSettingList
 A list of pointers to the settings.

Public Member Functions

 ConfigurationSection (std::string const &name)
 Constructs a new ConfigurationSection with the given name.
std::string const & getName () const
ConfigurationSection::SettingList getSetting (std::string const &name) const
 Retrieves a list of settings in this section, or any child section, matching name.
template<typename T>
void setSetting (std::string const &name, T const &value, ConfigurationSetting::AttributeList const &attributes, bool const unique=false)
 Sets a setting named name to value.
template<typename T>
void setSetting (std::string const &name, T const &value, bool const unique=false)
 Sets a setting named name to value.
void setSetting (ConfigurationSetting const &setting, bool const unique=false)
 Sets a setting specified by a ConfigurationSetting.
void addChildSection (ConfigurationSection::SharedPtr const childSection)
 Adds a child section to this section.
ConfigurationSection::SharedPtr getChildSection (std::string const &name)
 Retrieves a child section specified by the given name.
size_t getSettingCount () const
size_t getSettingCount (std::string const &setting) const
 Retrieves the number of settings in this section with the given name.
ConfigurationSetting::AttributeList
const & 
getAttributes () const
ConfigurationSetting::AttributeListgetAttributes ()
void setAttributes (ConfigurationSetting::AttributeList const &newAttributes)
 Sets attributes for this section.


Detailed Description

This represents a configuration section in the configuration.

ConfigurationSections are the "nodes" in the setting hierarchy. The root of every document is a ConfigurationSection, which can contain other ConfigurationSections or ConfigurationSettings.

ConfigurationSections contain a list of settings and attributes associated with the section. They also contain a list of child sections. This allows for complex hierarchies of settings to be created easily.


Member Typedef Documentation

typedef boost::shared_ptr<ConfigurationSection> PWToolBox::Configuration::ConfigurationSection::SharedPtr

A shared pointer to this type.

typedef boost::shared_ptr<ConfigurationSection const> PWToolBox::Configuration::ConfigurationSection::ConstSharedPtr

A shared pointer to constant data of this type.

typedef std::vector<ConfigurationSetting::SharedPtr> PWToolBox::Configuration::ConfigurationSection::SettingList

A list of pointers to the settings.


Constructor & Destructor Documentation

PWToolBox::Configuration::ConfigurationSection::ConfigurationSection ( std::string const &  name  )  [inline]

Constructs a new ConfigurationSection with the given name.

Parameters:
name The name of the section
Exceptions:
InvalidArgumentException Thrown if the section name is empty.


Member Function Documentation

std::string const& PWToolBox::Configuration::ConfigurationSection::getName (  )  const [inline]

Returns:
Returns the name of the section

ConfigurationSection::SettingList PWToolBox::Configuration::ConfigurationSection::getSetting ( std::string const &  name  )  const

Retrieves a list of settings in this section, or any child section, matching name.

This function will take a name and return a list of settings matching that name. If name is in dot notataion (contains '.' characters), it will break the name apart into sections and look for the setting in the appropriate child section. For example, a name of "a.b.c" will look for the setting "c" in section "b", which is a child of section "a", which is a child of this section.

Parameters:
name The name of the settings in to retrieve.
Exceptions:
InvalidArgumentException Thrown if there are no settings by that name
Returns:
Returns a list of the settings with the given name

template<typename T>
void PWToolBox::Configuration::ConfigurationSection::setSetting ( std::string const &  name,
T const &  value,
ConfigurationSetting::AttributeList const &  attributes,
bool const  unique = false 
) [inline]

Sets a setting named name to value.

The name can be specified in dot notation (contains '.' characters). This allows easy inserting settings into sections deep within the heirarchy. If the setting or any of its parents do not exist, they are created.

If unique is specified, any existing settings by that name are removed before inserting the new value.

The value must be convertable to std::string.

Parameters:
name The name of the setting to set
value The value of the setting to set.
attributes The attributes to associate with this setting
unique true if this setting should be unique, false otherwise
Exceptions:
InvalidArgumentException Thrown if name is empty

template<typename T>
void PWToolBox::Configuration::ConfigurationSection::setSetting ( std::string const &  name,
T const &  value,
bool const  unique = false 
) [inline]

Sets a setting named name to value.

See also:
setSetting(std::string const &, T const &, ConfigurationSetting::AttributeList const &, bool const)

void PWToolBox::Configuration::ConfigurationSection::setSetting ( ConfigurationSetting const &  setting,
bool const  unique = false 
)

Sets a setting specified by a ConfigurationSetting.

This allows ConfigurationSettings to be copied into the hierarchy. The implementation of this is an underlying call to another setSetting function, so all the documentation for other setSetting functions applies here.

See also:
setSetting(std::string const &, T const &, ConfigurationSetting::AttributeList const &, bool const)

void PWToolBox::Configuration::ConfigurationSection::addChildSection ( ConfigurationSection::SharedPtr const   childSection  ) 

Adds a child section to this section.

This does not add sections to deeper levels in the hierarchy.

Parameters:
childSection The section to add as a child of this section
Exceptions:
IllegalOperationException Thrown when a child section with the same name already exists in this section

ConfigurationSection::SharedPtr PWToolBox::Configuration::ConfigurationSection::getChildSection ( std::string const &  name  ) 

Retrieves a child section specified by the given name.

The name can be in dot notation to retrieve sections deeper in the hierarchy.

Parameters:
name The name of the section to retrieve
Exceptions:
IllegalOperationException Thrown when a section of that name does not exist.

size_t PWToolBox::Configuration::ConfigurationSection::getSettingCount (  )  const [inline]

Returns:
The number of settings in this section

size_t PWToolBox::Configuration::ConfigurationSection::getSettingCount ( std::string const &  setting  )  const [inline]

Retrieves the number of settings in this section with the given name.

Parameters:
setting The name of the setting to get the count of

ConfigurationSetting::AttributeList const& PWToolBox::Configuration::ConfigurationSection::getAttributes (  )  const [inline]

Returns:
The list of attributes associated with this section.

ConfigurationSetting::AttributeList& PWToolBox::Configuration::ConfigurationSection::getAttributes (  )  [inline]

Returns:
The list of attributes associated with this section.

void PWToolBox::Configuration::ConfigurationSection::setAttributes ( ConfigurationSetting::AttributeList const &  newAttributes  )  [inline]

Sets attributes for this section.

This replaces any previous attributes this section had.

Parameters:
newAttributes The attributes to set for this section


The documentation for this class was generated from the following file:
Generated on Sun Jul 13 14:18:27 2008 for PWToolBox by  doxygen 1.5.1