Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

PreferenceValue Class Reference

Encapsulates a preference value. More...

#include <appprefs.hpp>

Collaboration diagram for PreferenceValue:

Collaboration graph
[legend]
List of all members.

Public Member Functions

bool get (wxSize &value) const
 Gets a wxSize value.

bool get (wxPoint &value) const
 Gets a wxPoint value.

bool get (wxRect &value) const
 Gets a wxRect value.

bool get (bool &value) const
 Gets a boolean value.

bool get (double &value) const
 Gets a double value.

bool get (wxString &value) const
 Gets a string value.

bool get (long &value) const
 Gets a long integer value.

wxString getConfigKey () const
 Gets the key of the preference in the configuration file.

PreferenceValueoperator= (const PreferenceValue &source)
 Assignment operator.

 PreferenceValue (const PreferenceValue &source)
 Copy constructor.

 PreferenceValue (const wxSize &value, const wxString &cfgKey=wxEmptyString, const bool initFromCfgFile=true)
 Constructor with a wxSize type.

 PreferenceValue (const wxPoint &value, const wxString &cfgKey=wxEmptyString, const bool initFromCfgFile=true)
 Constructor with a wxPoint type.

 PreferenceValue (const wxRect &value, const wxString &cfgKey=wxEmptyString, const bool initFromCfgFile=true)
 Constructor with a wxRect type.

 PreferenceValue (const bool value, const wxString &cfgKey=wxEmptyString, const bool initFromCfgFile=true)
 Constructor with a boolean type.

 PreferenceValue (const double value, const wxString &cfgKey=wxEmptyString, const bool initFromCfgFile=true)
 Constructor with a double type.

 PreferenceValue (const wxString &value, const wxString &cfgKey=wxEmptyString, const bool initFromCfgFile=true)
 Constructor with a string type.

 PreferenceValue (const long value, const wxString &cfgKey=wxEmptyString, const bool initFromCfgFile=true)
 Constructor with a long integer type.

 PreferenceValue ()
 Default constructor.

bool set (const wxSize &newValue)
 Sets a wxSize value.

bool set (const wxPoint &newValue)
 Sets a wxPoint value.

bool set (const wxRect &newValue)
 Sets a wxRect value.

bool set (const bool newValue)
 Sets a boolean value.

bool set (const double newValue)
 Sets a string value.

bool set (const wxString &newValue)
 Sets a string value.

bool set (const long newValue)
 Sets a long integer value.

 ~PreferenceValue ()
 Destructor.


Static Public Member Functions

wxSize read (const wxString &key, const wxSize &def, wxConfigBase *cfg=NULL)
 Reads a wxSize value from the configuration file.

bool read (const wxString &key, wxSize *r, wxConfigBase *cfg=NULL)
 Reads a wxSize value from the configuration file.

wxPoint read (const wxString &key, const wxPoint &def, wxConfigBase *cfg=NULL)
 Reads a wxPoint value from the configuration file.

bool read (const wxString &key, wxPoint *r, wxConfigBase *cfg=NULL)
 Reads a wxPoint value from the configuration file.

wxRect read (const wxString &key, const wxRect &def, wxConfigBase *cfg=NULL)
 Reads a wxRect value from the configuration file.

bool read (const wxString &key, wxRect *r, wxConfigBase *cfg=NULL)
 Reads a wxRect value from the configuration file.


Protected Types

enum  PreferenceType {
  ptNotDefined = 0, ptLong, ptString, ptDouble,
  ptBoolean, ptRect, ptSize, ptPoint
}
 Type of the preference value. More...


Protected Member Functions

void cleanup ()
 Cleans up the memory.

void clone (const PreferenceValue &source)
 Clones the source instance in this instance.


Protected Attributes

wxString _cfgKey
 Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.

value_t _value
 Value of the preference.

PreferenceType _valueType
 Type of the preference.


Detailed Description

Encapsulates a preference value.

A preference value has a type and can have a corresponding key in the global configuration file (see wxConfig::Get() in the wxWidgets documentation).

