C++ Wrapper for expat XML parsers.
|
|
| mootExpatParser (size_t bufsize=8192, const std::string &encoding="") |
|
virtual void | setEncoding (const std::string &encoding="") |
|
virtual void | reset (void) |
|
virtual | ~mootExpatParser (void) |
|
|
virtual void | from_mstream (mootio::mistream *mistreamp, bool autoclose=false) |
|
virtual void | from_mstream (mootio::mistream &mistream, bool autoclose=false) |
|
virtual void | from_filename (const char *filename) |
|
virtual void | from_file (FILE *file) |
|
virtual void | from_fd (int fd) |
|
virtual void | from_buffer (const void *buf, size_t len) |
|
virtual void | from_string (const char *s) |
|
virtual void | from_cxxstream (std::istream &is) |
|
virtual void | close (void) |
|
|
virtual bool | parse_check (void) |
|
bool | parse_filename (const std::string &filename) |
|
bool | parse_file (FILE *infile=stdin, const std::string &in_name="") |
|
bool | parse_buffer (const char *buf, size_t buflen) |
|
bool | parse_all (mootio::mistream *in=__null) |
|
bool | parse_chunk (int &nbytes, int &is_final, mootio::mistream *in=__null) |
|
|
virtual void | context_dump (FILE *tofile=__null) |
|
virtual std::string | context_string (void) |
|
virtual void | carp (const char *fmt,...) |
|
virtual void | xpcarp (const char *fmt,...) |
|
long int | line_number (void) |
|
int | column_number (void) |
|
long | byte_offset (void) |
|
int | byte_count (void) |
|
|
virtual void | XmlDeclHandler (const XML_Char *version, const XML_Char *encoding, int standalone) |
|
virtual void | StartElementHandler (const char *el, const char **attr) |
|
virtual void | EndElementHandler (const char *el) |
|
virtual void | CharacterDataHandler (const XML_Char *s, int len) |
|
virtual void | ProcessingInstructionHandler (const XML_Char *s, const XML_Char *target, const XML_Char *data) |
|
virtual void | CommentHandler (const XML_Char *s) |
|
virtual void | StartCdataSectionHandler (void) |
|
virtual void | EndCdataSectionHandler (void) |
|
virtual void | DefaultHandler (const XML_Char *s, int len) |
|
|
|
static void | _xp_XmlDeclHandler (mootExpatParser *mp, const XML_Char *version, const XML_Char *encoding, int standalone) |
|
static void | _xp_StartElementHandler (mootExpatParser *mp, const char *el, const char **attr) |
|
static void | _xp_EndElementHandler (mootExpatParser *mp, const char *el) |
|
static void | _xp_CharacterDataHandler (mootExpatParser *mp, const XML_Char *s, int len) |
|
static void | _xp_CommentHandler (mootExpatParser *mp, const XML_Char *s) |
|
static void | _xp_DefaultHandler (mootExpatParser *mp, const XML_Char *s, int len) |
|
◆ mootExpatParser()
moot::mootExpatParser::mootExpatParser |
( |
size_t |
bufsize = 8192 , |
|
|
const std::string & |
encoding = "" |
|
) |
| |
Default constructor:
- Parameters
-
bufsize | length of parse buffer for expat |
encoding | override document input encoding (broken?) |
◆ ~mootExpatParser()
virtual moot::mootExpatParser::~mootExpatParser |
( |
void |
| ) |
|
|
virtual |
◆ setEncoding()
virtual void moot::mootExpatParser::setEncoding |
( |
const std::string & |
encoding = "" | ) |
|
|
inlinevirtual |
◆ reset()
virtual void moot::mootExpatParser::reset |
( |
void |
| ) |
|
|
virtual |
Reset parser state: re-initializes the internal xml buffer, as well as the expat parser, its encoding and handlers.
Reimplemented in moot::TokenReaderExpat.
Referenced by setEncoding().
◆ from_mstream() [1/2]
virtual void moot::mootExpatParser::from_mstream |
( |
mootio::mistream * |
mistreamp, |
|
|
bool |
autoclose = false |
|
) |
| |
|
virtual |
◆ from_mstream() [2/2]
virtual void moot::mootExpatParser::from_mstream |
( |
mootio::mistream & |
mistream, |
|
|
bool |
autoclose = false |
|
) |
| |
|
inlinevirtual |
◆ from_filename()
virtual void moot::mootExpatParser::from_filename |
( |
const char * |
filename | ) |
|
|
virtual |
Select input from a named file. Descendants using named file input may override this method. The filename "-" may be used to specify stdin. Default implementation calls from_mstream().
Reimplemented in moot::TokenReaderExpat.
Referenced by from_mstream().
◆ from_file()
virtual void moot::mootExpatParser::from_file |
( |
FILE * |
file | ) |
|
|
virtual |
Select input from a C stream. Caller is responsible for opening and closing the stream. Descendants using C stream input may override this method. Default implementation calls from_mstream().
Reimplemented in moot::TokenReaderExpat.
Referenced by from_mstream().
◆ from_fd()
virtual void moot::mootExpatParser::from_fd |
( |
int |
fd | ) |
|
|
inlinevirtual |
◆ from_buffer()
virtual void moot::mootExpatParser::from_buffer |
( |
const void * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
virtual |
◆ from_string()
virtual void moot::mootExpatParser::from_string |
( |
const char * |
s | ) |
|
|
inlinevirtual |
Select input from a NUL-terminated C string. Caller is responsible for allocation and de-allocation. Descendants using C string input may override this method. Default implementation calls from_cbuffer(s,len).
References mootio::mstream::close(), context_dump(), from_buffer(), from_cxxstream(), parse_all(), parse_buffer(), parse_check(), parse_chunk(), parse_file(), and parse_filename().
◆ from_cxxstream()
virtual void moot::mootExpatParser::from_cxxstream |
( |
std::istream & |
is | ) |
|
|
virtual |
Select input from a C++ stream. Caller is responsible for allocation and de-allocation. Descendants using C++ stream input may override this method. Default implementation calls from_mstream().
Reimplemented in moot::TokenReaderExpat.
Referenced by from_string().
◆ close()
virtual void moot::mootExpatParser::close |
( |
void |
| ) |
|
|
virtual |
Finish input from currently selected source & perform any required cleanup operations. This method should always be called before selecting a new input source.
Descendants may override this method.
Reimplemented in moot::TokenReaderExpat.
◆ parse_check()
virtual bool moot::mootExpatParser::parse_check |
( |
void |
| ) |
|
|
virtual |
Check whether object is in a sane state for parsing, printing warning messages if this is not the case
Referenced by from_string().
◆ parse_filename()
bool moot::mootExpatParser::parse_filename |
( |
const std::string & |
filename | ) |
|
◆ parse_file()
bool moot::mootExpatParser::parse_file |
( |
FILE * |
infile = stdin , |
|
|
const std::string & |
in_name = "" |
|
) |
| |
◆ parse_buffer()
bool moot::mootExpatParser::parse_buffer |
( |
const char * |
buf, |
|
|
size_t |
buflen |
|
) |
| |
Parse from your very own string buffer.
- Warning
- This method is not intended to be called incrementally, so the stack is cleared before parsing the buffer. If you want to parse incrementally, use parse_chunk()
- Parameters
-
buf | buffer to parse |
buflen | number of bytes to parse from the buffer |
Referenced by from_string().
◆ parse_all()
Parse the entirety of the stream in
, which defaults to the currently selected input stream. Only minimal sanity checks are performed.
Referenced by from_string().
◆ parse_chunk()
bool moot::mootExpatParser::parse_chunk |
( |
int & |
nbytes, |
|
|
int & |
is_final, |
|
|
mootio::mistream * |
in = __null |
|
) |
| |
Read in and parse the next chunk from input source in
using an internal buffer. Returns true on success, false on failure.
- Parameters
-
nbytes | number of bytes read from file will be stored here |
is_final | will be 1 if the file ended, 0 otherwise |
in | input stream to read from (default is to use current selection) |
- Warning
- you should have called reset() at least once before calling this method – no sanity checks are performed!
Referenced by from_string().
◆ context_dump()
virtual void moot::mootExpatParser::context_dump |
( |
FILE * |
tofile = __null | ) |
|
|
virtual |
Print current parser context (in real input encoding)
Referenced by from_string().
◆ context_string()
virtual std::string moot::mootExpatParser::context_string |
( |
void |
| ) |
|
|
inlinevirtual |
◆ carp()
virtual void moot::mootExpatParser::carp |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
|
virtual |
◆ xpcarp()
virtual void moot::mootExpatParser::xpcarp |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
|
virtual |
◆ line_number()
long int moot::mootExpatParser::line_number |
( |
void |
| ) |
|
|
inline |
Get current line number of expat parser
◆ column_number()
int moot::mootExpatParser::column_number |
( |
void |
| ) |
|
|
inline |
Get current column number of expat parser
◆ byte_offset()
long moot::mootExpatParser::byte_offset |
( |
void |
| ) |
|
|
inline |
Get current byte offset of expat parser
◆ byte_count()
int moot::mootExpatParser::byte_count |
( |
void |
| ) |
|
|
inline |
Get byte-count for current event of expat parser
◆ XmlDeclHandler()
virtual void moot::mootExpatParser::XmlDeclHandler |
( |
const XML_Char * |
version, |
|
|
const XML_Char * |
encoding, |
|
|
int |
standalone |
|
) |
| |
|
inlinevirtual |
◆ StartElementHandler()
virtual void moot::mootExpatParser::StartElementHandler |
( |
const char * |
el, |
|
|
const char ** |
attr |
|
) |
| |
|
inlinevirtual |
◆ EndElementHandler()
virtual void moot::mootExpatParser::EndElementHandler |
( |
const char * |
el | ) |
|
|
inlinevirtual |
◆ CharacterDataHandler()
virtual void moot::mootExpatParser::CharacterDataHandler |
( |
const XML_Char * |
s, |
|
|
int |
len |
|
) |
| |
|
inlinevirtual |
◆ ProcessingInstructionHandler()
virtual void moot::mootExpatParser::ProcessingInstructionHandler |
( |
const XML_Char * |
s, |
|
|
const XML_Char * |
target, |
|
|
const XML_Char * |
data |
|
) |
| |
|
inlinevirtual |
◆ CommentHandler()
virtual void moot::mootExpatParser::CommentHandler |
( |
const XML_Char * |
s | ) |
|
|
inlinevirtual |
◆ StartCdataSectionHandler()
virtual void moot::mootExpatParser::StartCdataSectionHandler |
( |
void |
| ) |
|
|
inlinevirtual |
Handle start of CDATA sections
◆ EndCdataSectionHandler()
virtual void moot::mootExpatParser::EndCdataSectionHandler |
( |
void |
| ) |
|
|
inlinevirtual |
Handle end of CDATA sections
◆ DefaultHandler()
virtual void moot::mootExpatParser::DefaultHandler |
( |
const XML_Char * |
s, |
|
|
int |
len |
|
) |
| |
|
inlinevirtual |
◆ _xp_XmlDeclHandler()
static void moot::mootExpatParser::_xp_XmlDeclHandler |
( |
mootExpatParser * |
mp, |
|
|
const XML_Char * |
version, |
|
|
const XML_Char * |
encoding, |
|
|
int |
standalone |
|
) |
| |
|
inlinestatic |
◆ _xp_StartElementHandler()
static void moot::mootExpatParser::_xp_StartElementHandler |
( |
mootExpatParser * |
mp, |
|
|
const char * |
el, |
|
|
const char ** |
attr |
|
) |
| |
|
inlinestatic |
◆ _xp_EndElementHandler()
static void moot::mootExpatParser::_xp_EndElementHandler |
( |
mootExpatParser * |
mp, |
|
|
const char * |
el |
|
) |
| |
|
inlinestatic |
◆ _xp_CharacterDataHandler()
static void moot::mootExpatParser::_xp_CharacterDataHandler |
( |
mootExpatParser * |
mp, |
|
|
const XML_Char * |
s, |
|
|
int |
len |
|
) |
| |
|
inlinestatic |
◆ _xp_CommentHandler()
static void moot::mootExpatParser::_xp_CommentHandler |
( |
mootExpatParser * |
mp, |
|
|
const XML_Char * |
s |
|
) |
| |
|
inlinestatic |
◆ _xp_DefaultHandler()
static void moot::mootExpatParser::_xp_DefaultHandler |
( |
mootExpatParser * |
mp, |
|
|
const XML_Char * |
s, |
|
|
int |
len |
|
) |
| |
|
inlinestatic |
◆ xp_istream
◆ xp_istream_created
bool moot::mootExpatParser::xp_istream_created |
◆ xml_buf
char* moot::mootExpatParser::xml_buf |
◆ xml_buflen
size_t moot::mootExpatParser::xml_buflen |
◆ xml_encoding
std::string moot::mootExpatParser::xml_encoding |
◆ parser
XML_Parser moot::mootExpatParser::parser |
The documentation for this class was generated from the following file: