ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ost::XMLParser Class Referenceabstract

XML streaming parser. More...

#include <xml.h>

Protected Member Functions

 XMLParser (unsigned size=8192)
 Create xml parser. More...
 
virtual ~XMLParser ()
 Destroy xml parser. More...
 
virtual void comment (const caddr_t text, size_t size)
 Virtual to receive embedded comments in XML document being parsed. More...
 
virtual void characters (const caddr_t text, size_t size)
 Virtual to receive character text extracted from the document. More...
 
virtual void startDocument (void)
 Notify start of document event. More...
 
virtual void endDocument (void)
 Notify end of document event. More...
 
virtual void startElement (const caddr_t name, caddr_t *attr)=0
 Notify start of an element in the document. More...
 
virtual void endElement (const caddr_t name)=0
 Notify end of an element in the document. More...
 
bool partial (const char *address, size_t size)
 Parse a chunk of data and return parser completion flag. More...
 
bool parse (const char *cp)
 Parse a stream buffer and return parser document completion flag. More...
 
bool parse (FILE *file)
 Parse a file buffer and return parser document completion flag. More...
 
bool end (void) const
 End of document check. More...
 

Private Types

enum  {
  TAG , CDATA , COMMENT , DTD ,
  AMP , NONE , END
}
 

Private Member Functions

__LOCAL bool parseTag (void)
 
__LOCAL void putBuffer (char c)
 
__LOCAL void clearBuffer (void)
 
 __DELETE_COPY (XMLParser)
 

Private Attributes

int ecount
 
int dcount
 
enum ost::XMLParser:: { ... }  state
 
char * buffer
 
unsigned bufpos
 
unsigned bufsize
 

Detailed Description

XML streaming parser.

This class implements a basic XML stream parser that can be used to examine an XML resource thru virtual I/O methods. This class must be derived into one that can implement the physical I/O required to parse actual data. A mixer class using XMLParser and tcpstream would be one example of this. This can also be used to parse xml content in memory buffers easily. This parser is only concerned with well-formedness, and does not perform validation.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 45 of file xml.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
TAG 
CDATA 
COMMENT 
DTD 
AMP 
NONE 
END 

Definition at line 49 of file xml.h.

Constructor & Destructor Documentation

◆ XMLParser()

ost::XMLParser::XMLParser ( unsigned  size = 8192)
protected

Create xml parser.

Parameters
sizeof XML data buffer.

Definition at line 35 of file xml.cpp.

References buffer, bufpos, bufsize, dcount, ecount, NONE, and state.

◆ ~XMLParser()

ost::XMLParser::~XMLParser ( )
protectedvirtual

Destroy xml parser.

Definition at line 44 of file xml.cpp.

References buffer.

Member Function Documentation

◆ __DELETE_COPY()

ost::XMLParser::__DELETE_COPY ( XMLParser  )
private

◆ characters()

void ost::XMLParser::characters ( const caddr_t  text,
size_t  size 
)
protectedvirtual

Virtual to receive character text extracted from the document.

Parameters
textreceived.
sizeof text received.

Definition at line 556 of file xml.cpp.

Referenced by clearBuffer(), parse(), partial(), and putBuffer().

◆ clearBuffer()

void ost::XMLParser::clearBuffer ( void  )
private

Definition at line 62 of file xml.cpp.

References buffer, bufpos, caddr_t, characters(), and ecount.

Referenced by parse(), and partial().

Here is the call graph for this function:

◆ comment()

void ost::XMLParser::comment ( const caddr_t  text,
size_t  size 
)
protectedvirtual

Virtual to receive embedded comments in XML document being parsed.

Parameters
textreceived.
sizeof text received.

Definition at line 552 of file xml.cpp.

Referenced by parse(), and partial().

◆ end()

bool ost::XMLParser::end ( void  ) const
inlineprotected

End of document check.

Returns
true if end of document.

Definition at line 144 of file xml.h.

Referenced by parseTag().

◆ endDocument()

void ost::XMLParser::endDocument ( void  )
protectedvirtual

Notify end of document event.

Definition at line 548 of file xml.cpp.

Referenced by parseTag().

◆ endElement()

virtual void ost::XMLParser::endElement ( const caddr_t  name)
protectedpure virtual

Notify end of an element in the document.

Parameters
nameof element ending.

Referenced by parseTag().

◆ parse() [1/2]

