cmWIXPatchParser.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2013 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCPackWIXPatchParser_h
  11. #define cmCPackWIXPatchParser_h
  12. #include <cmXMLParser.h>
  13. #include <CPack/cmCPackLog.h>
  14. #include <map>
  15. #include <list>
  16. struct cmWIXPatchNode
  17. {
  18. enum Type
  19. {
  20. TEXT,
  21. ELEMENT
  22. };
  23. virtual ~cmWIXPatchNode();
  24. virtual Type type() = 0;
  25. };
  26. struct cmWIXPatchText : public cmWIXPatchNode
  27. {
  28. virtual Type type();
  29. std::string text;
  30. };
  31. struct cmWIXPatchElement : cmWIXPatchNode
  32. {
  33. virtual Type type();
  34. ~cmWIXPatchElement();
  35. typedef std::list<cmWIXPatchNode*> child_list_t;
  36. typedef std::map<std::string, std::string> attributes_t;
  37. std::string name;
  38. child_list_t children;
  39. attributes_t attributes;
  40. };
  41. /** \class cmWIXPatchParser
  42. * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE)
  43. */
  44. class cmWIXPatchParser : public cmXMLParser
  45. {
  46. public:
  47. typedef std::map<std::string, cmWIXPatchElement> fragment_map_t;
  48. cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
  49. private:
  50. virtual void StartElement(const std::string& name, const char **atts);
  51. void StartFragment(const char **attributes);
  52. virtual void EndElement(const std::string& name);
  53. virtual void CharacterDataHandler(const char* data, int length);
  54. virtual void ReportError(int line, int column, const char* msg);
  55. void ReportValidationError(std::string const& message);
  56. bool IsValid() const;
  57. cmCPackLog* Logger;
  58. enum ParserState
  59. {
  60. BEGIN_DOCUMENT,
  61. BEGIN_FRAGMENTS,
  62. INSIDE_FRAGMENT
  63. };
  64. ParserState State;
  65. bool Valid;
  66. fragment_map_t& Fragments;
  67. std::list<cmWIXPatchElement*> ElementStack;
  68. };
  69. #endif