Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
orxonox::ConfigFileSection Class Reference

Represents a section in a config file. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/config/ConfigFileSection.h>

Public Member Functions

 ConfigFileSection (const std::string &name, const std::string &additionalComment="")
 Constructor: Initializes the section. More...
 
 ~ConfigFileSection ()
 Destructor: Deletes all entries. More...
 
void deleteVectorEntries (const std::string &name, unsigned int startindex=0)
 Deletes all elements of a config vector if their index is greater or equal to startindex. More...
 
std::string getFileEntry () const
 Returns the title and comment of the section as it will be stored in the file. More...
 
const std::string & getName () const
 Returns the name of the section. More...
 
const std::string & getOrCreateValue (const std::string &name, const std::string &fallback, bool bString)
 Returns the value of a given entry in the section. More...
 
const std::string & getOrCreateValue (const std::string &name, unsigned int index, const std::string &fallback, bool bString)
 Returns the value of a given element of a vector in the section. More...
 
const std::string & getValue (const std::string &name, bool bString)
 Returns the value of a given entry in the section. More...
 
const std::string & getValue (const std::string &name, unsigned int index, bool bString)
 Returns the value of a given element of a vector in the section. More...
 
unsigned int getVectorSize (const std::string &name) const
 Returns the size of a config vector. More...
 
void setComment (const std::string &comment)
 Changes the comment which is placed after the title of the section in the config file. More...
 
void setValue (const std::string &name, const std::string &value, bool bString)
 Stores a value in the section. More...
 
void setValue (const std::string &name, unsigned int index, const std::string &value, bool bString)
 Stores the value of an element of a vector in the section. More...
 

Private Member Functions

std::list< ConfigFileEntry * > & getEntries ()
 Returns the list of entries in this section. More...
 
const std::list< ConfigFileEntry * > & getEntries () const
 
