PixelLightAPI  .
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
PLCore::XmlBase Class Reference

Abstract XML base class. More...

#include <XmlBase.h>

Inheritance diagram for PLCore::XmlBase:
Inheritance graph
[legend]

List of all members.

Classes

struct  Cursor
 Internal structure for tracking location of items in the XML file. More...

Public Types

enum  {
  NoError, Error, ErrorOpeningFile, ErrorParsingElement,
  ErrorFailedToReadElementName, ErrorReadingElementValue, ErrorReadingAttributes, ErrorParsingEmpty,
  ErrorReadingEndTag, ErrorParsingUnknown, ErrorParsingComment, ErrorParsingDeclaration,
  ErrorDocumentEmpty, ErrorEmbeddedNull, ErrorParsingCData, ErrorDocumentTopOnly,
  ErrorStringCount
}
 Error codes. More...
enum  EQueryResult { Success, NoAttribute, WrongType }
 Only used by 'Attribute::Query'-functions. More...
enum  EEncoding { EncodingUnknown, EncodingUTF8, EncodingLegacy }
 Used by the parsing routines. More...

Public Member Functions

virtual PLCORE_API ~XmlBase ()
 Destructor.
int GetRow () const
 Return the row position, in the original source file, of this node or attribute.
int GetColumn () const
 Return the column position, in the original source file, of this node or attribute.
void * GetUserData () const
 Returns the user data.
void SetUserData (void *pUser)
 Sets the user data.
virtual bool Save (File &cFile, uint32 nDepth=0)=0
 Save function.
virtual String ToString (uint32 nDepth=0) const =0
 Output as string function.
virtual const char * Parse (const char *pszData, XmlParsingData *pData=nullptr, EEncoding nEncoding=EncodingUnknown)=0
 Parse the given null terminated block of XML data.

Static Public Member Functions

static bool IsWhiteSpaceCondensed ()
 Return the current white space setting.
static void SetCondenseWhiteSpace (bool bCondense)
 Set white space handling.

Protected Member Functions

 XmlBase ()
 Default constructor.

Static Protected Member Functions

static const char * SkipWhiteSpace (const char *pszData, EEncoding nEncoding)
static bool IsWhiteSpace (char c)
static bool IsWhiteSpace (int c)
static const char * ReadName (const char *pszData, String &sName, EEncoding nEncoding)
 Reads an XML name into the string provided.
static const char * ReadText (const char *pszData, String &sText, bool bTrimWhiteSpace, const char *pszEndTag, bool bCaseInsensitive, EEncoding nEncoding)
 Reads text.
static const char * GetEntity (const char *pszData, char *pszValue, int &nLength, EEncoding nEncoding)
static const char * GetChar (const char *pszData, char *pszValue, int &nLength, EEncoding nEncoding)
static bool StringEqual (const char *pszData, const char *pszTag, bool bIgnoreCase, EEncoding nEncoding)
static int IsAlpha (unsigned char nByte)
static int IsAlphaNum (unsigned char nByte)
static int ToLower (int nValue, EEncoding nEncoding)
static void ConvertUTF32ToUTF8 (unsigned long nInput, char *pszOutput, int &nLength)
static void EncodeString (const String &sInString, String &sOutString)

Protected Attributes

void * m_pUserData
Cursor m_cCursor

Static Protected Attributes

static const unsigned char UTF_LEAD_0 = 0xefU
static const unsigned char UTF_LEAD_1 = 0xbbU
static const unsigned char UTF_LEAD_2 = 0xbfU

Detailed Description

Abstract XML base class.

Remarks:
'XmlBase' is a base class for every class of the XML parser. It does little except to establish that parser classes can be printed and provide some utility functions. In XML, the document and elements can contain other elements and other types of nodes.
*    A document can contain: Element (container or leaf)
*                            Comment (leaf)
*                            Unknown (leaf)
*                            Declaration (leaf)
*
*    An element can contain: Element (container or leaf)
*                            Text (leaf)
*                            Attributes (not on tree)
*                            Comment (leaf)
*                            Unknown (leaf)
*
*    A declaration contains: Attributes (not on tree)
*    

