cmWIXPatchParser.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 cmWIXPatchElement
  17. {
  18. ~cmWIXPatchElement();
  19. typedef std::list<cmWIXPatchElement*> child_list_t;
  20. typedef std::map<std::string, std::string> attributes_t;
  21. std::string name;
  22. child_list_t children;
  23. attributes_t attributes;
  24. };
  25. /** \class cmWIXPatchParser
  26. * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE)
  27. */
  28. class cmWIXPatchParser : public cmXMLParser
  29. {
  30. public:
  31. typedef std::map<std::string, cmWIXPatchElement> fragment_map_t;
  32. cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
  33. private:
  34. virtual void StartElement(const std::string& name, const char **atts);
  35. void StartFragment(const char **attributes);
  36. virtual void EndElement(const std::string& name);
  37. virtual void ReportError(int line, int column, const char* msg);
  38. void ReportValidationError(std::string const& message);
  39. bool IsValid() const;
  40. cmCPackLog* Logger;
  41. enum ParserState
  42. {
  43. BEGIN_DOCUMENT,
  44. BEGIN_FRAGMENTS,
  45. INSIDE_FRAGMENT
  46. };
  47. ParserState State;
  48. bool Valid;
  49. fragment_map_t& Fragments;
  50. std::list<cmWIXPatchElement*> ElementStack;
  51. };
  52. #endif