Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Burger::FileINI Class Reference

Reads and writes INI files. More...

Collaboration diagram for Burger::FileINI:
Collaboration graph
[legend]

Classes

class  Comment
 Untouched text object. More...
 
class  Entry
 Key / Value pair. More...
 
class  Generic
 Base class for INI file line objects. More...
 
class  Section
 INI section chunk. More...
 

Public Member Functions

 FileINI ()
 Initialize an INI file parser.
 
 ~FileINI ()
 Dispose of an INI file parser.
 
uint_t Init (const char *pFilename)
 Initialize the records with a file on disk.
 
uint_t Init (Filename *pFilename)
 Initialize the records with a file on disk.
 
uint_t Init (InputMemoryStream *pInput)
 Initialize the records with an InputMemoryStream.
 
void Shutdown (void)
 Dispose of the contents of the structure.
 
uint_t Save (const char *pFilename) const
 Save a script file to disk.
 
uint_t Save (Filename *pFilename) const
 Save a script file to disk.
 
uint_t Save (OutputMemoryStream *pOutput) const
 Save a script file.
 
SectionAddSection (const char *pSectionName)
 Create a new section and append it to the end of the INI file.
 
SectionFindSection (const char *pSectionName, uint_t bAlwaysCreate=0)
 Find a Section.
 
void DeleteSection (const char *pSectionName)
 Delete a named Section.
 

Static Public Member Functions

static FileININew (void)
 Allocate and initialize a FileINI.
 
static FileININew (const char *pFilename, uint_t bAlwaysCreate=0)
 Create a new pref file record and initialize it with entries from a text file on disk.
 
static FileININew (Filename *pFilename, uint_t bAlwaysCreate=0)
 Create a new pref file record and initialize it with entries from a text file on disk.
 
static FileININew (InputMemoryStream *pInput, uint_t bAlwaysCreate=0)
 Create a new pref file record and initialize it with entries from a text file on disk.
 

Private Member Functions

 FileINI (const FileINI &)=delete
 
FileINIoperator= (const FileINI &)=delete
 
 FileINI (FileINI &&)=delete
 
FileINIoperator= (FileINI &&)=delete
 

Private Attributes

Generic m_Root
 Root entry for a list of sections.
 

Detailed Description

Reads and writes INI files.


This class will read and write out INI text files Care is taken that all comments and extra, non-parsable, data is retained so when the file is modified and written back out, all of the extra data is untouched.

# This is a sample of the contents
# of a legal Windows INI file
// C style comments are okay!
# Section without a name, access by passing "" as the section name
Data = 1
String = "Hello there"
# Section, access with the string "Foobar" (It's case insensitive)
[FOOBAR]
Data = 2
Hi = "Hi"
# Another section with duplicate names
[foobar2]
Data = 2
Float = 3.52
UTF 8 bit string class.
Definition burger.h:14832
See also
Burger::FileXML

Constructor & Destructor Documentation

◆ FileINI() [1/3]

Burger::FileINI::FileINI ( const FileINI & )
privatedelete

◆ FileINI() [2/3]

Burger::FileINI::FileINI ( FileINI && )
privatedelete

◆ FileINI() [3/3]

Burger::FileINI::FileINI ( void )

Initialize an INI file parser.


◆ ~FileINI()

Burger::FileINI::~FileINI ( )

Dispose of an INI file parser.


See also
Shutdown(void)

Member Function Documentation

◆ AddSection()

Burger::FileINI::Section *BURGER_API Burger::FileINI::AddSection ( const char * pSectionName)

Create a new section and append it to the end of the INI file.


Allocate a new Section and name it with pSectionName. Append the new Section at the end of the INI file records

Parameters
pSectionNamePointer to a "C" string of the new section to create
See also
FindSection(const char *,uint_t) or DeleteSection(const char *)

◆ DeleteSection()

void BURGER_API Burger::FileINI::DeleteSection ( const char * pSectionName)

Delete a named Section.


Traverse the linked list for a section that has the requested name and delete it and all data attached to it.

Parameters
pSectionNamePointer to a "C" string of the new section to locate
See also
FindSection(const char *,uint_t) or AddSection(const char *)

◆ FindSection()

Burger::FileINI::Section *BURGER_API Burger::FileINI::FindSection ( const char * pSectionName,
uint_t bAlwaysCreate = 0 )

Find a Section.


Traverse the linked list for a section that has the requested name. Return NULL if the record wasn't found and bAlwaysCreate is zero. If bAlwaysCreate is not zero and the record didn't exist, create one with the requested name.

Parameters
pSectionNamePointer to a "C" string of the new section to locate
bAlwaysCreateTRUE to create the section if one didn't already exist
Returns
Pointer to a Section with the requested name or NULL if not found
See also
DeleteSection(const char *) or AddSection(const char *)

