1
0

XMLString.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "XMLString.h"
  2. /* TODO: make and use some sort of nx_mutable_string_t object */
  3. XMLString::XMLString()
  4. {
  5. data=0;
  6. }
  7. XMLString::~XMLString()
  8. {
  9. NXMutableStringDestroy(data);
  10. }
  11. void XMLString::Reset()
  12. {
  13. if (data)
  14. data->nx_string_data->len = 0; // TODO: make mutable string function for this
  15. }
  16. nx_string_t XMLString::GetString()
  17. {
  18. // TODO: make mutable string function for this
  19. nx_string_t str = data->nx_string_data;
  20. data->nx_string_data = 0;
  21. NXMutableStringDestroy(data);
  22. data=0;
  23. return str;
  24. }
  25. void XMLString::XMLCallback_OnStartElement(const nsxml_char_t *xmlpath, const nsxml_char_t *xmltag, ifc_xmlattributes *attributes)
  26. {
  27. if (data)
  28. data->nx_string_data->len = 0; // TODO: make mutable string function for this
  29. }
  30. void XMLString::XMLCallback_OnCharacterData(const nsxml_char_t *xmlpath, const nsxml_char_t *xmltag, const nsxml_char_t *characters, size_t num_characters)
  31. {
  32. if (!data)
  33. data = NXMutableStringCreateFromXML(characters, num_characters);
  34. else
  35. NXMutableStringGrowFromXML(data, characters, num_characters);
  36. }