libxcks
0.1.0.1
|
A very simple XML parser. More...
#include <xmlparser.hpp>
Public Member Functions | |
bool | parse (const std::string &filename) |
Parses the given file. More... | |
bool | parse (std::istream &is) |
Parses the given input stream. More... | |
Protected Member Functions | |
XMLParser () | |
Default constructor. More... | |
virtual | ~XMLParser () |
Destructor. More... | |
bool | initParser () |
Initializes the parser for parsing a new document. More... | |
virtual void | startElement (const std::string &name, const XMLParserAttributes &atts) noexcept(false) |
Receives notification of the beginning of an element. More... | |
virtual void | endElement (const std::string &name) noexcept(false) |
Receives notification of the end of an element. More... | |
virtual void | characters (const std::string &chars) noexcept(false) |
Receives notification of character data. More... | |
virtual void | fatalError (XML_Error errorCode, const std::string &errorMessage, int line, int column) noexcept |
Receive notification of a non-recoverable error. More... | |
int | getDepth () const |
Returns the current depth in XML tree structure. More... | |
A very simple XML parser.
Uses expat to parse XML streams. expat must be configured to use UTF-8 multi-bytes strings.
All the parsing methods must call initParser before parse a new document.
Definition at line 137 of file xmlparser.hpp.
|
protected |
Default constructor.
Definition at line 333 of file xmlparser.cpp.
|
protectedvirtual |
Destructor.
Definition at line 343 of file xmlparser.cpp.
|
protectedvirtualnoexcept |
Receives notification of character data.
This default implementation does nothing.
chars | The characters from the XML document. |
Reimplemented in libxcks::XCKSFileReader.
Definition at line 420 of file xmlparser.cpp.
|
protectedvirtualnoexcept |
Receives notification of the end of an element.
This default implementation does nothing.
name | The name of the element. |
Reimplemented in libxcks::XCKSFileReader.
Definition at line 407 of file xmlparser.cpp.
|
protectedvirtualnoexcept |
Receive notification of a non-recoverable error.
This default implementation does nothing.
errorCode | The error code. |
errorMessage | The error message. |
line | The line number the text where the error has occurred. |
column | The column number where the error has occurred. |
Reimplemented in libxcks::XCKSFileReader.
Definition at line 436 of file xmlparser.cpp.
|
protected |
Returns the current depth in XML tree structure.
Definition at line 530 of file xmlparser.cpp.
|
protected |
Initializes the parser for parsing a new document.
Initializes also the current depth in the XML tree to 0
.
This method must call before parsing any new document.
If a previous parser exists, it is erased before creating a new one.
If this method returns false
the parser shouldn't begin to parse the document.
true
if a new parser has been created, false
otherwise. Definition at line 366 of file xmlparser.cpp.
bool libxcks::XMLParser::parse | ( | const std::string & | filename | ) |
Parses the given file.
filename | The name of the file to parse. |
true
if the file has been parsed successfully (with no errors), false otherwise
. Definition at line 544 of file xmlparser.cpp.
bool libxcks::XMLParser::parse | ( | std::istream & | is | ) |
Parses the given input stream.
The stream is parsed until its end is reached or until an error occurs.
is | The input stream to parse. |
true
if the file has been parsed successfully (with no errors), false otherwise
. Definition at line 561 of file xmlparser.cpp.
|
protectedvirtualnoexcept |
Receives notification of the beginning of an element.
This default implementation does nothing.
name | The name of the element. |
atts | The attributes attached to the element. |
Reimplemented in libxcks::XCKSFileReader.
Definition at line 394 of file xmlparser.cpp.