aboutsummaryrefslogtreecommitdiff
path: root/nix/libutil/xml-writer.hh
blob: 3cefe3712c0802380c26dd66cec11a8fbd162eb5 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

#include <iostream>
#include <string>
#include <list>
#include <map>


namespace nix {

using std::string;
using std::map;
using std::list;


typedef map<string, string> XMLAttrs;


class XMLWriter
{
private:

    std::ostream & output;

    bool indent;
    bool closed;

    list<string> pendingElems;

public:

    XMLWriter(bool indent, std::ostream & output);
    ~XMLWriter();

    void close();

    void openElement(const string & name,
        const XMLAttrs & attrs = XMLAttrs());
    void closeElement();

    void writeEmptyElement(const string & name,
        const XMLAttrs & attrs = XMLAttrs());

private:
    void writeAttrs(const XMLAttrs & attrs);

    void indent_(unsigned int depth);
};


class XMLOpenElement
{
private:
    XMLWriter & writer;
public:
    XMLOpenElement(XMLWriter & writer, const string & name,
        const XMLAttrs & attrs = XMLAttrs())
        : writer(writer)
    {
        writer.openElement(name, attrs);
    }
    ~XMLOpenElement()
    {
        writer.closeElement();
    }
};


}
57cab764122af69d52d8cc9c843456044e5d7bc'>image: Add mbr-raw-image-type and use by default....Josselin Poiret 2023-08-17doc: cookbook: Document how to disable the Yubikey OTP application....Maxim Cournoyer 2023-08-16doc: cookbook: Document a dynamic DNS update mcron job....Maxim Cournoyer 2023-08-16doc: Update Cookbook Texinfo menus....Maxim Cournoyer 2023-08-15doc: cookbook: Mention common SRFI-1 procedures....Ludovic Courtès 2023-08-15doc: cookbook: Add 'use-modules' in gexp example....Ludovic Courtès 2023-08-15doc: cookbook: Link to "Package Modules"....Ludovic Courtès 2023-07-14doc: Mention gexps in the "Scheme Crash Course"....Ludovic Courtès 2023-06-05doc: cookbook: Update example my-libgit2 package....Efraim Flashner 2023-06-04services: screen-locker-service-type: Configurable PAM and setuid....muradm 2023-05-31nls: Update translations....Florian Pelz 2023-05-06doc: cookbook: Remove outdated section about GUIX_PACKAGE_PATH....Ludovic Courtès 2023-01-09doc: cookbook: Add "Installing Guix on a Cluster" chapter....Ludovic Courtès 2023-01-06doc: cookbook: Remove 404 link to mitpress.mit.edu....Ludovic Courtès