Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/CPack/WiX/cmWIXSourceWriter.h
5019 views
1
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2
file LICENSE.rst or https://cmake.org/licensing for details. */
3
#pragma once
4
5
#include <string>
6
#include <vector>
7
8
#include "cmsys/FStream.hxx"
9
10
#include "cmCPackLog.h"
11
12
/** \class cmWIXSourceWriter
13
* \brief Helper class to generate XML WiX source files
14
*/
15
class cmWIXSourceWriter
16
{
17
public:
18
enum GuidType
19
{
20
WIX_GENERATED_GUID,
21
CMAKE_GENERATED_GUID
22
};
23
24
enum RootElementType
25
{
26
WIX_ELEMENT_ROOT,
27
INCLUDE_ELEMENT_ROOT
28
};
29
30
cmWIXSourceWriter(unsigned long wixVersion, cmCPackLog* logger,
31
std::string const& filename, GuidType componentGuidType,
32
RootElementType rootElementType = WIX_ELEMENT_ROOT);
33
34
~cmWIXSourceWriter();
35
36
void BeginElement_StandardDirectory();
37
void EndElement_StandardDirectory();
38
39
void BeginElement(std::string const& name);
40
41
void EndElement(std::string const& name);
42
43
void AddTextNode(std::string const& text);
44
45
void AddProcessingInstruction(std::string const& target,
46
std::string const& content);
47
48
void AddAttribute(std::string const& key, std::string const& value);
49
50
void AddAttributeUnlessEmpty(std::string const& key,
51
std::string const& value);
52
53
std::string CreateGuidFromComponentId(std::string const& componentId);
54
55
static std::string EscapeAttributeValue(std::string const& value);
56
57
protected:
58
unsigned long WixVersion;
59
cmCPackLog* Logger;
60
61
private:
62
enum State
63
{
64
DEFAULT,
65
BEGIN
66
};
67
68
void WriteXMLDeclaration();
69
70
void Indent(size_t count);
71
72
cmsys::ofstream File;
73
74
State State;
75
76
std::vector<std::string> Elements;
77
78
std::string SourceFilename;
79
80
GuidType ComponentGuidType;
81
};
82
83