Member Enumeration Documentation

anonymous enum

Error codes.

Enumerator:
NoError 

No error

Error 

Error

ErrorOpeningFile 

Error opening file

ErrorParsingElement 

Error parsing element

ErrorFailedToReadElementName 

Error failed to read element name

ErrorReadingElementValue 

Error reading element value

ErrorReadingAttributes 

Error reading attributes

ErrorParsingEmpty 

Error parsing empty

ErrorReadingEndTag 

Error reading end tag

ErrorParsingUnknown 

Error parsing unknown

ErrorParsingComment 

Error parsing comment

ErrorParsingDeclaration 

Error parsing declaration

ErrorDocumentEmpty 

Error document empty

ErrorEmbeddedNull 

Error embedded null

ErrorParsingCData 

Error parsing CDATA

ErrorDocumentTopOnly 

Error document top only

ErrorStringCount 

Error string count

Only used by 'Attribute::Query'-functions.

Enumerator:
Success 

All went fine

NoAttribute 

Attribute does not exist

WrongType 

Invalid attribute type

Used by the parsing routines.

Enumerator:
EncodingUnknown 

Unknown encoding (default)

EncodingUTF8 

UTF8 encoding

EncodingLegacy 

Legacy encoding


Constructor & Destructor Documentation

virtual PLCORE_API PLCore::XmlBase::~XmlBase ( ) [virtual]

Destructor.

PLCore::XmlBase::XmlBase ( ) [protected]

Default constructor.


Member Function Documentation

bool PLCore::XmlBase::IsWhiteSpaceCondensed ( ) [inline, static]

Return the current white space setting.

Returns:
'true' if white space condensed is set, else 'false'
Remarks:
The world does not agree on whether white space should be kept or not. In order to make everyone happy, these global, static functions are provided to set whether or not the parser will condense all white space into a single space or not. The default is to condense. Note changing this values is not thread safe.
void PLCore::XmlBase::SetCondenseWhiteSpace ( bool  bCondense) [inline, static]

Set white space handling.

Parameters:
[in]bCondense'true' if white space condensed is set, else 'false'
See also:
int PLCore::XmlBase::GetRow ( ) const [inline]

Return the row position, in the original source file, of this node or attribute.

Returns:
Row position
Remarks:
The row and column are 1-based. (That is the first row and first column is 1, 1). If the returns values are 0 or less, then the parser does not have a row and column value. Generally, the row and column value will be set when the 'XmlDocument::Load()', 'XmlDocument::Load()', or any 'XmlNode::Parse()' is called. It will NOT be set when the DOM was created from operator '>>'. The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document. There is a minor performance cost to computing the row and column. Computation can be disabled if 'XmlDocument::SetTabSize()' is called with 0 as the value.
See also:
int PLCore::XmlBase::GetColumn ( ) const [inline]

Return the column position, in the original source file, of this node or attribute.

Returns:
Column position
See also:
void * PLCore::XmlBase::GetUserData ( ) const [inline]

Returns the user data.

Returns:
User data, can be a null pointer
Note:
  • The user data is not used internally, it's really user only :)
void PLCore::XmlBase::SetUserData ( void *  pUser) [inline]

Sets the user data.

Parameters:
[in]pUserUser data, can be a null pointer
See also:
virtual bool PLCore::XmlBase::Save ( File cFile,
uint32  nDepth = 0 
) [pure virtual]

Save function.

Parameters:
[out]cFileFile to write in, must be opened and writable
[in]nDepthCurrent depth
Returns:
'true' if all went fine, else 'false'

Implemented in PLCore::XmlElement, PLCore::XmlDocument, PLCore::XmlAttribute, PLCore::XmlDeclaration, PLCore::XmlText, PLCore::XmlComment, and PLCore::XmlUnknown.

virtual String PLCore::XmlBase::ToString ( uint32  nDepth = 0) const [pure virtual]

Output as string function.

Parameters:
[in]nDepthCurrent depth
Returns:
String containing the XML

