cmWIXSourceWriter.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <fstream>
  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. const std::string& filename, bool isIncludeFile = false);
  24. ~cmWIXSourceWriter();
  25. void BeginElement(const std::string& name);
  26. void EndElement(const std::string& name);
  27. void AddProcessingInstruction(
  28. const std::string& target, const std::string& content);
  29. void AddAttribute(
  30. const std::string& key, const std::string& value);
  31. void AddAttributeUnlessEmpty(
  32. const std::string& key, const std::string& value);
  33. static std::string WindowsCodepageToUtf8(const std::string& value);
  34. private:
  35. enum State
  36. {
  37. DEFAULT,
  38. BEGIN
  39. };
  40. void WriteXMLDeclaration();
  41. void Indent(size_t count);
  42. static std::string EscapeAttributeValue(const std::string& value);
  43. cmCPackLog* Logger;
  44. std::ofstream file;
  45. State state;
  46. std::vector<std::string> elements;
  47. std::string sourceFilename;
  48. };
  49. #endif