◆ Init() [1/3]

uint_t BURGER_API Burger::FileINI::Init ( const char * pFilename)

Initialize the records with a file on disk.


Purge all records from the class and load in new data from a file on disk.

Parameters
pFilenamePointer to a "C" string of a valid Burgerlib filename
Returns
Zero on success, or non-zero on failure
See also
Init(InputMemoryStream *) or Init(const char *)

◆ Init() [2/3]

uint_t BURGER_API Burger::FileINI::Init ( Filename * pFilename)

Initialize the records with a file on disk.


Purge all records from the class and load in new data from a file on disk.

Parameters
pFilenamePointer to a Filename structure
Returns
Zero on success, or non-zero on failure
See also
Init(InputMemoryStream *) or Init(const char *)

◆ Init() [3/3]

uint_t BURGER_API Burger::FileINI::Init ( InputMemoryStream * pInput)

Initialize the records with an InputMemoryStream.


Purge all records from the class and load in new data from a memory stream

Parameters
pInputPointer to an image of the text file in memory
Returns
Zero on success, or non-zero on failure
See also
Init(Filename *) or Init(const char *)

◆ New() [1/4]

Burger::FileINI *BURGER_API Burger::FileINI::New ( const char * pFilename,
uint_t bAlwaysCreate = 0 )
static

Create a new pref file record and initialize it with entries from a text file on disk.


Open the file and read in the entries into a newly allocated FileINI structure.

Return NULL if the file cannot be opened and the bAlwaysCreate flag is zero

Parameters
pFilenamePointer to a "C" string of a valid Burgerlib filename
bAlwaysCreateTRUE if the file can't be opened, return an empty record instead
Returns
A pointer to an empty FileINI structure or NULL if out of memory
See also
New(InputMemoryStream *,uint_t), New(void) or New(Filename *,uint_t)

◆ New() [2/4]

Burger::FileINI *BURGER_API Burger::FileINI::New ( Filename * pFilename,
uint_t bAlwaysCreate = 0 )
static

Create a new pref file record and initialize it with entries from a text file on disk.


Open the file and read in the entries into a newly allocated FileINI structure.

Return NULL if the file cannot be opened and the bAlwaysCreate flag is zero

Parameters
pFilenamePointer to a Filename record
bAlwaysCreateTRUE if the file can't be opened, return an empty record instead
Returns
A pointer to an empty FileINI structure or NULL if out of memory
See also
New(InputMemoryStream *,uint_t), New(void) or New(const char *,uint_t)

◆ New() [3/4]

Burger::FileINI *BURGER_API Burger::FileINI::New ( InputMemoryStream * pInput,
uint_t bAlwaysCreate = 0 )
static

Create a new pref file record and initialize it with entries from a text file on disk.


Read in the entries from the InputMemoryStream into a newly allocated FileINI structure.

Return NULL if the file cannot be opened and the bAlwaysCreate flag is zero

Parameters
pInputPointer to a InputMemoryStream record that has the text file image
bAlwaysCreateTRUE if the file can't be opened, return an empty record instead
Returns
A pointer to an empty FileINI structure or NULL if out of memory
See also
New(Filename *,uint_t), New(void) or New(const char *,uint_t)

◆ New() [4/4]

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

Allocate and initialize a FileINI.


Returns
A pointer to an empty FileINI structure or NULL if out of memory
See also
New(InputMemoryStream *,uint_t), New(const char *,uint_t) or New(Filename *,uint_t)

◆ operator=() [1/2]

FileINI & Burger::FileINI::operator= ( const FileINI & )
privatedelete

◆ operator=() [2/2]

FileINI & Burger::FileINI::operator= ( FileINI && )
privatedelete

◆ Save() [1/3]

uint_t BURGER_API Burger::FileINI::Save ( const char * pFilename) const

Save a script file to disk.


Serialize the data contained in the entire class as a Windows style INI text file and save it to a file.

Parameters
pFilenamePointer to a Burgerlib Path name
Returns
Zero on success, non zero on error

◆ Save() [2/3]

uint_t BURGER_API Burger::FileINI::Save ( Filename * pFilename) const

Save a script file to disk.


Serialize the data contained in the entire class as a Windows style INI text file and save it to a file.

Parameters
pFilenamePointer to a Filename instance
Returns
Zero on success, non zero on error

◆ Save() [3/3]

uint_t BURGER_API Burger::FileINI::Save ( OutputMemoryStream * pOutput) const

Save a script file.


Serialize the data contained in the entire class as 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

◆ Shutdown()

void BURGER_API Burger::FileINI::Shutdown ( void )

Dispose of the contents of the structure.


Every record is released from memory

Member Data Documentation

◆ m_Root

Generic Burger::FileINI::m_Root
private

Root entry for a list of sections.