#include <options.h>
Inheritance diagram for Options:
Public Member Functions | |
Constructors and Destructors | |
Options () throw () | |
Default constructor. | |
Options (const Options &options) throw () | |
Copy constructor. | |
virtual | ~Options () throw () |
Destructor. | |
Assignment | |
const Options & | operator= (const Options &options) throw () |
Assignment operator. | |
virtual void | clear () throw () |
Clear method. | |
Predicates | |
bool | isInteger (const String &key) const throw () |
Returns true, if the value associated with the given key is an integer. | |
bool | isBool (const String &key) const throw () |
Returns true, if the value associated with the given key is a boolean. | |
bool | isReal (const String &key) const throw () |
Returns true, if the value associated with the given key is a real number. | |
bool | isVector (const String &key) const throw () |
Returns true, if the value associated with the given key can be read as a vector. | |
bool | isSet (const String &key) const throw () |
Returns true, if a value is defined for the given key. | |
Inspectors and mutators | |
void | setName (const String &name) throw () |
Sets the option table's name. | |
const String & | getName () const throw () |
Returns the option table's name. | |
String | get (const String &key) const throw () |
Returns the value associated with the key. | |
bool | getBool (const String &key) const throw () |
Returns the value associated with the key as bool. | |
double | getReal (const String &key) const throw () |
Returns the value associated with the key as a floting point number. | |
Vector3 | getVector (const String &key) const throw () |
Returns the value associated with the key as a Vector3 object. | |
long | getInteger (const String &key) const throw () |
Returns the value associated with the key as an integer. | |
void | set (const String &key, const String &value) throw () |
Assigns value to key. | |
void | setReal (const String &key, const double value) throw () |
Assigns the real number given by value to key. | |
void | setVector (const String &key, const Vector3 &value) throw () |
Assigns a Vector3 object to the value corresponding to a key. | |
void | setInteger (const String &key, const long value) throw () |
Assigns the integer given by value to key. | |
void | setBool (const String &key, const bool value) throw () |
Assigns the boolean value given by value to the table entry key. | |
String | setDefault (const String &key, const String &value) throw () |
Assigns the value only, if the key is not yet defined. | |
long | setDefaultInteger (const String &key, const long value) throw () |
Assigns the value only, if the key is not yet defined. | |
double | setDefaultReal (const String &key, const double value) throw () |
Assigns the value only, if the key is not yet defined. | |
bool | setDefaultBool (const String &key, const bool value) throw () |
Assigns the value only if the key is not yet defined. | |
bool | readOptionFile (const String &filename) throw () |
Reads options from a file. | |
bool | writeOptionFile (const String &filename) const throw () |
Writes options to a file. | |
void | write (PersistenceManager &pm) const throw () |
Persistent stream writing. | |
bool | read (PersistenceManager &pm) throw () |
Persistent stream reading. | |
bool | operator== (const Options &option) const throw () |
Equality operator. | |
bool | operator!= (const Options &option) const throw () |
Inequality operator. | |
Debugging | |
virtual void | dump (std::ostream &s=std::cout, Size depth=0) const throw () |
Dumps the whole content of the object. | |
Static Public Attributes | |
Constants | |
const Size | MAX_ENTRY_LENGTH |
Maximum length for each entry (key + value): 1024 byte. | |
Protected Attributes | |
String | name_ |
This object is intended to store options for complex method calls. These options are stored as key/value pairs of String .
|
Default constructor. Creates a new and empty Options object. |
|
Copy constructor. Creates a new option table from an existing one.
|
|
Destructor. Destructs the option table and frees all allocated memory.
|
|
Returns the value associated with the key. If the key does not exists an empty string is returned.
|
|
Returns the value associated with the key as bool. This method tries to convert the value associated with key to a bool value.
|
|
Returns the value associated with the key as an integer. If the value corresponding to key could not be converted to an integer number or the key does not exists, zero is returned. It is possible to check for the validity of this conversion by calling isInteger() .
|
|
Returns the option table's name.
|
|
Returns the value associated with the key as a floting point number. If the value could not be converted to a floating point number or the key does not exist a value of #0.0# is returned.
|
|
Returns the value associated with the key as a Vector3 object. This method is useful to read threedimensional coordinates, points, etc. The value corresponding to key has to be of the form #(<float> <float> <float>)# (i.e. three floating point numbers separated by white blanks and surrounded by round brackets).
|
|
Returns true, if the value associated with the given key is a boolean.
A boolean entry has either the value
|
|
Returns true, if the value associated with the given key is an integer.
|
|
Returns true, if the value associated with the given key is a real number.
|
|
Returns true, if a value is defined for the given key.
|
|
Returns true, if the value associated with the given key can be read as a vector. This method simply checks whether the value is of the form #(<float> <float> <float>)# where #<float># represents an arbitrary floating point number.
|
|
Persistent stream reading.
This method reads from the persistent stream using the
|
|
Reads options from a file. This method opens the file specified by filename. If the file could not be opened, the method returns false. Otherwise, the file is read line by line and each line is interpreted as a key (starting with the first non-blank character and terminated by the next blank) separated by a blank from a value (starting with the first non-blank charakter after the key and terminated by the end of the line). For each line either an existing key is updated with the value read, or a new key-value pair is created.
|
|
Assigns value to key. The string given as value is assigned to the key. If key didn't exist in the internal hash table, it is inserted.
|
|
Assigns the boolean value given by value to the table entry key. The value associated with key is either set to the string "true" or the string "false".
|
|
Assigns the value only, if the key is not yet defined. If an entry for key exists, it is not modified. It is set to value otherwise.
|
|
Assigns the value only if the key is not yet defined. If an entry for key exists, it is not modified. It is set to value otherwise.
|
|
Assigns the value only, if the key is not yet defined. If an entry for key exists, it is not modified. It is set to value otherwise.
|
|
Assigns the value only, if the key is not yet defined. If an entry for key exists, it is not modified. It is set to value otherwise.
|
|
Assigns the integer given by value to key. value is first converted to a string, which is then stored in the hash table under key.
|
|
Sets the option table's name.
|
|
Assigns the real number given by value to key. value is first converted to a string, which is then stored in the option object.
|
|
Assigns a Vector3 object to the value corresponding to a key. The given Vector3 is converted to a string by the following call to sprintf:
|
|
Persistent stream writing.
This method writes the strings using the
|
|
Writes options to a file. This method opens or creates the file specified by filename. If the file could not be opened, the method returns false. The option table's name is writen in a line starting with '!'.
|
|
Maximum length for each entry (key + value): 1024 byte.
|