Planeshift
Public Member Functions

optionEntry Class Reference

This class rappresents an option tree which comes from the server_options table. More...

#include <cachemanager.h>

List of all members.

Public Member Functions

optionEntrygetOption (const csString path)
 Gets an option entry in the tree.
optionEntrygetOptionSafe (const csString path, const csString fallback)
 Does the same of getOption, but, in case the entry is missing, an empty option will be added to the tree.
csString getValue ()
 Get the value of this specific option.
double getValueAsDouble ()
 Get the value of this specific option in double format.
int getValueAsInt ()
 Get the value of this specific option in int format.
csVector3 getValueAsVector ()
 Get the value of this specific option in csVector3 format.
bool getValueAsVector (csVector3 &vector)
 Get the value of this specific option in csVector3 format.
bool setOption (const csString path, const csString value)
 Sets an option in the option tree.
void setValue (const csString newValue)
 Sets the value of this specific option to a newvalue.

Detailed Description

This class rappresents an option tree which comes from the server_options table.

You can iterate the tree starting from the root or get a leaf and start search from there: useful if a specific class/manager wants to keep only the reference to the options it needs in place of iterating the entire tree each time. All the entries in the tree are the same, so you can assign and get a value to/from any. Right now : is used as path delimiter.

Definition at line 147 of file cachemanager.h.


Member Function Documentation

optionEntry* optionEntry::getOption ( const csString  path)

Gets an option entry in the tree.

It doesn't have to be the actual option we want a value from but also a folder containing the set of options we are interested for. This is useful to allow managers to keep their reference to a specific part of the tree and so avoid going through all the branches to reach what they are interested each time.

Parameters:
pathA path to the optionEntry we are interested in.
Returns:
A pointer to the optionEntry we are interested in. NULL if the optionEntry was not found.
optionEntry* optionEntry::getOptionSafe ( const csString  path,
const csString  fallback 
)

Does the same of getOption, but, in case the entry is missing, an empty option will be added to the tree.

Parameters:
pathA path to the optionEntry we are interested in.
fallbackA value to associate to the option in case it was not found.
Returns:
A pointer to the optionEntry we are interested in. It still returns NULL if the data is invalid, but that's a programming error and not a runtime error.
csString optionEntry::getValue ( ) [inline]

Get the value of this specific option.

Returns:
A csString containing the option value.

Definition at line 164 of file cachemanager.h.

double optionEntry::getValueAsDouble ( ) [inline]

Get the value of this specific option in double format.

Returns:
A double containing the option value converted to double.

Definition at line 171 of file cachemanager.h.

int optionEntry::getValueAsInt ( ) [inline]

Get the value of this specific option in int format.

Returns:
An int containing the option value converted to int.

Definition at line 178 of file cachemanager.h.

csVector3 optionEntry::getValueAsVector ( )

Get the value of this specific option in csVector3 format.

This function takes in account the format is x,y,z as text, returns a vector with 0,0,0 in case of error.

Returns:
A csVector3 containing the option value converted to a csvector.
bool optionEntry::getValueAsVector ( csVector3 &  vector)

Get the value of this specific option in csVector3 format.

This function takes in account the format is x,y,z as text, this version allows to check if there was a conversion error.

Parameters:
vectorA reference to a vector where the value will be stored.
Returns:
A boolean TRUE if the conversion was successfull.
bool optionEntry::setOption ( const csString  path,
const csString  value 
)

Sets an option in the option tree.

Note:
for now there is no support for db saving so this is only temporary.
If the value was never set the return will be an empty csString (internal string not initialized see crystal space documentation)
Parameters:
pathA path relative to this optionEntry. It's the full path only when using the "root" optionEntry.
valueThe value to set to the option we are adding to the tree.
void optionEntry::setValue ( const csString  newValue) [inline]

Sets the value of this specific option to a newvalue.

Note:
for now there is no support for db saving so this is only temporary.
Parameters:
newValueThe new string to assign to this option

Definition at line 157 of file cachemanager.h.


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