The type of the preference is fixed at the construction of the instance and can't be changed. The type is always checked when the value is set or gotten.

If a key is specified:

The static read methods provide facility for reading the complex types that are handled by this class (such as wxRect for example).

Definition at line 68 of file appprefs.hpp.


Member Enumeration Documentation

enum PreferenceValue::PreferenceType [protected]
 

Type of the preference value.

Definition at line 72 of file appprefs.hpp.


Constructor & Destructor Documentation

PreferenceValue::PreferenceValue  ) 
 

Default constructor.

Definition at line 89 of file appprefs.cpp.

References _value, _valueType, and PreferenceValue::value_t::valLong.

PreferenceValue::PreferenceValue const long  value,
const wxString &  cfgKey = wxEmptyString,
const bool  initFromCfgFile = true
 

Constructor with a long integer type.

Parameters:
value The value of long integer type.
cfgKey Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.
initFromCfgFile If true and if a key was given, tries first to initialize the value from the configuration file.

Definition at line 181 of file appprefs.cpp.

References _cfgKey, _value, _valueType, and PreferenceValue::value_t::valLong.

PreferenceValue::PreferenceValue const wxString &  value,
const wxString &  cfgKey = wxEmptyString,
const bool  initFromCfgFile = true
 

Constructor with a string type.

Parameters:
value The value of string type.
cfgKey Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.
initFromCfgFile If true and if a key was given, tries first to initialize the value from the configuration file.

Definition at line 202 of file appprefs.cpp.

References _cfgKey, _value, _valueType, and PreferenceValue::value_t::valString.

PreferenceValue::PreferenceValue const double  value,
const wxString &  cfgKey = wxEmptyString,
const bool  initFromCfgFile = true
 

Constructor with a double type.

Parameters:
value The value of double type.
cfgKey Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.
initFromCfgFile If true and if a key was given, tries first to initialize the value from the configuration file.

Definition at line 223 of file appprefs.cpp.

References _cfgKey, _value, _valueType, and PreferenceValue::value_t::valDouble.

PreferenceValue::PreferenceValue const bool  value,
const wxString &  cfgKey = wxEmptyString,
const bool  initFromCfgFile = true
 

Constructor with a boolean type.

Parameters:
value The value of boolean type.
cfgKey Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.
initFromCfgFile If true and if a key was given, tries first to initialize the value from the configuration file.

Definition at line 244 of file appprefs.cpp.

References _cfgKey, _value, _valueType, and PreferenceValue::value_t::valBool.

PreferenceValue::PreferenceValue const wxRect &  value,
const wxString &  cfgKey = wxEmptyString,
const bool  initFromCfgFile = true
 

Constructor with a wxRect type.

Parameters:
value The value of wxRect type.
cfgKey Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.
initFromCfgFile If true and if a key was given, tries first to initialize the value from the configuration file.

Definition at line 265 of file appprefs.cpp.

References _cfgKey, _value, _valueType, read(), and PreferenceValue::value_t::valRect.

PreferenceValue::PreferenceValue const wxPoint &  value,
const wxString &  cfgKey = wxEmptyString,
const bool  initFromCfgFile = true
 

Constructor with a wxPoint type.

Parameters:
value The value of wxPoint type.
cfgKey Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.
initFromCfgFile If true and if a key was given, tries first to initialize the value from the configuration file.

Definition at line 286 of file appprefs.cpp.

References _cfgKey, _value, _valueType, read(), and PreferenceValue::value_t::valPoint.

PreferenceValue::PreferenceValue const wxSize &  value,
const wxString &  cfgKey = wxEmptyString,
const bool  initFromCfgFile = true
 

Constructor with a wxSize type.

Parameters:
value The value of wxSize type.
cfgKey Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.
initFromCfgFile If true and if a key was given, tries first to initialize the value from the configuration file.

Definition at line 307 of file appprefs.cpp.

References _cfgKey, _value, _valueType, read(), and PreferenceValue::value_t::valSize.

