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::FXXMLFile

Public Types

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

Public Member Functions

 FXXML ()
 Construct XML serializer.
 
 FXXML (FXchar *data, FXuval sz=4096, Direction d=Load)
 Construct XML serializer and open for direction d. More...
 
FXbool open (FXchar *data=NULL, FXuval sz=4096, Direction d=Load)
 Open XML stream for given direction d. More...
 
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.
 
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.
 
virtual FXbool fill ()
 Fill buffer from file. More...
 
virtual FXbool flush ()
 Flush buffer to file. More...
 
virtual FXbool close ()
 Close stream and delete buffer, if owned.
 
virtual ~FXXML ()
 Close XML stream and clean up.
 

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

FXchar * begptr
 
FXchar * endptr
 
FXchar * sptr
 
FXchar * rptr
 
FXchar * wptr
 
Element * current
 
FXint column
 
FXint line
 
Direction dir
 
FXString vers
 
FXuint enc
 
FXbool owns
 

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.

◆ Direction

Enumerator
Save 

Not active.

Load 

Save to device.

◆ 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 *  data,
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

◆ fill()

virtual FXbool FX::FXXML::fill ( )
virtual

Fill buffer from file.

Return false if not open for reading, or no input left to read.

Reimplemented in FX::FXXMLFile.

◆ flush()

virtual FXbool FX::FXXML::flush ( )
virtual

Flush buffer to file.

Return false if not open for writing, or if no space left to write.

Reimplemented in FX::FXXMLFile.

◆ open()

FXbool FX::FXXML::open ( FXchar *  data = NULL,
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-2018 Jeroen van der Zijp