Metatemplateprogramming is really cool
This commit is contained in:
@@ -829,25 +829,8 @@ namespace xml {
|
||||
virtual ~Serialize();
|
||||
Serialize& operator=(const Serialize& other) throw();
|
||||
Serialize& className(const std::string& name) throw();
|
||||
Serialize& persist(Serialize& member,
|
||||
const std::string& name) throw();
|
||||
template<typename TYPE, class ALLOC>
|
||||
Serialize& persist(std::list<TYPE, ALLOC>& member,
|
||||
const std::string& name) throw() {
|
||||
return persist(member, name, name);
|
||||
}
|
||||
template<typename TYPE, class ALLOC>
|
||||
Serialize& persist(std::list<TYPE, ALLOC>& member,
|
||||
const std::string& list,
|
||||
const std::string& item) throw() {
|
||||
_xmlNames[list] = &member;
|
||||
Serialize ser(list);
|
||||
TYPE dummy;
|
||||
ser.persist(dummy, item);
|
||||
*_xmlFactory<<(xml::Node(list).limits(1,1)
|
||||
<<(*ser._xmlFactory)[0].limits(0, 0));
|
||||
return *this;
|
||||
}
|
||||
virtual Serialize& persist(Serialize& member,
|
||||
const std::string& name) throw();
|
||||
Serialize& persist(bool& member,
|
||||
const std::string& name) throw();
|
||||
Serialize& persist(char& member,
|
||||
@@ -885,6 +868,7 @@ namespace xml {
|
||||
protected:
|
||||
virtual void initXmlMembers();
|
||||
private:
|
||||
public: //! @todo
|
||||
void clear() throw();
|
||||
void copy(const Serialize& o) throw();
|
||||
template<typename TYPE>
|
||||
@@ -896,8 +880,8 @@ namespace xml {
|
||||
_xmlFactory = schema;
|
||||
return *this;
|
||||
}
|
||||
void fromNode(boost::any member, const xml::Node& node);
|
||||
void toNode(const boost::any member, xml::Node& node) const;
|
||||
virtual void fromNode(boost::any member, const xml::Node& node);
|
||||
virtual void toNode(const boost::any member, xml::Node& node) const;
|
||||
/*
|
||||
template<typename TYPE, class ALLOC>
|
||||
void fromNode(std::list<TYPE, ALLOC>* member, xml::Node& node) {
|
||||
@@ -911,6 +895,35 @@ namespace xml {
|
||||
static std::set<ToNodeFunc> _toNode;
|
||||
};
|
||||
|
||||
template<class TYPE, class ALLOC=std::allocator<TYPE> > class List:
|
||||
public std::list<TYPE, ALLOC>, public Serialize {
|
||||
public:
|
||||
List() {}
|
||||
List(const List& o): std::list<TYPE, ALLOC>(o), Serialize(o) {}
|
||||
List(const std::string& className) throw(): Serialize(className) {}
|
||||
virtual ~List() {}
|
||||
protected:
|
||||
/*virtual void initXmlMembers() {
|
||||
LOG("initXmlMembers std::list");
|
||||
//_xmlNames[list] = this;
|
||||
TYPE dummy;
|
||||
std::string itemName("item");
|
||||
if (typeid(TYPE*)==typeid(Serialize*)) {
|
||||
Serialize* ser((Serialize*)&dummy);
|
||||
if (!ser->_xmlFactory) ser->initXmlMembers();
|
||||
itemName = **ser->_xmlFactory;
|
||||
}
|
||||
persist(dummy, itemName);
|
||||
_xmlFactory->limits(0, 0);
|
||||
}
|
||||
virtual void fromNode(boost::any member, const xml::Node& node) {
|
||||
LOG("fromNode std::list");
|
||||
}
|
||||
virtual void toNode(const boost::any member, xml::Node& node) const {
|
||||
LOG("toNode std::list");
|
||||
}*/
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user