cmWIXSourceWriter.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 AddProcessingInstruction(
  28. std::string const& target, std::string const& content);
  29. void AddAttribute(
  30. std::string const& key, std::string const& value);
  31. void AddAttributeUnlessEmpty(
  32. std::string const& key, std::string const& value);
  33. static std::string WindowsCodepageToUtf8(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