PreferenceValue::PreferenceValue const PreferenceValue source  ) 
 

Copy constructor.

Parameters:
source Source instance.

Definition at line 148 of file appprefs.cpp.

References _value, _valueType, clone(), and PreferenceValue::value_t::valLong.

PreferenceValue::~PreferenceValue  ) 
 

Destructor.

Definition at line 322 of file appprefs.cpp.

References cleanup().


Member Function Documentation

void PreferenceValue::cleanup  )  [protected]
 

Cleans up the memory.

Definition at line 332 of file appprefs.cpp.

References _value, _valueType, PreferenceValue::value_t::valBool, PreferenceValue::value_t::valDouble, PreferenceValue::value_t::valLong, PreferenceValue::value_t::valPoint, PreferenceValue::value_t::valRect, PreferenceValue::value_t::valSize, and PreferenceValue::value_t::valString.

Referenced by clone(), and ~PreferenceValue().

void PreferenceValue::clone const PreferenceValue source  )  [protected]
 

Clones the source instance in this instance.

Parameters:
source Source instance.

Definition at line 102 of file appprefs.cpp.

References _cfgKey, _value, _valueType, cleanup(), clone(), PreferenceValue::value_t::valBool, PreferenceValue::value_t::valDouble, PreferenceValue::value_t::valLong, PreferenceValue::value_t::valPoint, PreferenceValue::value_t::valRect, PreferenceValue::value_t::valSize, and PreferenceValue::value_t::valString.

Referenced by clone(), operator=(), and PreferenceValue().

bool PreferenceValue::get wxSize &  value  )  const
 

Gets a wxSize value.

Parameters:
value A wxSize instance where the preference value will be stored.
Returns:
true if the preference value is a wxSize, false otherwise.

Definition at line 680 of file appprefs.cpp.

References _value, _valueType, get(), and PreferenceValue::value_t::valSize.

bool PreferenceValue::get wxPoint &  value  )  const
 

Gets a wxPoint value.

Parameters:
value A wxPoint instance where the preference value will be stored.
Returns:
true if the preference value is a wxPoint, false otherwise.

Definition at line 628 of file appprefs.cpp.

References _value, _valueType, get(), and PreferenceValue::value_t::valPoint.

bool PreferenceValue::get wxRect &  value  )  const
 

Gets a wxRect value.

Parameters:
value A wxRect instance where the preference value will be stored.
Returns:
true if the preference value is a wxRect, false otherwise.

Definition at line 575 of file appprefs.cpp.

References _value, _valueType, get(), and PreferenceValue::value_t::valRect.

bool PreferenceValue::get bool &  value  )  const
 

Gets a boolean value.

Parameters:
value A boolean where the preference value will be stored.
Returns:
true if the preference value is a boolean, false otherwise.

Definition at line 527 of file appprefs.cpp.

References _value, _valueType, get(), and PreferenceValue::value_t::valBool.

bool PreferenceValue::get double &  value  )  const
 

Gets a double value.

Parameters:
value A double where the preference value will be stored.
Returns:
true if the preference value is a double, false otherwise.

Definition at line 479 of file appprefs.cpp.

References _value, _valueType, get(), and PreferenceValue::value_t::valDouble.

bool PreferenceValue::get wxString &  value  )  const
 

Gets a string value.

Parameters:
value A string where the preference value will be stored.
Returns:
true if the preference value is a string, false otherwise.

Definition at line 431 of file appprefs.cpp.

References _value, _valueType, get(), and PreferenceValue::value_t::valString.

bool PreferenceValue::get long &  value  )  const
 

Gets a long integer value.

Parameters:
value A long integer where the preference value will be stored.
Returns:
true if the preference value is an long integer, false otherwise.

Definition at line 383 of file appprefs.cpp.

References _value, _valueType, get(), and PreferenceValue::value_t::valLong.

Referenced by get().

wxString PreferenceValue::getConfigKey  )  const
 

