Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
xml-writer.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include <iosfwd>
5
#include <string>
6
#include <list>
7
#include <map>
8
9
namespace
nix {
10
11
typedef
std::map<std::string, std::string, std::less<>> XMLAttrs;
12
13
class
XMLWriter
14
{
15
private
:
16
17
std::ostream & output;
18
19
bool
indent;
20
bool
closed;
21
22
std::list<std::string> pendingElems;
23
24
public
:
25
26
XMLWriter(
bool
indent, std::ostream & output);
27
~XMLWriter();
28
29
void
close();
30
31
void
openElement(std::string_view name,
const
XMLAttrs & attrs = XMLAttrs());
32
void
closeElement();
33
34
void
writeEmptyElement(std::string_view name,
const
XMLAttrs & attrs = XMLAttrs());
35
36
private
:
37
void
writeAttrs(
const
XMLAttrs & attrs);
38
39
void
indent_(
size_t
depth);
40
};
41
42
class
XMLOpenElement
43
{
44
private
:
45
XMLWriter
& writer;
46
public
:
47
XMLOpenElement(
XMLWriter
& writer, std::string_view name,
const
XMLAttrs & attrs = XMLAttrs())
48
: writer(writer)
49
{
50
writer.openElement(name, attrs);
51
}
52
53
XMLOpenElement(XMLOpenElement &&) =
delete
;
54
XMLOpenElement(
const
XMLOpenElement &) =
delete
;
55
XMLOpenElement & operator=(XMLOpenElement &&) =
delete
;
56
XMLOpenElement & operator=(
const
XMLOpenElement &) =
delete
;
57
58
~XMLOpenElement()
59
{
60
writer.closeElement();
61
}
62
};
63
64
}
// namespace nix
nix::XMLWriter
Definition
xml-writer.hh:14
libutil
include
nix
util
xml-writer.hh
Generated by
1.18.0