ManaPlus
pugixmlwriter.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifdef ENABLE_PUGIXML
23 
25 
26 #include "logger.h"
27 
28 #include "fs/virtfs/fs.h"
29 
30 #include "utils/delete2.h"
31 #include "utils/fuzzer.h"
32 #include "utils/stringutils.h"
33 
35 
36 #include "debug.h"
37 
38 namespace XML
39 {
40  Writer::Writer(const std::string &filename) :
41  mDoc(),
42  mNode(),
43  mName(filename)
44  {
45  mNode = mDoc;
46  }
47 
48  Writer::~Writer()
49  {
50  }
51 
52  void Writer::startNode(const std::string &name) const
53  {
54  mNode = mNode.append_child(name.c_str());
55  }
56 
57  void Writer::endNode() const
58  {
59  mNode = mNode.parent();
60  }
61 
62  void Writer::endDocument() const
63  {
64  mDoc.save_file(mName.c_str());
65  }
66 
67  void Writer::addAttribute(const std::string &name,
68  const std::string &value) const
69  {
70  mNode.append_attribute(name.c_str()) = value.c_str();
71  }
72 
73 } // namespace XML
74 
75 #endif // ENABLE_PUGIXML
Definition: libxml.cpp:86