Reads and writes XML files. More...
Classes | |
class | Attribute |
XML Attribute key / value pair. More... | |
class | CData |
Untouched text object intended for application parsing. More... | |
class | Comment |
Comment text object. More... | |
class | Declaration |
XML Declaration object. More... | |
class | Element |
XML Element object. More... | |
class | Generic |
Base class for XML file objects. More... | |
class | RawText |
Raw text object. More... | |
class | Root |
Linked list root object. More... | |
Public Member Functions | |
FileXML () | |
Initialize an XML file parser. | |
~FileXML () | |
Dispose of an XML 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 (OutputMemoryStream *pOutput) const |
Save an XML file. | |
uint_t | GetUTF8ByteMark (void) const |
Get the flag for writing a UTF8 byte mark. | |
void | SetUTF8ByteMark (uint_t bUTF8ByteMark) |
Set the flag for writing a UTF8 byte mark. | |
Declaration * | FindDeclaration (uint_t bAlwaysCreate=0) |
Find the XML declaration. | |
Declaration * | AddDeclaration (float fVersion=1.0f, const char *pEncoding=0, uint_t bStandalone=2) |
Add an XML declaration record. | |
void | DeleteDeclaration (void) |
Delete the XML declaration record(s) | |
Root * | GetRoot (void) |
Return the root object. | |
const Root * | GetRoot (void) const |
Return the const root object. | |
const Element * | FindElement (const char *pElementName) const |
Find a named XML Element. | |
Element * | FindElement (const char *pElementName, uint_t bAlwaysCreate=0) |
Find a named XML Element. | |
Element * | AddElement (const char *pElementName) |
Add a new Element record. | |
void | DeleteElement (const char *pElementName) |
Delete an Element record. | |
void | DeleteElements (const char *pElementName) |
Delete all Element records with this name. | |
Element * | GetFirstElement (void) const |
Return the pointer to the first Element object. | |
Generic * | GetFirstItem (void) const |
Return the pointer to the first object. | |
Static Public Member Functions | |
static FileXML * | New (void) |
Allocate and initialize a FileXML. | |
static FileXML * | New (const char *pFilename, uint_t bAlwaysCreate=0) |
Create a new XML file class and initialize it with entries from a text file on disk. | |
static FileXML * | New (Filename *pFilename, uint_t bAlwaysCreate=0) |
Create a new XML file class and initialize it with entries from a text file on disk. | |
static FileXML * | New (InputMemoryStream *pInput, uint_t bAlwaysCreate=0) |
Create a new XML file class and initialize it with entries from a text file in a memory stream. | |
static uint_t | ReadXMLName (String *pOutput, InputMemoryStream *pInput) |
Extract an XML label from an input stream. | |
static uint_t | ReadXMLText (String *pOutput, InputMemoryStream *pInput) |
Extract a XML text from an input stream. | |
static uint_t | SaveXMLString (OutputMemoryStream *pOutput, const char *pInput) |
Output a string in XML encoding. | |
static uint_t | DecodeXMLString (String *pInput) |
Decode a string using XML encoding. | |
Private Member Functions | |
FileXML (const FileXML &)=delete | |
FileXML & | operator= (const FileXML &)=delete |
FileXML (FileXML &&)=delete | |
FileXML & | operator= (FileXML &&)=delete |
Private Attributes | |
Root | m_Root |
Root entry for a list of XML objects. | |
uint_t | m_bUTF8ByteMark |
TRUE if the UTF-8 byte mark should be emitted on write. | |
Reads and writes XML files.
This class will read and write out XML text files
To read the above XML file, here's some sample code.
|
privatedelete |
|
privatedelete |
Burger::FileXML::FileXML | ( | void | ) |
Initialize an XML file parser.
XML Files default with Byte Order Marks disabled.
Burger::FileXML::~FileXML | ( | ) |
Dispose of an XML file parser.
Release all objects.
Calling Shutdown() performs this action manually.
Burger::FileXML::Declaration *BURGER_API Burger::FileXML::AddDeclaration | ( | float | fVersion = 1.0f, |
const char * | pEncoding = 0, | ||
uint_t | bStandalone = 2 ) |
Add an XML declaration record.
Traverse the linked list for an XML declaration and if one exists, update it. Otherwise, create a new record and place it as the first record in the XML file
|
inline |
Add a new Element record.
Create a new Element and place it as the last record in the XML file.
pElementName | Pointer to a "C" string to the element to search for. |
|
static |
Decode a string using XML encoding.
XML files use certain characters for the file format. To use these characters as text, they need to be encoded. This function will take a text string encoded in XML format and decode it to a UTF-8 string.
ASCII | Code |
---|---|
& | & |
' | ' |
" | " |
> | > |
< | < |
\n | |
美 | 美 |
pInput | Pointer to a String to convert |
|
inline |
Delete the XML declaration record(s)
Traverse the linked list for a XML declaration(s) and dispose of them.
|
inline |
Delete an Element record.
Traverse the linked list for the first Element with the supplied name and dispose of it. It will stop after the first deletion. If there are multiple records with the same name, the duplicates will remain.
pElementName | Pointer to a "C" string to the element to search for. |
|
inline |
Burger::FileXML::Declaration *BURGER_API Burger::FileXML::FindDeclaration | ( | uint_t | bAlwaysCreate = 0 | ) |
Find the XML declaration.
Traverse the linked list for an XML declaration. 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.
bAlwaysCreate | TRUE to create the section if one didn't already exist |
|
inline |
Find a named XML Element.
Traverse the linked list for an XML Element record with the matching name using a case sensitive search. Return NULL if the record wasn't found.
pElementName | Pointer to a "C" string to the element to search for. |
|
inline |
Find a named XML Element.
Traverse the linked list for an XML Element record with the matching name using a case sensitive search. 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.
pElementName | Pointer to a "C" string to the element to search for. |
bAlwaysCreate | TRUE to create the section if one didn't already exist |
|
inline |
|
inline |
Return the pointer to the first object.
Return the first object in the XML file. If the file is empty, return NULL
|
inline |
Return the root object.
Return the root object that contains all objects in an XML file for manual parsing.
|
inline |
Return the const root object.
Return the root object that contains all objects in an XML file for manual parsing.
|
inline |
uint_t BURGER_API Burger::FileXML::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 using a Burgerlib formatted filename.
pFilename | Pointer to a "C" string of a valid Burgerlib filename |
uint_t BURGER_API Burger::FileXML::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.
pFilename | Pointer to a Filename structure |
uint_t BURGER_API Burger::FileXML::Init | ( | InputMemoryStream * | pInput | ) |
Initialize the records with an InputMemoryStream.
Purge all records from the class and load in new data from a memory stream
pInput | Pointer to an image of the XML text file in memory |
|
static |
Create a new XML file class and initialize it with entries from a text file on disk.
Open the file and read in the entries into a newly allocated FileXML structure.
Return NULL if the file cannot be opened and the bAlwaysCreate flag is zero
pFilename | Pointer to a "C" string of a valid Burgerlib filename |
bAlwaysCreate | TRUE if the file can't be opened, return an empty record instead |
|
static |
Create a new XML file class and initialize it with entries from a text file on disk.
Open the file and read in the entries into a newly allocated FileXML structure.
Return NULL if the file cannot be opened and the bAlwaysCreate flag is zero
|
static |
Create a new XML file class and initialize it with entries from a text file in a memory stream.
Read in the entries from the InputMemoryStream into a newly allocated FileXML structure.
Return NULL if the text stream cannot be parsed and the bAlwaysCreate flag is zero
pInput | Pointer to a InputMemoryStream record that has the text file image |
bAlwaysCreate | TRUE if the file can't be parsed, return an empty record instead |
|
static |
Allocate and initialize a FileXML.
|
static |
Extract an XML label from an input stream.
Using XML rules, extract a string from the input stream and store it in the output string.
The first character must be a letter, an underscore or a high ASCII character, followed by alphanumeric, high ASCII, underscores, '-', '.' and ':'
pOutput | Pointer to a String to contain the output |
pInput | Pointer to an input stream that's pointing to the start of the label |
|
static |
Extract a XML text from an input stream.
Extract a quoted string from the input stream.
pOutput | Pointer to a String to contain the output |
pInput | Pointer to an input stream that's pointing to the start of the label |
uint_t BURGER_API Burger::FileXML::Save | ( | OutputMemoryStream * | pOutput | ) | const |
Save an XML file.
Serialize the data contained in the entire class as an XML text file.
pOutput | Output string to store the UTF-8 file image of the data |
|
static |
Output a string in XML encoding.
XML files use certain characters for the file format. To use these characters as text, they need to be encoded. This function will take a text string and output it in XML format.
ASCII | Code |
---|---|
& | & |
' | ' |
" | " |
> | > |
< | < |
pOutput | Pointer to a String to contain the output |
pInput | Pointer to an input stream that's pointing to the start of the label |
|
inline |
void BURGER_API Burger::FileXML::Shutdown | ( | void | ) |
Dispose of the contents of the structure.
Every record is released from memory and the Byte Order Mark flag is cleared
|
private |
TRUE if the UTF-8 byte mark should be emitted on write.