rtgui_xml.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef __RTGUI_XML_H__
  2. #define __RTGUI_XML_H__
  3. #include <rtgui/rtgui.h>
  4. /* Types of events: start element, end element, text, attr name, attr
  5. val and start/end document. Other events can be ignored! */
  6. enum {
  7. EVENT_START = 0, /* Start tag */
  8. EVENT_END, /* End tag */
  9. EVENT_TEXT, /* Text */
  10. EVENT_NAME, /* Attribute name */
  11. EVENT_VAL, /* Attribute value */
  12. EVENT_END_DOC, /* End of document */
  13. EVENT_COPY, /* Internal only; copies to internal buffer */
  14. EVENT_NONE /* Internal only; should never see this event */
  15. };
  16. /* xml structure typedef */
  17. typedef struct rtgui_xml rtgui_xml_t;
  18. typedef int (*rtgui_xml_event_handler_t)(rt_uint8_t event, const char* text, rt_size_t len, void* user);
  19. /* create a xml parser context */
  20. rtgui_xml_t* rtgui_xml_create(rt_size_t buffer_size, rtgui_xml_event_handler_t handler, void* user);
  21. /* destroy a xml parser context */
  22. void rtgui_xml_destroy(rtgui_xml_t* rtgui_xml);
  23. /* parse xml buffer */
  24. int rtgui_xml_parse(rtgui_xml_t* rtgui_xml, const char* buf, rt_size_t len);
  25. /* event string */
  26. const char* rtgui_xml_event_str(rt_uint8_t event);
  27. #endif