ACE  6.1.0
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
ACE_Configuration Class Reference

Base class for configuration databases. More...

#include <Configuration.h>

Inheritance diagram for ACE_Configuration:
Inheritance graph
[legend]
Collaboration diagram for ACE_Configuration:
Collaboration graph
[legend]

List of all members.

Public Types

enum  VALUETYPE { STRING, INTEGER, BINARY, INVALID }
 Enumeration for the various types of values we can store. More...

Public Member Functions

virtual ~ACE_Configuration (void)
 Destructor.
virtual const
ACE_Configuration_Section_Key
root_section (void) const
 Obtain a reference to the root section of this configuration.
virtual int open_section (const ACE_Configuration_Section_Key &base, const ACE_TCHAR *sub_section, int create, ACE_Configuration_Section_Key &result)=0
virtual int remove_section (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *sub_section, bool recursive)=0
 Removes a named section.
virtual int enumerate_values (const ACE_Configuration_Section_Key &key, int index, ACE_TString &name, VALUETYPE &type)=0
virtual int enumerate_sections (const ACE_Configuration_Section_Key &key, int index, ACE_TString &name)=0
virtual int set_string_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, const ACE_TString &value)=0
 Sets a string-typed value.
virtual int set_integer_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, u_int value)=0
 Sets a integer-typed value.
virtual int set_binary_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, const void *data, size_t length)=0
 Sets a binary-typed value.
virtual int get_string_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, ACE_TString &value)=0
 Gets a string-typed value.
virtual int get_integer_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, u_int &value)=0
 Gets an integer-typed value.
virtual int get_binary_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, void *&data, size_t &length)=0
 Gets a binary-typed value.
virtual int find_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, VALUETYPE &type)=0
virtual int remove_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name)=0
 Removes a named value.
int expand_path (const ACE_Configuration_Section_Key &key, const ACE_TString &path_in, ACE_Configuration_Section_Key &key_out, int create=1)
bool operator== (const ACE_Configuration &rhs) const
bool operator!= (const ACE_Configuration &rhs) const

Static Public Attributes

static ACE_TCHAR NULL_String_ = '\0'

Protected Member Functions

 ACE_Configuration (void)
 Default ctor.
ACE_Section_Key_Internalget_internal_key (const ACE_Configuration_Section_Key &key)
 Resolves the internal key from a section key.
int validate_name (const ACE_TCHAR *name, int allow_path=0)
int validate_value_name (const ACE_TCHAR *name)
 ACE_Configuration (const ACE_Configuration &rhs)
ACE_Configurationoperator= (const ACE_Configuration &rhs)

Protected Attributes

ACE_Configuration_Section_Key root_

Detailed Description

Base class for configuration databases.

This class provides an interface for configuration databases. A concrete class is required that implements the interface.

See also:
ACE_Configuration_Heap
ACE_Configuration_Win32Registry

Member Enumeration Documentation

Enumeration for the various types of values we can store.

Enumerator:
STRING 
INTEGER 
BINARY 
INVALID 

Constructor & Destructor Documentation

ACE_Configuration::~ACE_Configuration ( void  ) [virtual]

Destructor.

ACE_Configuration::ACE_Configuration ( void  ) [protected]

Default ctor.

ACE_Configuration::ACE_Configuration ( const ACE_Configuration rhs) [protected]

Member Function Documentation

virtual int ACE_Configuration::enumerate_sections ( const ACE_Configuration_Section_Key key,
int  index,
ACE_TString name 
) [pure virtual]

Enumerates through the subsections in a section.

Parameters:
keySection key to iterate through.
indexIteration position. Must be zero on the first call to iterate through key. Increment index by one on each successive call to this method.
nameReceives the subsection's name.
Note:
You may not modify the key section while enumerating. If the section is modified during enumeration, results are undefined; you must restart the enumeration from index 0.
Return values:
0for success, name has a valid name.
1there are no more subsections in the section.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

virtual int ACE_Configuration::enumerate_values ( const ACE_Configuration_Section_Key key,
int  index,
ACE_TString name,
VALUETYPE type 
) [pure virtual]

Enumerates through the values in a section.

Parameters:
keySection key to iterate through.
indexIteration position. Must be zero on the first call to iterate through key. Increment index by one on each successive call to this method.
nameReceives the value's name.
typeReceives the value's data type.
Note:
You may not delete or add values while enumerating. If the section is modified during enumeration, results are undefined; you must restart the enumeration from index 0.
Return values:
0for success, name and type are valid.
1there are no more values in the section.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

int ACE_Configuration::expand_path ( const ACE_Configuration_Section_Key key,
const ACE_TString path_in,
ACE_Configuration_Section_Key key_out,
int  create = 1 
)

Expands path_in to key_out from key. If create is true, the subsections are created. Returns 0 on success, non zero on error The path consists of sections separated by the backslash '\' or forward slash '/'. Returns 0 on success, -1 if <create) is 0 and the path refers a nonexistant section

virtual int ACE_Configuration::find_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name,
VALUETYPE type 
) [pure virtual]