ConfigFileEntrygetEntry (const std::string &name) const
 Returns the entry with given name (or nullptr if it doesn't exist). More...
 
ConfigFileEntrygetEntry (const std::string &name, unsigned int index) const
 Returns the entry of a vector element with given name and index (or nullptr if it doesn't exist). More...
 
ConfigFileEntrygetOrCreateEntry (const std::string &name, const std::string &fallback, bool bString)
 Returns the entry with given name. More...
 
ConfigFileEntrygetOrCreateEntry (const std::string &name, unsigned int index, const std::string &fallback, bool bString)
 Returns the entry that contains an element of a vector with given name. More...
 
std::list< ConfigFileEntry * >::iterator getOrCreateEntryIterator (const std::string &name, const std::string &fallback, bool bString)
 Returns the iterator to the entry with given name. More...
 
std::list< ConfigFileEntry * >::iterator getOrCreateEntryIterator (const std::string &name, unsigned int index, const std::string &fallback, bool bString)
 Returns the iterator to the entry of a vector element with given name and index. More...
 

Private Attributes

std::string additionalComment_
 The additional comment which is placed after the title of the section in the config file. More...
 
bool bUpdated_
 True if an entry is created. More...
 
std::list< ConfigFileEntry * > entries_
 The list of entries in this section. More...
 
std::string name_
 The name of the section. More...
 

Friends

class ConfigFile
 
class SettingsConfigFile
 

Detailed Description

Represents a section in a config file.

A section has a name and a list of config values.

Constructor & Destructor Documentation

orxonox::ConfigFileSection::ConfigFileSection ( const std::string &  name,
const std::string &  additionalComment = "" 
)
inline

Constructor: Initializes the section.

Parameters
nameThe name of the section
additionalCommentAn additional comment placed after the title of the section in the config file
orxonox::ConfigFileSection::~ConfigFileSection ( )

Destructor: Deletes all entries.

Member Function Documentation

void orxonox::ConfigFileSection::deleteVectorEntries ( const std::string &  name,
unsigned int  startindex = 0 
)

Deletes all elements of a config vector if their index is greater or equal to startindex.

Parameters
nameThe name of the vector
startindexThe index of the first element that will be deleted
std::list<ConfigFileEntry*>& orxonox::ConfigFileSection::getEntries ( )
inlineprivate

Returns the list of entries in this section.

const std::list<ConfigFileEntry*>& orxonox::ConfigFileSection::getEntries ( ) const
inlineprivate
ConfigFileEntry * orxonox::ConfigFileSection::getEntry ( const std::string &  name) const
private

Returns the entry with given name (or nullptr if it doesn't exist).

Parameters
nameThe name of the entry
ConfigFileEntry * orxonox::ConfigFileSection::getEntry ( const std::string &  name,
unsigned int  index 
) const
private

Returns the entry of a vector element with given name and index (or nullptr if it doesn't exist).

Parameters
nameThe name of the vector
indexThe index of the element in the vector
std::string orxonox::ConfigFileSection::getFileEntry ( ) const

Returns the title and comment of the section as it will be stored in the file.

const std::string& orxonox::ConfigFileSection::getName ( void  ) const
inline

Returns the name of the section.

ConfigFileEntry* orxonox::ConfigFileSection::getOrCreateEntry ( const std::string &  name,
const std::string &  fallback,
bool  bString 
)
inlineprivate

Returns the entry with given name.

If it doesn't exist, the entry is created using the fallback value.

Parameters
nameThe name of the entry
fallbackThe value that will be used if the entry doesn't exist
bStringIf true, the value is treated as string which means some special treatment of special characters.
ConfigFileEntry* orxonox::ConfigFileSection::getOrCreateEntry ( const std::string &  name,
unsigned int  index,
const std::string &  fallback,
bool  bString 
)
inlineprivate

Returns the entry that contains an element of a vector with given name.

If it doesn't exist, the entry is created using the fallback value.

Parameters
nameThe name of the entry
indexThe index of the element in the vector
fallbackThe value that will be used if the entry doesn't exist
bStringIf true, the value is treated as string which means some special treatment of special characters.
std::list< ConfigFileEntry * >::iterator orxonox::ConfigFileSection::getOrCreateEntryIterator ( const std::string &  name,
const std::string &  fallback,
bool  bString 
)
private

Returns the iterator to the entry with given name.

If the entry doesn't exist, it is created using the fallback value.

Parameters
nameThe name of the entry
fallbackThe value that will be used if the entry doesn't exist
bStringIf true, the value is treated as string which means some special treatment of special characters.
std::list< ConfigFileEntry * >::iterator orxonox::ConfigFileSection::getOrCreateEntryIterator ( const std::string &  name,
unsigned int  index,
const std::string &  fallback,
bool  bString 
)
private

Returns the iterator to the entry of a vector element with given name and index.

If the entry doesn't exist, it is created using the fallback value.

Parameters
nameThe name of the vector
indexThe index of the element in the vector
fallbackThe value that will be used if the entry doesn't exist
bStringIf true, the value is treated as string which means some special treatment of special characters.
const std::string& orxonox::ConfigFileSection::getOrCreateValue ( const std::string &  name,
const std::string &  fallback,
bool  bString 
)
inline

Returns the value of a given entry in the section.

If it doesn't exist, the entry is created using the fallback value.

Parameters
nameThe name of the entry
fallbackThe value that will be used if the entry doesn't exist
bStringIf true, the value is treated as string which means some special treatment of special characters.
const std::string& orxonox::ConfigFileSection::getOrCreateValue ( const std::string &  name,
unsigned int  index,
const std::string &  fallback,
bool  bString 
)
inline

Returns the value of a given element of a vector in the section.

If it doesn't exist, the entry is created using the fallback value.

Parameters
nameThe name of the vector
indexThe index of the element in the vector
fallbackThe value that will be used if the entry doesn't exist
bStringIf true, the value is treated as string which means some special treatment of special characters.
const std::string& orxonox::ConfigFileSection::getValue ( const std::string &  name,
bool  bString 
)
inline

Returns the value of a given entry in the section.

Returns a blank string if the value doesn't exist.

Parameters
nameThe name of the entry
bStringIf true, the value is treated as string which means some special treatment of special characters.
const std::string& orxonox::ConfigFileSection::getValue ( const std::string &  name,
unsigned int  index,
bool  bString 
)
inline

Returns the value of a given element of a vector in the section.

Returns a blank string if the value doesn't exist.

Parameters
nameThe name of the vector
indexThe index of the element in the vector
bStringIf true, the value is treated as string which means some special treatment of special characters.
unsigned int orxonox::ConfigFileSection::getVectorSize ( const std::string &  name) const

Returns the size of a config vector.

Parameters
nameThe name of the vector
void orxonox::ConfigFileSection::setComment ( const std::string &  comment)
inline

Changes the comment which is placed after the title of the section in the config file.

void orxonox::ConfigFileSection::setValue ( const std::string &  name,
const std::string &  value,
bool  bString 
)
inline

Stores a value in the section.

If the entry doesn't exist, it's created.

Parameters
nameThe name of the entry
valueThe new value
bStringIf true, the value is treated as string which means some special treatment of special characters.
void orxonox::ConfigFileSection::setValue ( const std::string &  name,
unsigned int  index,
const std::string &  value,
bool  bString 
)
inline

Stores the value of an element of a vector in the section.

If the entry doesn't exist, it's created.

Parameters
nameThe name of the vector
indexThe index of the element in the vector
valueThe new value
bStringIf true, the value is treated as string which means some special treatment of special characters.

Friends And Related Function Documentation

friend class ConfigFile
friend
friend class SettingsConfigFile
friend

Member Data Documentation

std::string orxonox::ConfigFileSection::additionalComment_
private

The additional comment which is placed after the title of the section in the config file.

bool orxonox::ConfigFileSection::bUpdated_
private

True if an entry is created.

std::list<ConfigFileEntry*> orxonox::ConfigFileSection::entries_
private

The list of entries in this section.

std::string orxonox::ConfigFileSection::name_
private

The name of the section.


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