INI section chunk. More...
Public Member Functions | |
Section () | |
Create an empty Section object. | |
Section (const char *pSection) | |
Create a Section object initialized with a name. | |
virtual | ~Section () |
Call the destructor for a Section object. | |
uint_t | Save (OutputMemoryStream *pOutput) const |
Save a script file. | |
const char * | GetName (void) const |
Return a pointer to the section's name. | |
void | SetName (const char *pInput) |
Set a new name for the section. | |
void | SetName (const String *pInput) |
Set a new name for the section. | |
Entry * | AddEntry (const char *pKey, const char *pValue) |
Create a new entry and append it to the end of the section. | |
Entry * | FindEntry (const char *pKey) const |
Locate an entry and return it if found. | |
Entry * | FindEntry (const char *pKey, uint_t bAlwaysCreate) |
Locate an entry and return it or create it if necessary. | |
Comment * | AddComment (const char *pComment) |
Create a new comment and append it to the end of the section. | |
const char * | GetValue (const char *pKey) const |
Locate an entry and return a pointer to the value string. | |
void | SetValue (const char *pKey, const char *pInput) |
Locate an entry and set a new value string. | |
void | SetValue (const char *pKey, const String *pInput) |
Locate an entry and set a new value string. | |
uint_t | GetBoolean (const char *pKey, uint_t bDefault) const |
Locate and return a boolean value (TRUE or FALSE) | |
void | SetBoolean (const char *pKey, uint_t bValue) |
Locate an entry and set a new boolean string. | |
uint_t | GetWord (const char *pKey, uint_t uDefault, uint_t uMin=0, uint_t uMax=0xFFFFFFFFU) const |
Locate and return an unsigned integer value. | |
void | SetWord (const char *pKey, uint_t uValue) |
Locate an entry and set a new unsigned integer string. | |
void | SetWordHex (const char *pKey, uint_t uValue) |
Locate an entry and set a new unsigned integer string. | |
int_t | GetInt (const char *pKey, int_t iDefault, int_t iMin=(- 0x7FFFFFFF) -1, int_t iMax=0x7FFFFFFF) const |
Locate and return an unsigned integer value. | |
void | SetInt (const char *pKey, int_t iValue) |
Locate an entry and set a new signed integer string. | |
float | GetFloat (const char *pKey, float fDefault, float fMin, float fMax) const |
Locate and return a 32 bit floating point value. | |
void | SetFloat (const char *pKey, float fValue) |
Locate an entry and set a new 32 bit floating point string. | |
double | GetDouble (const char *pKey, double dDefault, double dMin, double dMax) const |
Locate and return a 64 bit floating point value. | |
void | SetDouble (const char *pKey, double dValue) |
Locate an entry and set a new 64 bit floating point string. | |
void | GetString (String *pOutput, const char *pKey, const char *pDefault) const |
Locate and return a quoted string. | |
void | SetString (const char *pKey, const char *pValue) |
Locate an entry and set a new quoted string. | |
Public Member Functions inherited from Burger::FileINI::Generic | |
Generic (eType uType) | |
Initialize a generic object. | |
virtual | ~Generic () |
Call the destructor for a generic object. | |
Generic * | GetNext (void) const |
Get the pointer to the next object in the list. | |
Generic * | GetPrevious (void) const |
Get the pointer to the previous object in the list. | |
eType | GetType (void) const |
Get the enumeration of the derived class' type. | |
void | InsertBefore (Generic *pGeneric) |
Insert this object before this one in the linked list. | |
void | InsertAfter (Generic *pGeneric) |
Insert this object after this one in the linked list. | |
Public Member Functions inherited from Burger::Base | |
const char * | get_class_name (void) const noexcept |
Get the name of the class. | |
virtual const Burger::StaticRTTI * | get_StaticRTTI (void) const noexcept |
Get the description to the class. | |
virtual | ~Base () noexcept=default |
Destructor. | |
Static Public Member Functions | |
static Section * | New (void) |
Allocate an empty Section object. | |
static Section * | New (const char *pSection) |
Allocate a Section object initialized with a name. | |
Private Attributes | |
Generic | m_Root |
Linked list root for all attached entries. | |
String | m_SectionName |
Name of the section. | |
Additional Inherited Members | |
Public Types inherited from Burger::FileINI::Generic | |
enum | eType { LINEENTRY_ROOT , LINEENTRY_SECTION , LINEENTRY_ENTRY , LINEENTRY_COMMENT } |
Enumeration to identify derived classes. More... | |
Static Public Attributes inherited from Burger::Base | |
static const Burger::StaticRTTI | g_StaticRTTI |
The global description of the class. | |
INI section chunk.
INI files have data entries in the form of..
When braces are found, a Section class is created and all entries following it will be inserted into the section and all data queries are done through the section. Since sections contain localized data, entry names can be reused because name collisions are avoided.
Before the first section is found, a nameless section exists to hold data that isn't part of a data section. To access that data, pass an empty string as the section name.
Burger::FileINI::Section::Section | ( | ) |
Create an empty Section object.
Burger::FileINI::Section::Section | ( | const char * | pSection | ) |
Create a Section object initialized with a name.
pSection | "C" string containing the new section name |
|
virtual |
Call the destructor for a Section object.
Unlink itself from the linked list and release the contained strings and objects
Burger::FileINI::Comment *BURGER_API Burger::FileINI::Section::AddComment | ( | const char * | pComment | ) |
Create a new comment and append it to the end of the section.
pComment | Pointer to a "C" string for the new entry's data |
Burger::FileINI::Entry *BURGER_API Burger::FileINI::Section::AddEntry | ( | const char * | pKey, |
const char * | pValue ) |
Create a new entry and append it to the end of the section.
pKey | Pointer to a "C" string for the new entry's key |
pValue | Pointer to a "C" string for the new entry's value |
Burger::FileINI::Entry *BURGER_API Burger::FileINI::Section::FindEntry | ( | const char * | pKey | ) | const |
Locate an entry and return it if found.
pKey | Pointer to a "C" of the key desired |
Burger::FileINI::Entry *BURGER_API Burger::FileINI::Section::FindEntry | ( | const char * | pKey, |
uint_t | bAlwaysCreate ) |
Locate an entry and return it or create it if necessary.
pKey | Pointer to a "C" of the key desired |
bAlwaysCreate | If non-zero, and if the entry wasn't found, create a new entry with this desired key |
uint_t BURGER_API Burger::FileINI::Section::GetBoolean | ( | const char * | pKey, |
uint_t | bDefault ) const |
Locate and return a boolean value (TRUE or FALSE)
Search the entries in the Section and if found scan the value string and if it matches the word TRUE or FALSE (Case insensitive), it will return TRUE or FALSE. If the value is numeric, it will return TRUE if the value is not zero and FALSE if not.
If it's none of the above, then return the default value
pKey | Pointer to a "C" of the key desired |
bDefault | Value to return on error |
double BURGER_API Burger::FileINI::Section::GetDouble | ( | const char * | pKey, |
double | dDefault, | ||
double | dMin, | ||
double | dMax ) const |
Locate and return a 64 bit floating point value.
Search the entries in the Section and if found scan the value string as a 64 bit floating point numeric value and if successful, test it against the valid range and return the value clamped to that range. If it's not a number, return the default.
If NaN or Inf is detected, it will be converted to a zero to prevent floating point issues.
If it's none of the above, then return the default value
pKey | Pointer to a "C" of the key desired |
dDefault | Value to return on error |
dMin | Minimum acceptable value |
dMax | Maximum acceptable value |
float BURGER_API Burger::FileINI::Section::GetFloat | ( | const char * | pKey, |
float | fDefault, | ||
float | fMin, | ||
float | fMax ) const |
Locate and return a 32 bit floating point value.
Search the entries in the Section and if found scan the value string as a 32 bit floating point numeric value and if successful, test it against the valid range and return the value clamped to that range. If it's not a number, return the default.
If NaN or Inf is detected, it will be converted to a zero to prevent floating point issues.
If it's none of the above, then return the default value
pKey | Pointer to a "C" of the key desired |
fDefault | Value to return on error |
fMin | Minimum acceptable value |
fMax | Maximum acceptable value |
int_t BURGER_API Burger::FileINI::Section::GetInt | ( | const char * | pKey, |
int_t | iDefault, | ||
int_t | iMin = (- 0x7FFFFFFF )-1, | ||
int_t | iMax = 0x7FFFFFFF ) const |
Locate and return an unsigned integer value.
Search the entries in the Section and if found scan the value string as a 32 bit signed integer or hex value and if successful, test it against the valid range and return the value clamped to that range. If it's not a number, return the default.
Hex strings are acceptable input in the form of $1234 and 0x1234. 0xFFFFFFFF will be converted to -1.
If it's none of the above, then return the default value
pKey | Pointer to a "C" of the key desired |
iDefault | Value to return on error |
iMin | Minimum acceptable value |
iMax | Maximum acceptable value |
|
inline |
void BURGER_API Burger::FileINI::Section::GetString | ( | String * | pOutput, |
const char * | pKey, | ||
const char * | pDefault ) const |
Locate and return a quoted string.
Search the entries in the Section and if found return the string without enclosing quotes. The string can have quotes if double quotes were used.
If it's none of the above, then return the default value
const char *BURGER_API Burger::FileINI::Section::GetValue | ( | const char * | pKey | ) | const |
Locate an entry and return a pointer to the value string.
pKey | Pointer to a "C" of the key desired |
uint_t BURGER_API Burger::FileINI::Section::GetWord | ( | const char * | pKey, |
uint_t | uDefault, | ||
uint_t | uMin = 0, | ||
uint_t | uMax = 0xFFFFFFFFU ) const |
Locate and return an unsigned integer value.
Search the entries in the Section and if found scan the value string as a 32 bit unsigned integer or hex value and if successful, test it against the valid range and return the value clamped to that range. If it's not a number, return the default.
Hex strings are acceptable input in the form of $1234 and 0x1234
If it's none of the above, then return the default value
pKey | Pointer to a "C" of the key desired |
uDefault | Value to return on error |
uMin | Minimum acceptable value |
uMax | Maximum acceptable value |
|
static |
Allocate a Section object initialized with a name.
pSection | "C" string containing the new section name |
|
static |
Allocate an empty Section object.
uint_t BURGER_API Burger::FileINI::Section::Save | ( | OutputMemoryStream * | pOutput | ) | const |
Save a script file.
Serialize the data contained in the section as a chunk meant for a Windows style INI text file.
pOutput | Output string to store the UTF-8 file image of the data |
void BURGER_API Burger::FileINI::Section::SetBoolean | ( | const char * | pKey, |
uint_t | bValue ) |
Locate an entry and set a new boolean string.
Search the entries in the Section and if found replace the contained value string with a new one for a boolean.
If not found, create the entry with the data.
pKey | Pointer to a "C" of the key desired |
bValue | Zero to store "FALSE" or non zero to store "TRUE" |
void BURGER_API Burger::FileINI::Section::SetDouble | ( | const char * | pKey, |
double | dValue ) |
Locate an entry and set a new 64 bit floating point string.
Search the entries in the Section and if found convert the input into an floating point representation of a UTF-8 string and set the value to this string
If not found, create the entry with the data.
pKey | Pointer to a "C" of the key desired |
dValue | Value to store as a floating point string |
void BURGER_API Burger::FileINI::Section::SetFloat | ( | const char * | pKey, |
float | fValue ) |
Locate an entry and set a new 32 bit floating point string.
Search the entries in the Section and if found convert the input into an floating point representation of a UTF-8 string and set the value to this string
If not found, create the entry with the data.
pKey | Pointer to a "C" of the key desired |
fValue | Value to store as a floating point string |
void BURGER_API Burger::FileINI::Section::SetInt | ( | const char * | pKey, |
int_t | iValue ) |
Locate an entry and set a new signed integer string.
Search the entries in the Section and if found convert the input into an signed integer UTF-8 string and set the value to this string
If not found, create the entry with the data.
pKey | Pointer to a "C" of the key desired |
iValue | Value to convert to an signed integer UTF-8 string |
|
inline |
Set a new name for the section.
Replace the section name string with a new one
pInput | Pointer to a "C" string |
|
inline |
Set a new name for the section.
Replace the section name string with a new one
pInput | Pointer to a String class instance |
void BURGER_API Burger::FileINI::Section::SetString | ( | const char * | pKey, |
const char * | pValue ) |
void BURGER_API Burger::FileINI::Section::SetValue | ( | const char * | pKey, |
const char * | pInput ) |
Locate an entry and set a new value string.
Search the entries in the Section and if found replace the contained value string with a new one.
If not found, create the entry with the data.
pKey | Pointer to a "C" of the key desired |
pInput | Pointer to a "C" string of the new value |
void BURGER_API Burger::FileINI::Section::SetValue | ( | const char * | pKey, |
const String * | pInput ) |
void BURGER_API Burger::FileINI::Section::SetWord | ( | const char * | pKey, |
uint_t | uValue ) |
Locate an entry and set a new unsigned integer string.
Search the entries in the Section and if found replace the contained value string with a new one for an unsigned integer.
If not found, create the entry with the data.
pKey | Pointer to a "C" of the key desired |
uValue | Value to convert to an unsigned integer UTF-8 string |
void BURGER_API Burger::FileINI::Section::SetWordHex | ( | const char * | pKey, |
uint_t | uValue ) |
Locate an entry and set a new unsigned integer string.
Search the entries in the Section and if found replace the contained value string with a new one for a hex string for the unsigned integer.
If not found, create the entry with the data.
pKey | Pointer to a "C" of the key desired |
uValue | Value to convert to a hex string |
|
private |
Linked list root for all attached entries.
|
private |
Name of the section.