bool ost::XMLParser::parse ( const char *  cp)
protected

Parse a stream buffer and return parser document completion flag.

This is used to scan a stream buffer for a complete XML document. The stream is scanned until the document is complete or EOF. Multiple XML document instances can be scanned from a continues XML streaming source.

Parameters
streambuffer to parse.
Returns
true if parse complete, false if invalid or EOF.

Definition at line 182 of file xml.cpp.

References AMP, buffer, bufpos, bufsize, caddr_t, CDATA, ch, characters(), clearBuffer(), COMMENT, comment(), dcount, DTD, ecount, END, ucommon::eq(), isElement(), NONE, parseTag(), putBuffer(), state, and TAG.

Here is the call graph for this function:

◆ parse() [2/2]

bool ost::XMLParser::parse ( FILE *  file)
protected

Parse a file buffer and return parser document completion flag.

This is used to scan a file buffer for a complete XML document. The file is scanned until the document is complete or EOF. Multiple XML document instances can be scanned from a continues XML streaming source.

Parameters
filebuffer to parse.
Returns
true if parse complete, false if invalid or EOF.

Definition at line 69 of file xml.cpp.

References AMP, buffer, bufpos, bufsize, caddr_t, CDATA, ch, characters(), clearBuffer(), COMMENT, comment(), dcount, DTD, ecount, END, EOF, ucommon::eq(), isElement(), NONE, parseTag(), putBuffer(), state, and TAG.

Here is the call graph for this function:

◆ parseTag()

bool ost::XMLParser::parseTag ( void  )
private

Definition at line 399 of file xml.cpp.

References buffer, bufpos, caddr_t, ecount, END, end(), endDocument(), endElement(), isElement(), startDocument(), startElement(), state, and strnicmp().

Referenced by parse(), and partial().

Here is the call graph for this function:

◆ partial()

bool ost::XMLParser::partial ( const char *  address,
size_t  size 
)
protected

Parse a chunk of data and return parser completion flag.

This is used to externally drive data into the XML parser. The return status can be used to determine when a document has been fully parsed. This can be called multiple times to push stream data into the parser.

Parameters
addressof data to parse.
sizeof data to parse.

Definition at line 294 of file xml.cpp.

References AMP, buffer, bufpos, bufsize, caddr_t, CDATA, characters(), clearBuffer(), COMMENT, comment(), dcount, DTD, ecount, END, ucommon::eq(), isElement(), NONE, parseTag(), putBuffer(), state, and TAG.

Here is the call graph for this function:

◆ putBuffer()

void ost::XMLParser::putBuffer ( char  c)
private

Definition at line 52 of file xml.cpp.

References buffer, bufpos, bufsize, caddr_t, characters(), and ecount.

Referenced by parse(), and partial().

Here is the call graph for this function:

◆ startDocument()

void ost::XMLParser::startDocument ( void  )
protectedvirtual

Notify start of document event.

Definition at line 544 of file xml.cpp.

Referenced by parseTag().

◆ startElement()

virtual void ost::XMLParser::startElement ( const caddr_t  name,
caddr_t attr 
)
protectedpure virtual

Notify start of an element in the document.

Parameters
nameof element found.
attrlist of attributes extracted.

Referenced by parseTag().

Member Data Documentation

◆ buffer

char* ost::XMLParser::buffer
private

Definition at line 50 of file xml.h.

Referenced by clearBuffer(), parse(), parseTag(), partial(), putBuffer(), XMLParser(), and ~XMLParser().

◆ bufpos

unsigned ost::XMLParser::bufpos
private

Definition at line 51 of file xml.h.

Referenced by clearBuffer(), parse(), parseTag(), partial(), putBuffer(), and XMLParser().

◆ bufsize

unsigned ost::XMLParser::bufsize
private

Definition at line 51 of file xml.h.

Referenced by parse(), partial(), putBuffer(), and XMLParser().

◆ dcount

int ost::XMLParser::dcount
private

Definition at line 48 of file xml.h.

Referenced by parse(), partial(), and XMLParser().

◆ ecount

int ost::XMLParser::ecount
private

Definition at line 48 of file xml.h.

Referenced by clearBuffer(), parse(), parseTag(), partial(), putBuffer(), and XMLParser().

◆ 

enum { ... } ost::XMLParser::state

Referenced by parse(), parseTag(), partial(), and XMLParser().


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