Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXXML Class Reference

The XML serializer loads or saves data to xml text file. More...

#include <FXXML.h>

Inheritance diagram for FX::FXXML:
FX::FXParseBuffer FX::FXXMLFile FX::FXXMLString

Public Types

enum  Error {
  ErrOK, ErrEmpty, ErrSave, ErrLoad,
  ErrSpace, ErrEquals, ErrName, ErrString,
  ErrToken, ErrDigit, ErrHexDigit, ErrSemiColon,
  ErrReference, ErrNoMatch, ErrEof
}
 
enum  { CRLF = 0x0001, REFS = 0x0002 }
 
enum  {
  UTF8 = 1, UTF16LE = 2, UTF16BE = 3, UTF32LE = 4,
  UTF32BE = 5
}
 
- Public Types inherited from FX::FXParseBuffer
enum  Direction { Stop = 0, Save = 1, Load = 2 }
 

Public Member Functions

 FXXML ()
 Construct XML serializer.
 
 FXXML (FXchar *buffer, FXuval sz=4096, Direction d=Load)
 Construct XML serializer and open for direction d. More...
 
FXbool open (FXchar *buffer=nullptr, FXuval sz=4096, Direction d=Load)
 Open XML stream for given direction d. More...
 
FXuval size () const
 Return size of parse buffer.
 
Direction direction () const
 Return direction in effect.
 
FXint getLine () const
 Return current line number.
 
FXint getColumn () const
 Return current column number.
 
FXlong getOffset () const
 Return offset from begin of file.
 
Error parse ()
 Parse the file, return error code to indicate success or failure.
 
Error startDocument ()
 Document start.
 
Error startElement (const FXString &tag)
 Element start w/no attributes.
 
Error startElement (const FXString &tag, const FXStringDictionary &atts)
 Element start w/attributes.
 
Error characters (const FXString &text)
 Characters.
 
Error comment (const FXString &text)
 Comment.
 
Error processing (const FXString &target, const FXString &text)
 Processing instruction.
 
Error endElement (const FXString &tag)
 Element end.
 
Error endDocument ()
 Document end.
 
FXbool close ()
 Close stream and delete buffer, if owned.
 
virtual ~FXXML ()
 Close XML stream and clean up.
 
- Public Member Functions inherited from FX::FXParseBuffer
 FXParseBuffer ()
 Initialize parse buffer to empty.
 
 FXParseBuffer (FXchar *buffer, FXuval sz=4096, Direction d=Load)
 Initialize parse buffer with given size and direction. More...
 
FXbool open (FXchar *buffer=nullptr, FXuval sz=4096, Direction d=Load)
 Open parse buffer with given size and direction.
 
Direction direction () const
 Return current direction.
 
FXuval size () const
 Return current buffer size.
 
virtual FXival fill (FXival count)
 Read at least count bytes into buffer; return bytes available, or -1 for error.
 
virtual FXival flush (FXival count)
 Write at least count bytes from buffer; return space available, or -1 for error.
 
FXbool close ()
 Close parse buffer.
 
virtual ~FXParseBuffer ()
 Clean up and close buffer.
 

Static Public Member Functions

static const FXchar * getError (Error err)
 Returns error code for given error.
 
static FXbool decode (FXString &dst, const FXString &src, FXuint flags=CRLF|REFS)
 Decode escaped special characters from XML stream.
 
static FXbool encode (FXString &dst, const FXString &src, FXuint flags=CRLF|REFS)
 Encode special characters for inclusion into XML stream.
 

Public Attributes

FXCallback< Error() > startDocumentCB
 Called when start of document is recognized.
 
FXCallback< Error(const FXString &, const FXStringDictionary &) > startElementCB
 Called when start of element is recognized.
 
FXCallback< Error(const FXString &) > charactersCB
 Called to pass batch of decoded characters.
 
FXCallback< Error(const FXString &) > commentCB
 Called to pass comment string.
 
FXCallback< Error(const FXString &, const FXString &) > processingCB
 Called to pass processing instruction.
 
FXCallback< Error(const FXString &) > endElementCB
 Called when end of element is recognized.
 
FXCallback< Error() > endDocumentCB
 Called when end of document is recognized.
 

Protected Attributes

FXlong offset
 
Element * current
 
FXint column
 
FXint line
 
FXString vers
 
FXuint enc
 
- Protected Attributes inherited from FX::FXParseBuffer
FXchar * begptr
 
FXchar * endptr
 
FXchar * wptr
 
FXchar * rptr
 
FXchar * sptr
 
Direction dir
 

Additional Inherited Members

- Protected Member Functions inherited from FX::FXParseBuffer
FXbool need (FXival count)
 
FXbool emit (FXchar ch, FXint count)
 
FXbool emit (const FXchar *str, FXint count)
 

Detailed Description

The XML serializer loads or saves data to xml text file.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
REFS 

CRLF, LFCR, CR, LF map to LF.

◆ anonymous enum

anonymous enum
Enumerator
UTF16LE 

UTF8 encoded.

UTF16BE 

Little endian UTF16 encoded.

UTF32LE 

Big endian UTF16 encoded.

UTF32BE 

Little endian UTF32 encoded.

◆ Error

Enumerator
ErrEmpty 

No errors.

ErrSave 

No data loaded.

ErrLoad 

Unable to save.

ErrSpace 

Unable to load.

ErrEquals 

Expected space.

ErrName 

Expected equals sign '='.

ErrString 

Expected name.

ErrToken 

Expected string.

ErrDigit 

Illegal token.

ErrHexDigit 

Expected digit.

ErrSemiColon 

Expected hex digit.

ErrReference 

Expected semicolon.

ErrNoMatch 

Unknown reference.

ErrEof 

Start and end tag not matching.

Unexpected end of file

Constructor & Destructor Documentation

◆ FXXML()

FX::FXXML::FXXML ( FXchar *  buffer,
FXuval  sz = 4096,
Direction  d = Load 
)

Construct XML serializer and open for direction d.

Use given buffer data of size sz, or allocate a local buffer.

Member Function Documentation

◆ open()

FXbool FX::FXXML::open ( FXchar *  buffer = nullptr,
FXuval  sz = 4096,
Direction  d = Load 
)

Open XML stream for given direction d.

Use given buffer data of size sz, or allocate a local buffer.


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

Copyright © 1997-2022 Jeroen van der Zijp