cmWIXPatchParser.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmCPackWIXPatchParser_h
  4. #define cmCPackWIXPatchParser_h
  5. #include "cmCPackLog.h"
  6. #include "cmXMLParser.h"
  7. #include <map>
  8. #include <vector>
  9. struct cmWIXPatchNode
  10. {
  11. enum Type
  12. {
  13. TEXT,
  14. ELEMENT
  15. };
  16. virtual ~cmWIXPatchNode();
  17. virtual Type type() = 0;
  18. };
  19. struct cmWIXPatchText : public cmWIXPatchNode
  20. {
  21. virtual Type type();
  22. std::string text;
  23. };
  24. struct cmWIXPatchElement : cmWIXPatchNode
  25. {
  26. virtual Type type();
  27. ~cmWIXPatchElement();
  28. typedef std::vector<cmWIXPatchNode*> child_list_t;
  29. typedef std::map<std::string, std::string> attributes_t;
  30. std::string name;
  31. child_list_t children;
  32. attributes_t attributes;
  33. };
  34. /** \class cmWIXPatchParser
  35. * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE)
  36. */
  37. class cmWIXPatchParser : public cmXMLParser
  38. {
  39. public:
  40. typedef std::map<std::string, cmWIXPatchElement> fragment_map_t;
  41. cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
  42. private:
  43. virtual void StartElement(const std::string& name, const char** atts);
  44. void StartFragment(const char** attributes);
  45. virtual void EndElement(const std::string& name);
  46. virtual void CharacterDataHandler(const char* data, int length);
  47. virtual void ReportError(int line, int column, const char* msg);
  48. void ReportValidationError(std::string const& message);
  49. bool IsValid() const;
  50. cmCPackLog* Logger;
  51. enum ParserState
  52. {
  53. BEGIN_DOCUMENT,
  54. BEGIN_FRAGMENTS,
  55. INSIDE_FRAGMENT
  56. };
  57. ParserState State;
  58. bool Valid;
  59. fragment_map_t& Fragments;
  60. std::vector<cmWIXPatchElement*> ElementStack;
  61. };
  62. #endif