cmWIXSourceWriter.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2012 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 cmWIXSourceWriter_h
  11. #define cmWIXSourceWriter_h
  12. #include <vector>
  13. #include <string>
  14. #include <cmsys/FStream.hxx>
  15. #include <CPack/cmCPackLog.h>
  16. /** \class cmWIXSourceWriter
  17. * \brief Helper class to generate XML WiX source files
  18. */
  19. class cmWIXSourceWriter
  20. {
  21. public:
  22. cmWIXSourceWriter(cmCPackLog* logger,
  23. std::string const& filename, bool isIncludeFile = false);
  24. ~cmWIXSourceWriter();
  25. void BeginElement(std::string const& name);
  26. void EndElement(std::string const& name);
  27. void AddTextNode(std::string const& text);
  28. void AddProcessingInstruction(
  29. std::string const& target, std::string const& content);
  30. void AddAttribute(
  31. std::string const& key, std::string const& value);
  32. void AddAttributeUnlessEmpty(
  33. std::string const& key, std::string const& value);
  34. static std::string CMakeEncodingToUtf8(std::string const& value);
  35. protected:
  36. cmCPackLog* Logger;
  37. private:
  38. enum State
  39. {
  40. DEFAULT,
  41. BEGIN
  42. };
  43. void WriteXMLDeclaration();
  44. void Indent(size_t count);
  45. static std::string EscapeAttributeValue(std::string const& value);
  46. cmsys::ofstream File;
  47. State State;
  48. std::vector<std::string> Elements;
  49. std::string SourceFilename;
  50. };
  51. #endif