|
|
@ -1058,9 +1058,7 @@ namespace xml { |
|
|
|
Serialize& Serialize::persist(Serialize& ser, |
|
|
|
Serialize& Serialize::persist(Serialize& ser, |
|
|
|
const std::string& name) throw() { |
|
|
|
const std::string& name) throw() { |
|
|
|
if (!ser._xmlFactory) ser.initXmlMembers(); |
|
|
|
if (!ser._xmlFactory) ser.initXmlMembers(); |
|
|
|
mapName<Serialize>()[std::make_pair(this, name)] = &ser; |
|
|
|
_xmlNames[name] = &ser; |
|
|
|
mapMember<Serialize>()[&ser] = name; |
|
|
|
|
|
|
|
_xmlNames[name] = &typeid(Serialize); |
|
|
|
|
|
|
|
xml::Node schema(*_xmlFactory); |
|
|
|
xml::Node schema(*_xmlFactory); |
|
|
|
xml::Node node(xml::Node(name).limits(1,1)); |
|
|
|
xml::Node node(xml::Node(name).limits(1,1)); |
|
|
|
for (xml::Node::size_type i(0); i<ser._xmlFactory->children(); ++i) |
|
|
|
for (xml::Node::size_type i(0); i<ser._xmlFactory->children(); ++i) |
|
|
@ -1125,12 +1123,12 @@ namespace xml { |
|
|
|
if (!_xmlFactory) const_cast<Serialize*>(this)->initXmlMembers(); |
|
|
|
if (!_xmlFactory) const_cast<Serialize*>(this)->initXmlMembers(); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
for (std::map<std::string, const std::type_info*>::const_iterator |
|
|
|
for (std::map<std::string, boost::any>::const_iterator |
|
|
|
it(_xmlNames.begin()); |
|
|
|
it(_xmlNames.begin()); |
|
|
|
it!=_xmlNames.end(); ++it) { |
|
|
|
it!=_xmlNames.end(); ++it) { |
|
|
|
#define QWERTZ_CHECK_TYPE_ZTREWQ___XXX(TYPE) \ |
|
|
|
#define QWERTZ_CHECK_TYPE_ZTREWQ___XXX(TYPE) \ |
|
|
|
if (*it->second==typeid(TYPE)) \
|
|
|
|
if (it->second.type()==typeid(TYPE*)) \
|
|
|
|
toNode(mapName<TYPE>()[std::make_pair(this, it->first)], \
|
|
|
|
toNode(boost::any_cast<TYPE*>(it->second), \
|
|
|
|
node[it->first]); \
|
|
|
|
node[it->first]); \
|
|
|
|
else |
|
|
|
else |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(Serialize) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(Serialize) |
|
|
@ -1150,7 +1148,7 @@ namespace xml { |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned long) |
|
|
|
throw std::runtime_error(it->second->name()); |
|
|
|
throw std::runtime_error(it->first); |
|
|
|
#undef QWERTZ_CHECK_TYPE_ZTREWQ___XXX |
|
|
|
#undef QWERTZ_CHECK_TYPE_ZTREWQ___XXX |
|
|
|
}
|
|
|
|
}
|
|
|
|
os<<node; |
|
|
|
os<<node; |
|
|
@ -1161,12 +1159,12 @@ namespace xml { |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
std::auto_ptr<xml::Node> node(factory.read(is)); |
|
|
|
std::auto_ptr<xml::Node> node(factory.read(is)); |
|
|
|
for (std::map<std::string, const std::type_info*>::const_iterator |
|
|
|
for (std::map<std::string, boost::any>::const_iterator |
|
|
|
it(_xmlNames.begin()); |
|
|
|
it(_xmlNames.begin()); |
|
|
|
it!=_xmlNames.end(); ++it) { |
|
|
|
it!=_xmlNames.end(); ++it) { |
|
|
|
#define QWERTZ_CHECK_TYPE_ZTREWQ___XXX(TYPE) \ |
|
|
|
#define QWERTZ_CHECK_TYPE_ZTREWQ___XXX(TYPE) \ |
|
|
|
if (*it->second==typeid(TYPE)) \
|
|
|
|
if (it->second.type()==typeid(TYPE*)) \
|
|
|
|
fromNode(mapName<TYPE>()[std::make_pair(this, it->first)], \
|
|
|
|
fromNode(boost::any_cast<TYPE*>(it->second), \
|
|
|
|
(*node)[it->first]); \
|
|
|
|
(*node)[it->first]); \
|
|
|
|
else |
|
|
|
else |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(Serialize) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(Serialize) |
|
|
@ -1186,7 +1184,7 @@ namespace xml { |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned long) |
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned long) |
|
|
|
throw std::runtime_error(it->second->name()); |
|
|
|
throw std::runtime_error(it->first); |
|
|
|
#undef QWERTZ_CHECK_TYPE_ZTREWQ___XXX |
|
|
|
#undef QWERTZ_CHECK_TYPE_ZTREWQ___XXX |
|
|
|
} |
|
|
|
} |
|
|
|
return is; |
|
|
|
return is; |
|
|
@ -1199,40 +1197,11 @@ namespace xml { |
|
|
|
} |
|
|
|
} |
|
|
|
void Serialize::initXmlMembers() {} |
|
|
|
void Serialize::initXmlMembers() {} |
|
|
|
void Serialize::clear() throw() { |
|
|
|
void Serialize::clear() throw() { |
|
|
|
// Remove my entries from the maps
|
|
|
|
_xmlNames.clear(); |
|
|
|
for (std::map<std::string, const std::type_info*>::const_iterator |
|
|
|
_xmlFactory.reset(); |
|
|
|
it(_xmlNames.begin()); |
|
|
|
|
|
|
|
it!=_xmlNames.end(); ++it) { |
|
|
|
|
|
|
|
#define QWERTZ_CHECK_TYPE_ZTREWQ___XXX(TYPE) \ |
|
|
|
|
|
|
|
if (*it->second==typeid(TYPE)) { \
|
|
|
|
|
|
|
|
mapMember<TYPE>() \
|
|
|
|
|
|
|
|
.erase(mapName<TYPE>()[std::make_pair(this, it->first)]); \
|
|
|
|
|
|
|
|
mapName<TYPE>().erase(std::make_pair(this, it->first)); \
|
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(Serialize) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(std::string) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(float) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(double) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(bool) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(char) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed char) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned char) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(short) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed short) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned short) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(int) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed int) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned int) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(long) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(signed long) |
|
|
|
|
|
|
|
QWERTZ_CHECK_TYPE_ZTREWQ___XXX(unsigned long) |
|
|
|
|
|
|
|
{} // ignore coding error here, but memory leaks - better abort?
|
|
|
|
|
|
|
|
#undef QWERTZ_CHECK_TYPE_ZTREWQ___XXX |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void Serialize::copy(const Serialize& o) throw() { |
|
|
|
void Serialize::copy(const Serialize& o) throw() { |
|
|
|
clear(); |
|
|
|
clear(); |
|
|
|
_xmlFactory.reset(); |
|
|
|
|
|
|
|
initXmlMembers(); |
|
|
|
initXmlMembers(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|