cmake/Source/CPack/WiX/cmWIXSourceWriter.h

78 lines
1.6 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2013-03-16 19:13:01 +02:00
2020-02-01 23:06:01 +01:00
#include <string>
#include <vector>
2016-07-09 11:21:54 +02:00
2017-07-20 19:35:53 +02:00
#include "cmsys/FStream.hxx"
2013-03-16 19:13:01 +02:00
2020-02-01 23:06:01 +01:00
#include "cmCPackLog.h"
2013-03-16 19:13:01 +02:00
/** \class cmWIXSourceWriter
* \brief Helper class to generate XML WiX source files
*/
class cmWIXSourceWriter
{
public:
2016-10-30 18:24:19 +01:00
enum GuidType
{
WIX_GENERATED_GUID,
CMAKE_GENERATED_GUID
};
enum RootElementType
{
WIX_ELEMENT_ROOT,
INCLUDE_ELEMENT_ROOT
};
2016-07-09 11:21:54 +02:00
cmWIXSourceWriter(cmCPackLog* logger, std::string const& filename,
2016-10-30 18:24:19 +01:00
GuidType componentGuidType,
RootElementType rootElementType = WIX_ELEMENT_ROOT);
2013-03-16 19:13:01 +02:00
~cmWIXSourceWriter();
2015-04-27 22:25:09 +02:00
void BeginElement(std::string const& name);
2013-03-16 19:13:01 +02:00
2015-04-27 22:25:09 +02:00
void EndElement(std::string const& name);
2013-03-16 19:13:01 +02:00
2016-03-13 13:35:51 +01:00
void AddTextNode(std::string const& text);
2016-07-09 11:21:54 +02:00
void AddProcessingInstruction(std::string const& target,
std::string const& content);
2013-03-16 19:13:01 +02:00
2016-07-09 11:21:54 +02:00
void AddAttribute(std::string const& key, std::string const& value);
2013-03-16 19:13:01 +02:00
2016-07-09 11:21:54 +02:00
void AddAttributeUnlessEmpty(std::string const& key,
std::string const& value);
2014-08-03 19:52:23 +02:00
2016-10-30 18:24:19 +01:00
std::string CreateGuidFromComponentId(std::string const& componentId);
2021-09-14 00:13:48 +02:00
static std::string EscapeAttributeValue(std::string const& value);
2015-04-27 22:25:09 +02:00
protected:
2016-07-09 11:21:54 +02:00
cmCPackLog* Logger;
2013-03-16 19:13:01 +02:00
private:
enum State
{
DEFAULT,
BEGIN
};
void WriteXMLDeclaration();
void Indent(size_t count);
2014-08-03 19:52:23 +02:00
cmsys::ofstream File;
State State;
2013-03-16 19:13:01 +02:00
2014-08-03 19:52:23 +02:00
std::vector<std::string> Elements;
2013-03-16 19:13:01 +02:00
2014-08-03 19:52:23 +02:00
std::string SourceFilename;
2016-10-30 18:24:19 +01:00
GuidType ComponentGuidType;
2013-03-16 19:13:01 +02:00
};