ADTF
3.18.2
|
String table. More...
Public Member Functions | |
cStringTable () | |
Default constructor. | |
virtual | ~cStringTable () |
Destructor. | |
tResult | Load (const tChar *strFilename) |
Loads a string table from a file. More... | |
tResult | LoadFromString (const tChar *strTable) |
Initializes the string table from a string. More... | |
tResult | Free () |
Frees all allocated resources. More... | |
cString & | Get (const tChar *strId) |
Returns the value assigned to a string. More... | |
cString | Format (const tChar *strId,...) |
Printf-style formating. More... | |
tInt32 | GetItemCount () const |
This function returns the number of items the table contains. More... | |
cString & | operator[] (const cString &strKey) |
This function retrieves a string value from the list. More... | |
cString & | operator[] (tInt32 nIdx) |
Use this function to access single elements of the table. More... | |
tBool | IsEmpty () const |
This function checks if the string table object is empty. More... | |
Static Public Member Functions | |
static cStringTable * | GetGlobal () |
Returns the global table if available. More... | |
Protected Attributes | |
cStringMap | m_mapStrings |
Internally used string map. | |
Static Protected Attributes | |
static cStringTable * | m_pGlobalInstance |
Pointer to global string table. | |
Printf-style formating.
strId | [in] The id string which value string should be used as format string. |
tResult Free | ( | ) |
Frees all allocated resources.
Returns the value assigned to a string.
strId | [in] The key string. |
|
static |
Returns the global table if available.
Please note that this is not an actual singleton. This just returns a pointer to the first instance created of cStringTable. If this instance is deleted, the global table is not available until another table is created and takes its place.
tInt32 GetItemCount | ( | ) | const |
This function returns the number of items the table contains.
tBool IsEmpty | ( | ) | const |
This function checks if the string table object is empty.
Loads a string table from a file.
The file has to be formated with name=value pairs seperated by newlines. Comments begin with #, ; or //.
strFilename | [in] The filename. |
Initializes the string table from a string.
The string has to be formated with name=value pairs seperated by newlines. Comments begin with #, ; or // If you want either key or value to contain whitespace characters, escape them. This function will not return an error even if some pairs could not be parsed or look like they were parsed incorrectly. Only an invalid argument will cause an error. Neither key nor value can be empty. If the key is empyt, side effects may happen ( see note )
strTable | [in] The input string. |
This function retrieves a string value from the list.
strKey | [in] Key value of string to be fetched. |