Welcome to CppExpat’s documentation!¶
-
class
ParserBase
¶ - #include <cppexpat.hpp>
The parser base class.
Create a derived version of this class to implement custom callbacks.
Public Functions
-
void
parse
(std::istream &f, int sz)¶ Parse an input stream.
-
void
parse
(string s)¶ Parse a string.
Protected Functions
-
virtual void
start
(string name, ElementAttr attr)¶ Called when an element starts.
-
virtual void
end
(string name)¶ Called when an element ends.
-
virtual void
chardata
(string data)¶ Called when character data is encountered.
-
virtual void
pinstr
(string target, string data)¶ Called for processing instructions.
Private Members
-
XML_Parser
p
¶
Private Static Functions
-
void
start_wrapper
(void *userdata, const char *name, const char **attr)¶
-
void
end_wrapper
(void *userdata, const char *name)¶
-
void
chardata_wrapper
(void *userdata, const char *data, int len)¶
-
void
pinstr_wrapper
(void *userdata, const char *target, const char *data)¶
-
ElementAttr
build_attr
(const char **attr)¶
-
void
-
class
XMLError
¶ - #include <cppexpat.hpp>
An exception thrown when Expat encounters an error.
Private Members
-
const string
what_
¶
Private Static Functions
-
static string
construct_what
(XML_Parser p)¶
-
const string
-
class
XMLParser
¶ - #include <cppexpat.hpp>
A pre-made XML parser class that takes callback functions.
Public Functions
-
XMLParser
()¶
-
void
set_start_handler
(StartCallback c)¶ Set the start element handler.
-
void
set_end_handler
(EndCallback c)¶ Set the end element handler.
-
void
set_chardata_handler
(ChardataCallback c)¶ Set the character data handler.
-
void
set_pinstr_handler
(PinstrCallback c)¶ Set the processing instruction handler.
Protected Functions
-
virtual void
start
(string name, ElementAttr attr)¶ Called when an element starts.
-
virtual void
end
(string name)¶ Called when an element ends.
-
virtual void
chardata
(string data)¶ Called when character data is encountered.
-
virtual void
pinstr
(string target, string data)¶ Called for processing instructions.
-
-
namespace
cppexpat
¶ Typedefs
-
typedef
using cppexpat::ElementAttr = typedef std::map<string, string>
An alias for an attribute map.
-
typedef
using cppexpat::StartCallback = typedef std::function<void(string,ElementAttr)>
-
typedef
using cppexpat::EndCallback = typedef std::function<void(string)>
-
typedef
using cppexpat::ChardataCallback = typedef std::function<void(string)>
-
typedef
using cppexpat::PinstrCallback = typedef std::function<void(string,string)>
Variables
-
constexpr unsigned int
bufsize
¶
-
typedef
-
file
cppexpat.hpp
- #include <functional>#include <exception>#include <istream>#include <expat.h>#include <utility>#include <cstring>#include <sstream>#include <string>#include <memory>#include <map>