polyXMLBase.h
1 /*
2  @copyright Russell Standish 2000-2013
3  @author Russell Standish
4  This file is part of Classdesc
5 
6  Open source licensed under the MIT license. See LICENSE for details.
7 */
8 
9 #ifndef POLYXMLBASE_H
10 #define POLYXMLBASE_H
11 
12 #include "xml_pack_base.h"
13 #include "xml_unpack_base.h"
14 
15 namespace classdesc
16 {
17  struct PolyXMLBase
18  {
19  virtual void xml_pack(xml_pack_t&, const string&) const=0;
20  virtual void xml_unpack(xml_unpack_t&, const string&)=0;
21  virtual ~PolyXMLBase() {}
22  };
23 
24  template <class T>
25  struct PolyXML: virtual public PolyXMLBase
26  {
27  void xml_pack(xml_pack_t& x, const string& d) const
28  //{::xml_pack(x,d,static_cast<const T&>(*this));}
29  // call access_pack to avoid double wrapping by the XML tag
30  {
32  (x,d,const_cast<T&>(static_cast<const T&>(*this)));
33  }
34 
35  void xml_unpack(xml_unpack_t& x, const string& d)
36  {::xml_unpack(x,d,static_cast<T&>(*this));}
37 
38  };
39 
40  template <> struct tn<PolyXMLBase>
41  {
42  static std::string name()
43  {return "classdesc::PolyXMLBase";}
44  };
45  template <class T> struct tn<PolyXML<T> >
46  {
47  static std::string name()
48  {return "classdesc::PolyXML<"+typeName<T>()+">";}
49  };
50 }
51 
52 #endif
53 
XML serialisation descriptor.
Definition: classdesc_access.h:23
Definition: classdesc.h:375
Definition: xml_unpack_base.h:268
Definition: xml_pack_base.h:49
Contains definitions related to classdesc functionality.
Definition: arrays.h:2514
Definition: polyXMLBase.h:25
Definition: polyXMLBase.h:17
XML deserialisation descriptor.