serialization nearly ready for containment

This commit is contained in:
Marc Wäckerlin
2009-04-24 07:13:10 +00:00
parent 37fd5e8695
commit 17dc91d35e
6 changed files with 133 additions and 35 deletions

View File

@@ -17,6 +17,34 @@
#include <typeinfo>
#include <stdexcept>
#include <cassert>
#include <iostream>
#include <iomanip>
class MethodTrace {
public:
MethodTrace(const void* addr, const std::string& name) throw():
_addr(addr), _name(name) {
std::clog<<std::hex<<std::setw(15)<<_addr<<": "
<<std::dec<<std::setw(2+_level)
<<std::setfill(' ')<<"\\ "<<_name<<std::endl;
++_level;
}
~MethodTrace() throw() {
--_level;
std::clog<<std::hex<<std::setw(15)<<_addr<<": "<<std::dec
<<std::setw(2+_level)<<std::setfill(' ')
<<"/ "<<_name<<std::endl;
}
private:
const void* _addr;
const std::string _name;
static unsigned int _level;
};
#define TRACE MethodTrace XXX_METHOD(this, __PRETTY_FUNCTION__)
#define LOG(X) std::clog<<__PRETTY_FUNCTION__<<"\t**** "<<X<<std::endl
/*! @mainpage
@section maintitle C++ XML Class Library
@@ -646,6 +674,7 @@ namespace xml {
Factory& operator=(const Node& t) throw();
Factory& append(const Node& node) throw();
const Node& operator*() const throw(factory_not_valid);
const Node*const operator->() const throw(factory_not_valid);
operator bool() const throw();
friend std::ostream& operator<<(std::ostream& os,
const Factory& factory) throw();
@@ -764,9 +793,13 @@ namespace xml {
Serialize() throw();
Serialize(const std::string& className) throw();
virtual ~Serialize();
void className(const std::string& name) throw();
Serialize& className(const std::string& name) throw();
Serialize& persist(Serialize& ser) throw();
template<typename TYPE>
Serialize& persist(TYPE& member, const std::string& name) {
Serialize& persist(TYPE& member, const std::string& name) throw() {
assert(mapName<TYPE>().find(name)==mapName<TYPE>().end());
assert(mapMember<TYPE>().find(&member)==mapMember<TYPE>().end());
assert(_xmlNames.find(name)==_xmlNames.end());
mapName<TYPE>()[name] = &member;
mapMember<TYPE>()[&member] = name;
_xmlNames[name] = &typeid(TYPE);