27#define UTF8ToWString(s) s
37 const XML_Char
COLON =
':';
39 const XML_Char* get_local_name(
const XML_Char* rawname)
41 const XML_Char*
p = rawname;
47 while (*
p !=
COLON &&
p > rawname)
59 return static_cast<xml_parser*
>(XML_GetUserData(
60 static_cast<XML_Parser
>(data)));
63 bool has_only_whitespaces(
const XML_Char* s,
int len)
65 const XML_Char*
p = s;
66 for (
int i = 0;
i < len;
i++)
67 if (*
p++ !=
' ')
return false;
73 document_handler_(nullptr),
74 xml_parser_(XML_ParserCreate(nullptr))
106 attributes[
UTF8ToWString(
reinterpret_cast<const char*
>(get_local_name(atts[
i])))] =
UTF8ToWString(
reinterpret_cast<const char*
>(atts[
i+1]));
132 if (has_only_whitespaces(s,len))
161 XML_SetElementHandler(
166 XML_SetCharacterDataHandler(
170 XML_SetCommentHandler(
177 if (XML_STATUS_ERROR ==
virtual void end_element(const string_t &raw_name, const string_t &local_name)=0
virtual void comment(const string_t &comment)=0
virtual void characters(const string_t &character)=0
virtual void start_element(const string_t &raw_name, const string_t &local_name, const xml_tag_attribute_container_t &attributes)=0
virtual void ignore_whitespace(const string_t &whitespaces)=0
i_xml_parser_event_handler * document_handler_
void set_document_handler(i_xml_parser_event_handler *event_handler)
Set a document handler.
i_xml_parser_event_handler * get_document_handler() const
Returns the currently used document handler or null if no document handler was set before.
void parse(const char *XmlData, size_t Length, bool IsFinal)
Parse a XML data stream.
std::map< string_t, string_t > xml_tag_attribute_container_t
static void xml_character_data_handler(void *UserData, const XML_Char *s, int len)
static void xml_start_element_handler(void *UserData, const XML_Char *name, const XML_Char **atts)
static void xml_comment_handler(void *UserData, const XML_Char *Data)
static void xml_end_element_handler(void *UserData, const XML_Char *name)