Retrieves the type of a named configuration value.

Parameters:
keyConfiguration section to look up the name in.
nameName of the configuration value to get the type of.
typeReceives the data type of the named value, if it exists.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

virtual int ACE_Configuration::get_binary_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name,
void *&  data,
size_t &  length 
) [pure virtual]

Gets a binary-typed value.

Parameters:
keyConfiguration section to get the value from.
nameName of the configuration value to get.
dataReceives a pointer to memory holding the binary data for the value. This method allocates the memory pointed to using operator new[]. The caller is responsible for freeing the memory using operator delete[].
lengthReceives the number of bytes in the value.
Return values:
0for success; caller is responsible for freeing the returned memory.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

virtual int ACE_Configuration::get_integer_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name,
u_int &  value 
) [pure virtual]

Gets an integer-typed value.

Parameters:
keyConfiguration section to get the value from.
nameName of the configuration value to get.
valueReceives the configuration value if it exists and has type INTEGER.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

ACE_Section_Key_Internal * ACE_Configuration::get_internal_key ( const ACE_Configuration_Section_Key key) [protected]

Resolves the internal key from a section key.

virtual int ACE_Configuration::get_string_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name,
ACE_TString value 
) [pure virtual]

Gets a string-typed value.

Parameters:
keyConfiguration section to get the value from.
nameName of the configuration value to get.
valueReceives the configuration value if it exists and has type STRING.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

virtual int ACE_Configuration::open_section ( const ACE_Configuration_Section_Key base,
const ACE_TCHAR sub_section,
int  create,
ACE_Configuration_Section_Key result 
) [pure virtual]

Opens a named section in an existing section.

Parameters:
baseExisting section in which to open the named section.
sub_sectionName of the section to open.
createIf zero, the named section must exist. If non-zero, the named section will be created if it does not exist.
resultReference; receives the section key for the new section.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

bool ACE_Configuration::operator!= ( const ACE_Configuration rhs) const

Determine if the contents of this object are different from the contents of the object on the right hand side. Returns false if they are equal and true if they are not equal

ACE_Configuration& ACE_Configuration::operator= ( const ACE_Configuration rhs) [protected]
bool ACE_Configuration::operator== ( const ACE_Configuration rhs) const

Determine if the contents of this object is the same as the contents of the object on the right hand side. Returns true if they are equal and false if they are not equal

Determine if the contents of this object is the same as the contents of the object on the right hand side. Returns 1 (True) if they are equal and 0 (False) if they are not equal

virtual int ACE_Configuration::remove_section ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR sub_section,
bool  recursive 
) [pure virtual]

Removes a named section.

Parameters:
keySection key to remove the named section from.
sub_sectionName of the section to remove.
recursiveIf true, any subkeys below sub_section are removed as well.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

virtual int ACE_Configuration::remove_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name 
) [pure virtual]

Removes a named value.

Parameters:
keyConfiguration section to remove the named value from.
nameName of the configuration value to remove.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

const ACE_Configuration_Section_Key & ACE_Configuration::root_section ( void  ) const [virtual]

Obtain a reference to the root section of this configuration.

virtual int ACE_Configuration::set_binary_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name,
const void *  data,
size_t  length 
) [pure virtual]

Sets a binary-typed value.

Parameters:
keyConfiguration section to set the value in.
nameName of the configuration value to set. If a value with the specified name exists, it is replaced.
dataPointer to the binary data for the value.
lengthNumber of bytes for the new value.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

virtual int ACE_Configuration::set_integer_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name,
u_int  value 
) [pure virtual]

Sets a integer-typed value.

Parameters:
keyConfiguration section to set the value in.
nameName of the configuration value to set. If a value with the specified name exists, it is replaced.
valueThe integer to set the configuration value to.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

virtual int ACE_Configuration::set_string_value ( const ACE_Configuration_Section_Key key,
const ACE_TCHAR name,
const ACE_TString value 
) [pure virtual]

Sets a string-typed value.

Parameters:
keyConfiguration section to set the value in.
nameName of the configuration value to set. If a value with the specified name exists, it is replaced.
valueThe string to set the configuration value to.
Return values:
0for success.
-1for error; ACE_OS::last_error() retrieves error code.

Implemented in ACE_Configuration_Heap, and ACE_Configuration_Win32Registry.

int ACE_Configuration::validate_name ( const ACE_TCHAR name,
int  allow_path = 0 
) [protected]

Tests to see if name is valid. name must be < 255 characters and not contain the path separator '\', brackets [] or = (maybe just restrict to alphanumeric?) returns non zero if name is not valid. The path separator is allowed, except for the first character, if allow_path is true.

int ACE_Configuration::validate_value_name ( const ACE_TCHAR name) [protected]

Test to see if name is valid. The default value for a key can be unnamed, which means either name is == 0 or name == '\0` is valid. Otherwise, it calls validate_name() to test name for the same rules that apply to keys.


Member Data Documentation

* Represents the "NULL" string to simplify the internal logic.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines