sipxportlib
Version 3.3
|
#include <OsConfigDb.h>
Public Member Functions | |
OsConfigDb () | |
virtual | ~OsConfigDb () |
virtual OsStatus | loadFromFile (FILE *fp) |
virtual OsStatus | loadFromFile (const char *filename) |
virtual OsStatus | loadFromBuffer (const char *buf) |
virtual OsStatus | storeToFile (const char *filename) |
virtual OsStatus | updateFile (const char *filename) const |
OsStatus | remove (const UtlString &rKey) |
OsStatus | removeByPrefix (const UtlString &rPrefix) |
void | set (const UtlString &rKey, const UtlString &rNewValue) |
void | set (const UtlString &rKey, const int iNewValue) |
virtual OsStatus | get (const UtlString &rKey, UtlString &rValue) const |
virtual OsStatus | get (const UtlString &rKey, int &rValue) const |
virtual const char * | getIdentityLabel () const |
virtual void | setIdentityLabel (const char *idLabel) |
OsConfigEncryption * | getEncryption () const |
void | setCapitalizeName (UtlBoolean capitalize) |
void | storeToBuffer (char *buff) const |
int | calculateBufferSize () const |
virtual UtlBoolean | isEmpty (void) const |
virtual int | numEntries (void) const |
virtual OsStatus | getSubHash (const UtlString &rHashSubKey, OsConfigDb &rSubDb) const |
virtual OsStatus | getNext (const UtlString &rKey, UtlString &rNextKey, UtlString &rNextValue) const |
virtual void | addList (const UtlString &rPrefix, UtlSList &rList) |
virtual int | loadList (const UtlString &rPrefix, UtlSList &rList) const |
int | getPort (const char *szKey) const |
void | clear () |
Static Public Member Functions | |
static void | setStaticEncryption (OsConfigEncryption *encryption) |
static OsConfigEncryption * | getStaticEncryption () |
static void | removeNewlineReturns (UtlString &stringData) |
Protected Member Functions | |
OsStatus | loadFromEncryptedFile (const char *filename) |
OsStatus | loadFromUnencryptedFile (FILE *fp) |
OsStatus | loadFromEncryptedBuffer (char *buf, int bufLen) |
OsStatus | loadFromUnencryptedBuffer (const char *buf) |
OsStatus | storeToEncryptedFile (const char *filename) |
OsStatus | storeBufferToFile (const char *filename, const char *buff, unsigned long buffLen) |
void | dump () |
virtual OsStatus | storeToFile (FILE *fp) |
void | insertEntry (const UtlString &rKey, const UtlString &rNewValue) |
OsConfigDb (const OsConfigDb &rOsConfigDb) | |
OsConfigDb & | operator= (const OsConfigDb &rhs) |
Static Protected Member Functions | |
static UtlBoolean | parseLine (const char *line, UtlBoolean capitalizeName, const char *fileLabelForError, UtlString &name, UtlString &value) |
static void | removeChars (UtlString *s, char c) |
Protected Attributes | |
OsRWMutex | mRWMutex |
UtlSortedList | mDb |
UtlString | mIdentityLabel |
UtlBoolean | mCapitalizeName |
Friends | |
class | OsConfigDbTest |
Configuration database containing key/value pairs with ability to read and write to disk.
OsConfigDb | ( | ) |
|
virtual |
|
protected |
Copy constructor (not implemented for this class)
|
virtual |
|
virtual |
Load the configuration database from a file
|
virtual |
Load the configuation database from a string buffer(Buffer CANNOT be encrypted) with the following format:
s : s
s : s
...
|
virtual |
Store the config database to a file
|
virtual |
Attempts to update existing file without loosing comments or parameter order
Remove the key/value pair associated with rKey.
return OS_SUCCESS if the key was found in the database, return OS_NOT_FOUND otherwise
Remove all the key/value pairs starting with the designated prefix
return OS_SUCCESS if one key or more keys were found in the database, return OS_NOT_FOUND otherwise
Insert the key/value pair into the config database If the database already contains an entry for this key, then set the value for the existing entry to rNewValue.
void set | ( | const UtlString & | rKey, |
const int | iNewValue | ||
) |
Insert the key/value pair into the config database If the database already contains an entry for this key, then set the value for the existing entry to iNewValue.
Sets rValue to the value in the database associated with rKey. If rKey is found in the database, returns OS_SUCCESS. Otherwise, returns OS_NOT_FOUND and sets rValue to the empty string.
Sets rValue to the value in the database associated with rKey. If rKey is found in the database, returns OS_SUCCESS. Otherwise, returns OS_NOT_FOUND and sets rValue to -1.
|
virtual |
Filename, URI, or what helps identify the contents of this config
|
virtual |
Filename, URI, or what helps identify the contents of this config
OsConfigEncryption * getEncryption | ( | ) | const |
Current encryption support. NULL when there's no encryption support, !NULL then there's a possiblity that actual contents of config will be encrypted or decrypted from/to io source.
|
static |
Set the default encryption support for all OsConfig instances
|
static |
Get the encryption support for call instances
void setCapitalizeName | ( | UtlBoolean | capitalize | ) |
force capitalization of all keys, most profiles want this off even keys are typcialy stored as capitalized
void storeToBuffer | ( | char * | buff | ) | const |
Store all contents into a buffer, call calculateBufferSize to get safe size. Call strlen to get actual size
int calculateBufferSize | ( | ) | const |
Return gauronteed to be large enough, (unless values are changed) when storing into a buffer
|
virtual |
Return TRUE if the database is empty, otherwise FALSE
|
virtual |
Return the number of entries in the config database
|
virtual |
Get a hash of name value pairs with the given key prefix
rHashSubKey | the prefix for keys to name value pairs which are copied into the given rSubDb. The key in the sub-OsConfigDb have the prefix removed. |
|
virtual |
Relative to rKey, return the key and value associated with next (lexicographically ordered) key/value pair stored in the database. If rKey is the empty string, key and value associated with the first entry in the database will be returned.
Stores a list of strings to the configuration datadase using the designated prefix as the base for the list items. The prefix is used to build unique configuration keys. For example, if you use specify a prefix of "MYLIST" and supply a list containing ("item 1", "item 2", and "item 3"), you will end up with the following:
MYLIST.COUNT : 3 MYLIST.1 : item 1 MYLIST.2 : item 2 MYLIST.3 : item 3
Warning: All items with a key of "[rPrefix]." are removed as a side effect.
rPrefix | Configuration name prefix |
rList | List of UtlString values. |
int getPort | ( | const char * | szKey | ) | const |
Helper method to obtain a port value from the configuration database. Results are as follows:
PORT_DEFAULT : Let a port be selected automatically. Represented as "DEFAULT". PORT_NONE : Disabled (either specified as such, the key was not found, or the value was blank) Represented as "NONE". other : The port number that was specified Represented as a decimal integer.
szKey | Key file to lookup. |
void clear | ( | ) |
Delete all entries from the configuration database
|
static |
Remove newlines and carriage returns from string
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedvirtual |
|
staticprotected |
Parse "key : value" and returns TRUE if parameter found Returns false if line is blank or a comment (begins with #).
Method for inserting a key/value pair into the dictionary The write lock for the database should be taken before calling this method. If the database already contains an entry for this key, then set the value for the existing entry to rNewValue.
|
protected |
Assignment operator (not implemented for this class)
|
staticprotected |
Utility func to remove all chars = c from given string
|
friend |
|
mutableprotected |
reader/writer lock for synchronization
|
protected |
sorted storage of key/values
|
protected |
ID, used to distiguish which files should be encrypted
|
protected |
Force capitalization on all keys. Most profile do not want this on even though most of their keys are already captilized