rtgui_xml.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. {
  8. EVENT_START = 0, /* Start tag */
  9. EVENT_END, /* End tag */
  10. EVENT_TEXT, /* Text */
  11. EVENT_NAME, /* Attribute name */
  12. EVENT_VAL, /* Attribute value */
  13. EVENT_END_DOC, /* End of document */
  14. EVENT_COPY, /* Internal only; copies to internal buffer */
  15. EVENT_NONE /* Internal only; should never see this event */
  16. };
  17. /* xml structure typedef */
  18. typedef struct rtgui_xml rtgui_xml_t;
  19. typedef int (*rtgui_xml_event_handler_t)(rt_uint8_t event, const char *text, rt_size_t len, void *user);
  20. /* create a xml parser context */
  21. rtgui_xml_t *rtgui_xml_create(rt_size_t buffer_size, rtgui_xml_event_handler_t handler, void *user);
  22. /* destroy a xml parser context */
  23. void rtgui_xml_destroy(rtgui_xml_t *rtgui_xml);
  24. /* parse xml buffer */
  25. int rtgui_xml_parse(rtgui_xml_t *rtgui_xml, const char *buf, rt_size_t len);
  26. /* event string */
  27. const char *rtgui_xml_event_str(rt_uint8_t event);
  28. #endif