2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2012-10-03 18:08:49 +04:00
|
|
|
#ifndef cmWIXSourceWriter_h
|
|
|
|
#define cmWIXSourceWriter_h
|
|
|
|
|
2016-04-29 16:40:20 +03:00
|
|
|
#include <CPack/cmCPackLog.h>
|
|
|
|
|
2014-01-04 09:47:13 +04:00
|
|
|
#include <cmsys/FStream.hxx>
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2016-04-29 16:40:20 +03:00
|
|
|
#include <string>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <vector>
|
2012-10-03 18:08:49 +04:00
|
|
|
|
|
|
|
/** \class cmWIXSourceWriter
|
|
|
|
* \brief Helper class to generate XML WiX source files
|
|
|
|
*/
|
|
|
|
class cmWIXSourceWriter
|
|
|
|
{
|
|
|
|
public:
|
2016-09-06 13:11:00 +03:00
|
|
|
enum GuidType
|
|
|
|
{
|
|
|
|
WIX_GENERATED_GUID,
|
|
|
|
CMAKE_GENERATED_GUID
|
|
|
|
};
|
|
|
|
|
|
|
|
enum RootElementType
|
|
|
|
{
|
|
|
|
WIX_ELEMENT_ROOT,
|
|
|
|
INCLUDE_ELEMENT_ROOT
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmWIXSourceWriter(cmCPackLog* logger, std::string const& filename,
|
2016-09-06 13:11:00 +03:00
|
|
|
GuidType componentGuidType,
|
|
|
|
RootElementType rootElementType = WIX_ELEMENT_ROOT);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
|
|
|
~cmWIXSourceWriter();
|
|
|
|
|
2014-02-25 02:21:12 +04:00
|
|
|
void BeginElement(std::string const& name);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2014-02-25 02:21:12 +04:00
|
|
|
void EndElement(std::string const& name);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2015-10-12 22:53:08 +03:00
|
|
|
void AddTextNode(std::string const& text);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void AddProcessingInstruction(std::string const& target,
|
|
|
|
std::string const& content);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void AddAttribute(std::string const& key, std::string const& value);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void AddAttributeUnlessEmpty(std::string const& key,
|
|
|
|
std::string const& value);
|
2013-11-20 00:38:09 +04:00
|
|
|
|
2016-09-06 13:11:00 +03:00
|
|
|
std::string CreateGuidFromComponentId(std::string const& componentId);
|
|
|
|
|
2015-03-27 14:22:15 +03:00
|
|
|
static std::string CMakeEncodingToUtf8(std::string const& value);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2014-08-09 16:50:49 +04:00
|
|
|
protected:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLog* Logger;
|
2014-08-09 16:50:49 +04:00
|
|
|
|
2012-10-03 18:08:49 +04:00
|
|
|
private:
|
|
|
|
enum State
|
|
|
|
{
|
|
|
|
DEFAULT,
|
|
|
|
BEGIN
|
|
|
|
};
|
|
|
|
|
|
|
|
void WriteXMLDeclaration();
|
|
|
|
|
2012-12-04 23:37:41 +04:00
|
|
|
void Indent(size_t count);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2014-02-25 02:21:12 +04:00
|
|
|
static std::string EscapeAttributeValue(std::string const& value);
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ofstream File;
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2013-12-20 21:12:01 +04:00
|
|
|
State State;
|
2012-10-03 18:08:49 +04:00
|
|
|
|
2013-12-20 21:12:01 +04:00
|
|
|
std::vector<std::string> Elements;
|
2013-10-23 14:14:39 +04:00
|
|
|
|
2013-12-20 21:12:01 +04:00
|
|
|
std::string SourceFilename;
|
2016-09-06 13:11:00 +03:00
|
|
|
|
|
|
|
GuidType ComponentGuidType;
|
2012-10-03 18:08:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|