1 #ifndef OPENMM_XML_SERIALIZER_H_
2 #define OPENMM_XML_SERIALIZER_H_
35 #include "openmm/serialization/SerializationNode.h"
36 #include "openmm/serialization/SerializationProxy.h"
37 #include "openmm/OpenMMException.h"
38 #include "openmm/internal/windowsExport.h"
59 static void serialize(
const T*
object,
const std::string& rootName, std::ostream& stream) {
60 const SerializationProxy& proxy = SerializationProxy::getProxy(
typeid(*
object));
61 SerializationNode node;
62 node.setName(rootName);
63 proxy.serialize(
object, node);
64 if (node.hasProperty(
"type"))
65 throw OpenMMException(proxy.getTypeName()+
" created node with reserved property 'type'");
66 node.setStringProperty(
"type", proxy.getTypeName());
67 serialize(node, stream);
77 return reinterpret_cast<T*
>(deserializeStream(stream));
80 static void serialize(
const SerializationNode& node, std::ostream& stream);
81 static void* deserializeStream(std::istream& stream);
82 static TiXmlElement* encodeNode(
const SerializationNode& node);
83 static void decodeNode(SerializationNode& node,
const TiXmlElement& element);