summaryrefslogtreecommitdiff
path: root/lib/xml.h
blob: 2c3450acd5337f5a6f762bdf8f5342d87537f44a (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
/*
 *
 * xml.h
 *
 * (c) 2017 Jörg Wendel
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
 */

#ifndef __XML_H
#define __XML_H

//***************************************************************************
// Include
//***************************************************************************

#include <tinyxml2.h>

#include "common.h"

using namespace tinyxml2;

//***************************************************************************
// Class cXml
//***************************************************************************

class cXml
{
   public:

      cXml();

      int create(const char* rootName);
      int set(const char* data);

      XMLNode* appendElement(const char* name, const char* value, XMLNode* node = 0);
      XMLNode* appendElement(const char* name, int value, XMLNode* node = 0);

      XMLNode* getRoot()     { return root; }
      XMLElement* getFirst(XMLNode* node = 0);
      XMLElement* getNext(XMLNode* node);

      XMLElement* getElementByName(const char* name, XMLElement* element = 0);

      const char* toText();

   private:

      XMLDocument doc;
      XMLNode* root;
      XMLPrinter printer;
};

//***************************************************************************
#endif // __XML_H