Gets the key of the preference in the configuration file.

Returns:
The key of the preference in the configuration file or an empty string if there is no key.

Definition at line 369 of file appprefs.cpp.

References _cfgKey.

PreferenceValue & PreferenceValue::operator= const PreferenceValue source  ) 
 

Assignment operator.

Parameters:
source Source instance.
Returns:
A reference on the instance.

Definition at line 163 of file appprefs.cpp.

References clone(), and operator=().

Referenced by operator=().

wxSize PreferenceValue::read const wxString &  key,
const wxSize &  def,
wxConfigBase *  cfg = NULL
[static]
 

Reads a wxSize value from the configuration file.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
cfg A pointer on the configuration instance from which the value must be read. If NULL, the global configuration instance (given by wxConfig::Get()) will be used.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 940 of file appprefs.cpp.

References read().

bool PreferenceValue::read const wxString &  key,
wxSize *  r,
wxConfigBase *  cfg = NULL
[static]
 

Reads a wxSize value from the configuration file.

Parameters:
key The key whose associated value is to be returned.
r A pointer on the wxSize in which the value will be stored.
cfg A pointer on the configuration instance from which the value must be read. If NULL, the global configuration instance (given by wxConfig::Get()) will be used.
Returns:
true if the value was read, false otherwise. If the key was not found, r is not changed.

Definition at line 888 of file appprefs.cpp.

References read().

wxPoint PreferenceValue::read const wxString &  key,
const wxPoint &  def,
wxConfigBase *  cfg = NULL
[static]
 

Reads a wxPoint value from the configuration file.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
cfg A pointer on the configuration instance from which the value must be read. If NULL, the global configuration instance (given by wxConfig::Get()) will be used.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 865 of file appprefs.cpp.

References read().

bool PreferenceValue::read const wxString &  key,
wxPoint *  r,
wxConfigBase *  cfg = NULL
[static]
 

Reads a wxPoint value from the configuration file.

Parameters:
key The key whose associated value is to be returned.
r A pointer on the wxPoint in which the value will be stored.
cfg A pointer on the configuration instance from which the value must be read. If NULL, the global configuration instance (given by wxConfig::Get()) will be used.
Returns:
true if the value was read, false otherwise. If the key was not found, r is not changed.

Definition at line 813 of file appprefs.cpp.

References read().

wxRect PreferenceValue::read const wxString &  key,
const wxRect &  def,
wxConfigBase *  cfg = NULL
[static]
 

Reads a wxRect value from the configuration file.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
cfg A pointer on the configuration instance from which the value must be read. If NULL, the global configuration instance (given by wxConfig::Get()) will be used.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 790 of file appprefs.cpp.

References read().

bool PreferenceValue::read const wxString &  key,
wxRect *  r,
wxConfigBase *  cfg = NULL
[static]
 

Reads a wxRect value from the configuration file.

Parameters:
key The key whose associated value is to be returned.
r A pointer on the wxRect in which the value will be stored.
cfg A pointer on the configuration instance from which the value must be read. If NULL, the global configuration instance (given by wxConfig::Get()) will be used.
Returns:
true if the value was read, false otherwise. If the key was not found, r is not changed.

Definition at line 736 of file appprefs.cpp.

References read().

Referenced by PreferenceValue(), and read().

bool PreferenceValue::set const wxSize &  newValue  ) 
 

Sets a wxSize value.

Parameters:
newValue The new value of the preference. If the preference has a corresponding key in the configuration file, the value will be written in the configuration file.
Returns:
true if the type of the preference is a wxSize and if the value has been successfully written in the configuration file (if needed), false otherwise.
Remarks:
The configuration file is given by the static method wxConfig::Get().

Definition at line 705 of file appprefs.cpp.

References _cfgKey, _value, _valueType, set(), and PreferenceValue::value_t::valSize.

bool PreferenceValue::set const wxPoint &  newValue  ) 
 

Sets a wxPoint value.

