cmWIXSourceWriter.h 1.8 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 <CPack/cmCPackLog.h>
  13. #include <cmsys/FStream.hxx>
  14. #include <string>
  15. #include <vector>
  16. /** \class cmWIXSourceWriter
  17. * \brief Helper class to generate XML WiX source files
  18. */
  19. class cmWIXSourceWriter
  20. {
  21. public:
  22. cmWIXSourceWriter(cmCPackLog* logger, std::string const& filename,
  23. 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(std::string const& target,
  29. std::string const& content);
  30. void AddAttribute(std::string const& key, std::string const& value);
  31. void AddAttributeUnlessEmpty(std::string const& key,
  32. std::string const& value);
  33. static std::string CMakeEncodingToUtf8(std::string const& value);
  34. protected:
  35. cmCPackLog* Logger;
  36. private:
  37. enum State
  38. {
  39. DEFAULT,
  40. BEGIN
  41. };
  42. void WriteXMLDeclaration();
  43. void Indent(size_t count);
  44. static std::string EscapeAttributeValue(std::string const& value);
  45. cmsys::ofstream File;
  46. State State;
  47. std::vector<std::string> Elements;
  48. std::string SourceFilename;
  49. };
  50. #endif