00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024
00025
00026 #ifndef _XMLAdapter_
00027 #define _XMLAdapter_
00028
00029 #include "BasicXMLable.hxx"
00030 #include <sstream>
00031 #include <string>
00032
00033 namespace CLAM {
00034
00057 template <class T> class XMLAdapter : public BasicXMLable {
00058
00059 public:
00060 typedef BasicXMLable super;
00061 typedef T t_adaptee;
00062
00063 private:
00064 t_adaptee & mAdaptee;
00065
00066 public:
00082 XMLAdapter (t_adaptee & anAdaptee, const char * name=NULL, bool isXMLElement=false)
00083 : BasicXMLable(name, isXMLElement), mAdaptee(anAdaptee)
00084 {
00085 }
00086 XMLAdapter (const t_adaptee & anAdaptee, const char * name=NULL, bool isXMLElement=false)
00087 : BasicXMLable(name, isXMLElement), mAdaptee(const_cast<T&>(anAdaptee))
00088 {
00089 }
00090 virtual ~XMLAdapter()
00091 {
00092 };
00093
00094
00095 public:
00096
00097 std::string XMLContent() const
00098 {
00099
00100 std::stringstream str;
00101 str << mAdaptee << std::ends;
00102 return str.str();
00103 }
00104
00105
00106 bool XMLContent(std::istream & str)
00107 {
00108 str >> mAdaptee;
00109 return str!=NULL;
00110 }
00111
00112 public:
00113
00114 bool FulfilsInvariant()
00115 {
00116 return super::FulfilsInvariant();
00117 }
00118 };
00119
00120 }
00121 #endif//_XMLAdapter_
00122