1
/*============================================================================
2
CMake - Cross Platform Makefile Generator
3
Copyright 2015 Daniel Pfeifer <daniel@pfeifer-mail.de>
5
Distributed under the OSI-approved BSD License (the "License");
6
see accompanying file Copyright.txt for details.
8
This software is distributed WITHOUT ANY WARRANTY; without even the
9
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
See the License for more information.
11
============================================================================*/
15
#include "cmStandardIncludes.h"
16
#include "cmXMLSafe.h"
26
cmXMLWriter(std::ostream& output, std::size_t level = 0);
29
void StartDocument(const char* encoding = "UTF-8");
32
void StartElement(std::string const& name);
35
void BreakAttributes();
38
void Attribute(const char* name, T const& value)
41
this->Output << name << "=\"" << SafeAttribute(value) << '"';
45
void Element(std::string const& name, T const& value)
47
this->StartElement(name);
53
void Content(T const& content)
56
this->Output << SafeContent(content);
59
void Comment(const char* comment);
61
void CData(std::string const& data);
63
void ProcessingInstruction(const char* target, const char* data);
65
void FragmentFile(const char* fname);
68
cmXMLWriter(const cmXMLWriter&);
69
cmXMLWriter& operator=(const cmXMLWriter&);
71
void ConditionalLineBreak(bool condition, std::size_t indent);
76
void CloseStartElement();
79
static cmXMLSafe SafeAttribute(const char* value)
81
return cmXMLSafe(value);
84
static cmXMLSafe SafeAttribute(std::string const& value)
86
return cmXMLSafe(value);
90
static T SafeAttribute(T value)
95
static cmXMLSafe SafeContent(const char* value)
97
return cmXMLSafe(value).Quotes(false);
100
static cmXMLSafe SafeContent(std::string const& value)
102
return cmXMLSafe(value).Quotes(false);
105
template <typename T>
106
static T SafeContent(T value)
112
std::ostream& Output;
113
std::stack<std::string, std::vector<std::string> > Elements;