1
0

XMLNode.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <windows.h>
  3. #include "../nu/Alias.h"
  4. #include <vector>
  5. #include <map>
  6. class MapUnicodeComp
  7. {
  8. public:
  9. // CSTR_LESS_THAN 1 // string 1 less than string 2
  10. // CSTR_EQUAL 2 // string 1 equal to string 2
  11. // CSTR_GREATER_THAN 3 // string 1 greater than string 2
  12. bool operator()(const wchar_t* str1, const wchar_t* str2) const
  13. {
  14. return (CompareStringW(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), 0, str1, -1, str2, -1)-2) == CSTR_LESS_THAN;
  15. }
  16. };
  17. class XMLNode
  18. {
  19. public:
  20. typedef std::map<const wchar_t *, wchar_t*, MapUnicodeComp> PropMap;
  21. typedef std::vector<XMLNode*> NodeList;
  22. typedef std::map<const wchar_t *, NodeList*, MapUnicodeComp> NodeMap;
  23. XMLNode();
  24. ~XMLNode();
  25. const XMLNode *Get(const wchar_t *) const;
  26. const NodeList *GetList(const wchar_t *) const;
  27. const bool Present(const wchar_t *) const;
  28. void SetProperty(const wchar_t *prop, const wchar_t *value);
  29. const wchar_t *GetProperty(const wchar_t *prop) const;
  30. const wchar_t *GetContent() const;
  31. void SetContent_Own(wchar_t *new_content);
  32. void AppendContent(wchar_t *append);
  33. void AddNode(const wchar_t *name, XMLNode *new_node);
  34. XMLNode *parent;
  35. private:
  36. PropMap properties;
  37. wchar_t *content;
  38. size_t content_len; // number of characters in curtext, not including null terminator
  39. NodeMap nodes;
  40. };