AllegroPlus
 All Classes Functions Variables Pages
Public Member Functions | List of all members
Allegro::ConfigPlus Class Reference

Wrapper for ALLEGRO_CONFIG More...

#include <ConfigPlus.h>

Public Member Functions

 ConfigPlus (bool createEmpty=false)
 Constructor.
 ConfigPlus (const char *filename)
 Constructor.
 ConfigPlus (const std::string &filename)
 Constructor.
 ~ConfigPlus ()
 Destructor.
void Empty ()
 Resets to an empty configuration file
void Load (const char *filename)
 Loads a configuration from the specified filename.
void Load (const std::string &filename)
 Loads a configuration from the specified filename.
void Load (ALLEGRO_FILE *file)
 Loads a configuration from an allegro file.
void Save (const char *filename) const
 Saves the configuration to the specified filename.
void Save (const std::string &filename) const
 Saves the configuration to the specified filename.
void Save (ALLEGRO_FILE *file) const
 Saves the configuration to the specified filename.
void AddSection (const char *name)
 Adds a section to the configuration.
void AddSection (const std::string &name)
 Adds a section to the configuration.
void AddComment (const char *section, const char *comment)
 Adds a comment to the specified section.
void AddComment (const std::string &section, const std::string &comment)
 Adds a comment to the specified section.
const char * GetValueDirect (const char *section, const char *key) const
 Gets a value directly from the allegro config. Will have to convert the value if non-string type is desired.
void SetValueDirect (const char *section, const char *key, const char *value)
 Sets a value to the allegro config. Will have to convert the value to string if non-string type.
void MergeConfig (const ConfigPlus &with, ConfigPlus &to) const
 Merges this configuation and the passed configuration into the specified configuration.
void MergeConfigInto (const ConfigPlus &with)
 Merges the passed configuration into this configuration.
template<typename T >
GetValue (const char *section, const char *key) const
 Gets a value from the allegro config. This will handle converting to the desired type.
template<typename T >
GetValue (const std::string &section, const std::string &key) const
 Gets a value from the allegro config. This will handle converting to the desired type.
template<typename T >
void SetValue (const char *section, const char *key, const T &value)
 Sets a value to the allegro config. This will handle converting to the desired type.
template<typename T >
void SetValue (const std::string &section, const std::string &key, const T &value)
 Sets a value to the allegro config. This will handle converting to the desired type.

Detailed Description

Wrapper for ALLEGRO_CONFIG

Constructor & Destructor Documentation

Allegro::ConfigPlus::ConfigPlus ( bool  createEmpty = false)

Constructor.

Parameters
createEmptytrue: create an empty/blank configuration file, false: don't create
Allegro::ConfigPlus::ConfigPlus ( const char *  filename)

Constructor.

Parameters
filenameThe filename to load.
Allegro::ConfigPlus::ConfigPlus ( const std::string &  filename)

Constructor.

Parameters
filenameThe filename to load.
Allegro::ConfigPlus::~ConfigPlus ( )

Destructor.

Member Function Documentation

void Allegro::ConfigPlus::AddComment ( const char *  section,
const char *  comment 
)

Adds a comment to the specified section.

Parameters
sectionThe section.
commentThe comment.
void Allegro::ConfigPlus::AddComment ( const std::string &  section,
const std::string &  comment 
)

Adds a comment to the specified section.

Parameters
sectionThe section.
commentThe comment.
void Allegro::ConfigPlus::AddSection ( const char *  name)

Adds a section to the configuration.

Parameters
nameThe name of the section.
void Allegro::ConfigPlus::AddSection ( const std::string &  name)

Adds a section to the configuration.

Parameters
nameThe name of the section.
void Allegro::ConfigPlus::Empty ( )

Resets to an empty configuration file

template<typename T >
T Allegro::ConfigPlus::GetValue ( const char *  section,
const char *  key 
) const
inline

Gets a value from the allegro config. This will handle converting to the desired type.

Parameters
sectionThe section.
keyThe key.
Returns
The value from the config
template<typename T >
T Allegro::ConfigPlus::GetValue ( const std::string &  section,
const std::string &  key 
) const
inline

Gets a value from the allegro config. This will handle converting to the desired type.

Parameters
sectionThe section.
keyThe key.
Returns
The value from the config
const char * Allegro::ConfigPlus::GetValueDirect ( const char *  section,
const char *  key 
) const

Gets a value directly from the allegro config. Will have to convert the value if non-string type is desired.

Parameters
sectionThe section.
keyThe key.
Returns
null if it fails, else the value.

See GetValue<T> for retriving values direct to type

void Allegro::ConfigPlus::Load ( const char *  filename)

Loads a configuration from the specified filename.

Parameters
filenameThe filename to load.
void Allegro::ConfigPlus::Load ( const std::string &  filename)

Loads a configuration from the specified filename.

Parameters
filenameThe filename to load.
void Allegro::ConfigPlus::Load ( ALLEGRO_FILE *  file)

Loads a configuration from an allegro file.

Parameters
fileIf non-null, the file to load.
void Allegro::ConfigPlus::MergeConfig ( const ConfigPlus with,
ConfigPlus to 
) const

Merges this configuation and the passed configuration into the specified configuration.

Parameters
withThe configuration to merge this one with.
toThe destination configuration to combine them into.
void Allegro::ConfigPlus::MergeConfigInto ( const ConfigPlus with)

Merges the passed configuration into this configuration.

Parameters
withThe configuration to merge this configuration with.
void Allegro::ConfigPlus::Save ( const char *  filename) const

Saves the configuration to the specified filename.

Parameters
filenameThe filename to save to.
void Allegro::ConfigPlus::Save ( const std::string &  filename) const

Saves the configuration to the specified filename.

Parameters
filenameThe filename to save to.
void Allegro::ConfigPlus::Save ( ALLEGRO_FILE *  file) const

Saves the configuration to the specified filename.

Parameters
fileIf non-null, the allegro file to save to.
template<typename T >
void Allegro::ConfigPlus::SetValue ( const char *  section,
const char *  key,
const T &  value 
)
inline

Sets a value to the allegro config. This will handle converting to the desired type.

Parameters
sectionThe section.
keyThe key.
Returns
The value from the config
template<typename T >
void Allegro::ConfigPlus::SetValue ( const std::string &  section,
const std::string &  key,
const T &  value 
)
inline

Sets a value to the allegro config. This will handle converting to the desired type.

Parameters
sectionThe section.
keyThe key.
Returns
The value from the config
void Allegro::ConfigPlus::SetValueDirect ( const char *  section,
const char *  key,
const char *  value 
)

Sets a value to the allegro config. Will have to convert the value to string if non-string type.

Parameters
sectionThe section.
keyThe key.

See SetValue<T> for setting values direct from type