Parameters:
newValue The new value of the preference. If the preference has a corresponding key in the configuration file, the value will be written in the configuration file.
Returns:
true if the type of the preference is a wxPoint and if the value has been successfully written in the configuration file (if needed), false otherwise.
Remarks:
The configuration file is given by the static method wxConfig::Get().

Definition at line 653 of file appprefs.cpp.

References _cfgKey, _value, _valueType, set(), and PreferenceValue::value_t::valPoint.

bool PreferenceValue::set const wxRect &  newValue  ) 
 

Sets a wxRect value.

Parameters:
newValue The new value of the preference. If the preference has a corresponding key in the configuration file, the value will be written in the configuration file.
Returns:
true if the type of the preference is a wxRect and if the value has been successfully written in the configuration file (if needed), false otherwise.
Remarks:
The configuration file is given by the static method wxConfig::Get().

Definition at line 600 of file appprefs.cpp.

References _cfgKey, _value, _valueType, set(), and PreferenceValue::value_t::valRect.

bool PreferenceValue::set const bool  newValue  ) 
 

Sets a boolean value.

Parameters:
newValue The new value of the preference. If the preference has a corresponding key in the configuration file, the value will be written in the configuration file.
Returns:
true if the type of the preference is a boolean and if the value has been successfully written in the configuration file (if needed), false otherwise.
Remarks:
The configuration file is given by the static method wxConfig::Get().

Definition at line 552 of file appprefs.cpp.

References _cfgKey, _value, _valueType, set(), and PreferenceValue::value_t::valBool.

bool PreferenceValue::set const double  newValue  ) 
 

Sets a string value.

Parameters:
newValue The new value of the preference. If the preference has a corresponding key in the configuration file, the value will be written in the configuration file.
Returns:
true if the type of the preference is a double and if the value has been successfully written in the configuration file (if needed), false otherwise.
Remarks:
The configuration file is given by the static method wxConfig::Get().

Definition at line 504 of file appprefs.cpp.

References _cfgKey, _value, _valueType, set(), and PreferenceValue::value_t::valDouble.

bool PreferenceValue::set const wxString &  newValue  ) 
 

Sets a string value.

Parameters:
newValue The new value of the preference. If the preference has a corresponding key in the configuration file, the value will be written in the configuration file.
Returns:
true if the type of the preference is a string and if the value has been successfully written in the configuration file (if needed), false otherwise.
Remarks:
The configuration file is given by the static method wxConfig::Get().

Definition at line 456 of file appprefs.cpp.

References _cfgKey, _value, _valueType, set(), and PreferenceValue::value_t::valString.

bool PreferenceValue::set const long  newValue  ) 
 

Sets a long integer value.

Parameters:
newValue The new value of the preference. If the preference has a corresponding key in the configuration file, the value will be written in the configuration file.
Returns:
true if the type of the preference is a long integer and if the value has been successfully written in the configuration file (if needed), false otherwise.
Remarks:
The configuration file is given by the static method wxConfig::Get().

Definition at line 408 of file appprefs.cpp.

References _cfgKey, _value, _valueType, set(), and PreferenceValue::value_t::valLong.

Referenced by set().


Member Data Documentation

wxString PreferenceValue::_cfgKey [protected]
 

Corresponding key in the configuration file. Must be empty if this item isn't stored in the configuration file.

Definition at line 98 of file appprefs.hpp.

Referenced by clone(), getConfigKey(), PreferenceValue(), and set().

value_t PreferenceValue::_value [protected]
 

Value of the preference.

Definition at line 96 of file appprefs.hpp.

Referenced by cleanup(), clone(), get(), PreferenceValue(), and set().

PreferenceType PreferenceValue::_valueType [protected]
 

Type of the preference.

Definition at line 97 of file appprefs.hpp.

Referenced by cleanup(), clone(), get(), PreferenceValue(), and set().


The documentation for this class was generated from the following files:
Generated on Sun May 30 13:38:06 2004 for wxChecksums by doxygen 1.3.7