Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::util::Options Class Reference

Inheritance diagram for ONE::util::Options:

Inheritance graph
[legend]
List of all members.

Detailed Description

manages string to value bindings

Supported option values are

Bindings may be saved to and loaded from XML files.

Note:
Currently, option names must be valid XML element names.
Author:
Daniel Seibert


Public Types

typedef std::map< std::string,
OptionValue
Map

Public Member Functions

void clear ()
OptionValue get (const std::string &key, OptionValue def=0, bool add=false)
 retrieves a value
void load (const std::string &file, bool clear=true)
 loads settings from file
 Options ()
void remove (const std::string &key)
void save (const std::string &file) const
 saves settings to a file
void set (const std::string &key, OptionValue val)
 sets a value
 ~Options ()

Public Attributes

Map options

Classes

class  OptionValue


Member Typedef Documentation

typedef std::map<std::string,OptionValue> ONE::util::Options::Map
 


Constructor & Destructor Documentation

ONE::util::Options::Options  ) 
 

ONE::util::Options::~Options  ) 
 


Member Function Documentation

void ONE::util::Options::clear  ) 
 

OptionValue ONE::util::Options::get const std::string &  key,
OptionValue  def = 0,
bool  add = false
 

retrieves a value

If key is unknown, this function returns def. The returned value is implicitly converted to any of the types listed in the class description above. However, attempting to assign the return value to a different type that it contains will result in an error.

Parameters:
key the desired option
def an optional default value
add if true, adds def to the options table if key is not found

void ONE::util::Options::load const std::string &  file,
bool  clear = true
 

loads settings from file

If clear is true (the default), present settings are cleared before loading.

Exceptions:
IOException if the file cannot be read

void ONE::util::Options::remove const std::string &  key  ) 
 

void ONE::util::Options::save const std::string &  file  )  const
 

saves settings to a file

Exceptions:
IOException if the file cannot be written

void ONE::util::Options::set const std::string &  key,
OptionValue  val
 

sets a value

If key is already present, its value is overwritten. Supported values may be direcly passed to this function; instead of

 set("foo",OptionValue(true)); 
write
 set("foo",true); 


Member Data Documentation

Map ONE::util::Options::options
 


Generated on Wed Sep 7 19:03:32 2005 for ONEngine by  doxygen 1.4.3