Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::FileINI::Section Class Reference

INI section chunk. More...

Inheritance diagram for Burger::FileINI::Section:
Collaboration diagram for Burger::FileINI::Section:

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.
 
EntryAddEntry (const char *pKey, const char *pValue)
 Create a new entry and append it to the end of the section.
 
EntryFindEntry (const char *pKey) const
 Locate an entry and return it if found.
 
EntryFindEntry (const char *pKey, uint_t bAlwaysCreate)
 Locate an entry and return it or create it if necessary.
 
CommentAddComment (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.
 
GenericGetNext (void) const
 Get the pointer to the next object in the list.
 
GenericGetPrevious (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::StaticRTTIget_StaticRTTI (void) const noexcept
 Get the description to the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Member Functions

static SectionNew (void)
 Allocate an empty Section object.
 
static SectionNew (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.
 

Detailed Description

INI section chunk.


INI files have data entries in the form of..

Nameless = 1234
Data = 1
String = "Hello world"
Number = 7.3232
[NewSection]
Data = 3
Section()
Create an empty Section object.
Definition brfileini.cpp:776
UTF 8 bit string class.
Definition burger.h:14855

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.

Note
This will identify with eType of LINEENTRY_SECTION
See also
Burger::FileINI, Burger::FileINI::Comment, Burger::FileINI::Generic or Burger::FileINI::Entry

Constructor & Destructor Documentation

◆ Section() [1/2]

Burger::FileINI::Section::Section ( )

Create an empty Section object.


◆ Section() [2/2]

Burger::FileINI::Section::Section ( const char * pSection)

Create a Section object initialized with a name.


Parameters
pSection"C" string containing the new section name

◆ ~Section()

Burger::FileINI::Section::~Section ( )
virtual

Call the destructor for a Section object.


Unlink itself from the linked list and release the contained strings and objects

Member Function Documentation

◆ AddComment()

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.


Parameters
pCommentPointer to a "C" string for the new entry's data
Returns
Pointer to the new comment or NULL on an out of memory situation
See also
FindEntry(const char *,uint_t) or AddEntry(const char *,const char *)

◆ AddEntry()

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.


Parameters
pKeyPointer to a "C" string for the new entry's key
pValuePointer to a "C" string for the new entry's value
Returns
Pointer to the new entry or NULL on an out of memory situation
See also
FindEntry(const char *,uint_t) or AddComment(const char *)

◆ FindEntry() [1/2]

Burger::FileINI::Entry *BURGER_API Burger::FileINI::Section::FindEntry ( const char * pKey) const

Locate an entry and return it if found.


Parameters
pKeyPointer to a "C" of the key desired
Returns
Pointer to the located entry or NULL if the entry wasn't found
See also
FindEntry(const char *,uint_t)

◆ FindEntry() [2/2]

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.


Parameters
pKeyPointer to a "C" of the key desired
bAlwaysCreateIf non-zero, and if the entry wasn't found, create a new entry with this desired key
Returns
Pointer to the located key or NULL if the key wasn't found or not enough memory to create a new entry
See also
FindEntry(const char *) const

◆ GetBoolean()

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

Parameters
pKeyPointer to a "C" of the key desired
bDefaultValue to return on error
Returns
TRUE or FALSE or bDefault
See also
SetBoolean(const char *,uint_t)

◆ GetDouble()

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

Parameters
pKeyPointer to a "C" of the key desired
dDefaultValue to return on error
dMinMinimum acceptable value
dMaxMaximum acceptable value
Returns
Value in between dMin and dMax or dDefault
See also
SetDouble(const char *,double) or GetFloat(const char *,float,float,float) const

◆ GetFloat()

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

Parameters
pKeyPointer to a "C" of the key desired
fDefaultValue to return on error
fMinMinimum acceptable value
fMaxMaximum acceptable value
Returns
Value in between fMin and fMax or fDefault
See also
SetFloat(const char *,float) or GetDouble(const char *,double,double,double) const

◆ GetInt()

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

Parameters
pKeyPointer to a "C" of the key desired
iDefaultValue to return on error
iMinMinimum acceptable value
iMaxMaximum acceptable value
Returns
Value in between iMin and iMax or iDefault
See also
SetInt(const char *,int_t) or GetWord(const char *,uint_t,uint_t,uint_t) const

◆ GetName()

const char * Burger::FileINI::Section::GetName ( void ) const
inline

Return a pointer to the section's name.


See also
SetName(const char *) or SetName(const String *)

◆ GetString()

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

Parameters
pOutputPointer to a String class to hold the resulting string
pKeyPointer to a "C" of the key desired
pDefaultString to return on error
See also
SetString(const char *,const char *)

◆ GetValue()

const char *BURGER_API Burger::FileINI::Section::GetValue ( const char * pKey) const

Locate an entry and return a pointer to the value string.


Parameters
pKeyPointer to a "C" of the key desired
Returns
Pointer to the "C" string located or NULL if the key wasn't found
See also
FindEntry(const char *) const, SetValue(const char *,const char *) or SetValue(const char *,const String *)

◆ GetWord()

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

Parameters
pKeyPointer to a "C" of the key desired
uDefaultValue to return on error
uMinMinimum acceptable value
uMaxMaximum acceptable value
Returns
Value in between uMin and uMax or uDefault
See also
SetWord(const char *,uint_t) or GetInt(const char *,int_t,int_t,int_t) const

◆ New() [1/2]

Burger::FileINI::Section *BURGER_API Burger::FileINI::Section::New ( const char * pSection)
static

Allocate a Section object initialized with a name.


Parameters
pSection"C" string containing the new section name

◆ New() [2/2]

Burger::FileINI::Section *BURGER_API Burger::FileINI::Section::New ( void )
static

Allocate an empty Section object.


◆ Save()

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.

Parameters
pOutputOutput string to store the UTF-8 file image of the data
Returns
Zero on success, non zero on error

◆ SetBoolean()

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.

Parameters
pKeyPointer to a "C" of the key desired
bValueZero to store "FALSE" or non zero to store "TRUE"
See also
GetBoolean(const char *,uint_t) const

◆ SetDouble()

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.

Parameters
pKeyPointer to a "C" of the key desired
dValueValue to store as a floating point string
See also
GetDouble(const char *,double,double,double) const and SetFloat(const char *,float)

◆ SetFloat()

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.

Parameters
pKeyPointer to a "C" of the key desired
fValueValue to store as a floating point string
See also
GetFloat(const char *,float,float,float) const and SetDouble(const char *,double)

◆ SetInt()

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.

Parameters
pKeyPointer to a "C" of the key desired
iValueValue to convert to an signed integer UTF-8 string
See also
GetInt(const char *,int_t,int_t,int_t) const and SetWord(const char *,uint_t)

◆ SetName() [1/2]

void Burger::FileINI::Section::SetName ( const char * pInput)
inline

Set a new name for the section.


Replace the section name string with a new one

Parameters
pInputPointer to a "C" string
See also
GetName(void) const or SetName(const String *)

◆ SetName() [2/2]

void Burger::FileINI::Section::SetName ( const String * pInput)
inline

Set a new name for the section.


Replace the section name string with a new one

Parameters
pInputPointer to a String class instance
See also
GetName(void) const or SetName(const char *)

◆ SetString()

void BURGER_API Burger::FileINI::Section::SetString ( const char * pKey,
const char * pValue )

Locate an entry and set a new quoted string.


Search the entries in the Section and if found convert the input into an quoted string.

If not found, create the entry with the data.

Parameters
pKeyPointer to a "C" of the key desired
pValueString to encapsulate with quotes
See also
GetString(String *,const char *,const char *) const

◆ SetValue() [1/2]

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.

Parameters
pKeyPointer to a "C" of the key desired
pInputPointer to a "C" string of the new value
See also
GetValue(const char *) const or SetValue(const char *,const String *)

◆ SetValue() [2/2]

void BURGER_API Burger::FileINI::Section::SetValue ( const char * pKey,
const String * 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.

Parameters
pKeyPointer to a "C" of the key desired
pInputPointer to a String containing the new value
See also
GetValue(const char *) const or SetValue(const char *,const char *)

◆ SetWord()

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.

Parameters
pKeyPointer to a "C" of the key desired
uValueValue to convert to an unsigned integer UTF-8 string
See also
GetWord(const char *,uint_t,uint_t,uint_t) const and SetWordHex(const char *,uint_t)

◆ SetWordHex()

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.

Parameters
pKeyPointer to a "C" of the key desired
uValueValue to convert to a hex string
See also
GetWord(const char *,uint_t,uint_t,uint_t) const and SetWord(const char *,uint_t)

Member Data Documentation

◆ m_Root

Generic Burger::FileINI::Section::m_Root
private

Linked list root for all attached entries.

◆ m_SectionName

String Burger::FileINI::Section::m_SectionName
private

Name of the section.