YAPOG  0.0.1
Yet Another Pokemon Online Game
XmlTree.hpp
Go to the documentation of this file.
1 #ifndef YAPOG_XMLTREE_HPP
2 # define YAPOG_XMLTREE_HPP
3 
4 # include <memory>
5 
6 # include <boost/property_tree/xml_parser.hpp>
7 # include <boost/property_tree/ptree.hpp>
8 
9 # include "YAPOG/Macros.hpp"
10 # include "YAPOG/System/String.hpp"
11 # include "YAPOG/System/IOStream.hpp"
12 
13 namespace yap
14 {
15  class XmlTree;
16  typedef std::shared_ptr<XmlTree> XmlTreePtrType;
17 
19  {
21 
22  public:
23 
24  typedef boost::property_tree::ptree DataType;
25 
26  XmlTree ();
27  XmlTree (const XmlTree& copy);
28 
29  template <typename T>
30  const T Get (const String& name) const;
31 
32  template <typename T>
33  const T Get () const;
34 
35  template <typename T>
36  void Add (const String& name, const T& value);
37 
38  void Create (const String& rootName);
39  void CreateFromStream (IStream& iStream, const String& rootName);
40 
41  void CreateFromXmlTree (const String& rootName, XmlTree& copy);
42  void CreateFromRawData (DataType* data);
43 
45  void Dump (OStream& oStream);
46 
47  XmlTreePtrType ChangeRoot (const String& rootName);
48 
49  bool NodeExists (const String& name) const;
50 
51  const String& GetNode (int index) const;
52 
53  DataType* GetRootRawData () const;
54 
55  private:
56 
57  DataType& GetChild (const String& name);
58  DataType& AbsoluteGetChild (const String& name);
59 
60  DataType& GetRootData ();
61  const DataType& GetRootData () const;
62 
65  };
66 } // namespace yap
67 
69 
70 #endif // YAPOG_XMLTREE_HPP