Implemented in PLCore::XmlElement, PLCore::XmlDocument, PLCore::XmlAttribute, PLCore::XmlDeclaration, PLCore::XmlText, PLCore::XmlComment, and PLCore::XmlUnknown.

virtual const char* PLCore::XmlBase::Parse ( const char *  pszData,
XmlParsingData pData = nullptr,
EEncoding  nEncoding = EncodingUnknown 
) [pure virtual]

Parse the given null terminated block of XML data.

Parameters:
[in]pszDataParsing data, if a null pointer, an error will be returned
[in]pDataParsing data, can be a null pointer
[in]nEncodingEncoding
Returns:
The pointer to the parameter 'pszData' if all went fine, else a null pointer
Remarks:
Passing in an encoding to this method (either 'EncodingLegacy' or 'EncodingUTF8' will force the parser to use that encoding, regardless of what the parser might otherwise try to detect.

Implemented in PLCore::XmlElement, PLCore::XmlDocument, PLCore::XmlAttribute, PLCore::XmlDeclaration, PLCore::XmlText, PLCore::XmlComment, and PLCore::XmlUnknown.

static const char* PLCore::XmlBase::SkipWhiteSpace ( const char *  pszData,
EEncoding  nEncoding 
) [static, protected]
static bool PLCore::XmlBase::IsWhiteSpace ( char  c) [static, protected]
static bool PLCore::XmlBase::IsWhiteSpace ( int  c) [static, protected]
static const char* PLCore::XmlBase::ReadName ( const char *  pszData,
String sName,
EEncoding  nEncoding 
) [static, protected]

Reads an XML name into the string provided.

Parameters:
[in]pszDataData
[out]sNameRead name
[in]nEncodingEncoding
Returns:
Returns a pointer just past the last character of the name, or 0 if the function has an error
static const char* PLCore::XmlBase::ReadText ( const char *  pszData,
String sText,
bool  bTrimWhiteSpace,
const char *  pszEndTag,
bool  bCaseInsensitive,
EEncoding  nEncoding 
) [static, protected]

Reads text.

Parameters:
[in]pszDataWhere to start
[out]sTextThe string read
[in]bTrimWhiteSpaceWhether to keep the white space
[in]pszEndTagWhat ends this text
[in]bCaseInsensitiveWhether to ignore case in the end tag
[in]nEncodingThe current encoding
Returns:
Returns a pointer past the given end tag
Note:
  • Wickedly complex options, but it keeps the (sensitive) code in one place.
static const char* PLCore::XmlBase::GetEntity ( const char *  pszData,
char *  pszValue,
int &  nLength,
EEncoding  nEncoding 
) [static, protected]
static const char* PLCore::XmlBase::GetChar ( const char *  pszData,
char *  pszValue,
int &  nLength,
EEncoding  nEncoding 
) [static, protected]
static bool PLCore::XmlBase::StringEqual ( const char *  pszData,
const char *  pszTag,
bool  bIgnoreCase,
EEncoding  nEncoding 
) [static, protected]
static int PLCore::XmlBase::IsAlpha ( unsigned char  nByte) [static, protected]
static int PLCore::XmlBase::IsAlphaNum ( unsigned char  nByte) [static, protected]
static int PLCore::XmlBase::ToLower ( int  nValue,
EEncoding  nEncoding 
) [static, protected]
static void PLCore::XmlBase::ConvertUTF32ToUTF8 ( unsigned long  nInput,
char *  pszOutput,
int &  nLength 
) [static, protected]
static void PLCore::XmlBase::EncodeString ( const String sInString,
String sOutString 
) [static, protected]

Member Data Documentation

const unsigned char PLCore::XmlBase::UTF_LEAD_0 = 0xefU [static, protected]
const unsigned char PLCore::XmlBase::UTF_LEAD_1 = 0xbbU [static, protected]
const unsigned char PLCore::XmlBase::UTF_LEAD_2 = 0xbfU [static, protected]
void* PLCore::XmlBase::m_pUserData [protected]

User data, can be a null pointer


The documentation for this class was generated from the following files:


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:29
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported