From 0754f2a7af831922e26c12e707dfb6724897322f Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 15 Nov 2011 00:05:26 +0200 Subject: [PATCH] ToolDefManager serialization --- src/tooldef.cpp | 37 ++++++++++++++++++++++++++++++++++++- src/tooldef.h | 3 +++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/tooldef.cpp b/src/tooldef.cpp index 93bedf92..1c85dbd8 100644 --- a/src/tooldef.cpp +++ b/src/tooldef.cpp @@ -66,7 +66,7 @@ void ToolDefinition::deSerialize(std::istream &is) { int version = readU8(is); if(version != 0) throw SerializationError( - "unsupported ToolDiggingProperties version"); + "unsupported ToolDefinition version"); imagename = deSerializeString(is); properties.basetime = readF1000(is); properties.dt_weight = readF1000(is); @@ -133,6 +133,41 @@ public: m_tool_definitions[toolname] = new ToolDefinition(def); return true; } + virtual void serialize(std::ostream &os) + { + writeU8(os, 0); // version + u16 count = m_tool_definitions.size(); + writeU16(os, count); + for(core::map::Iterator + i = m_tool_definitions.getIterator(); + i.atEnd() == false; i++){ + std::string name = i.getNode()->getKey(); + ToolDefinition *def = i.getNode()->getValue(); + // Serialize name + os<serialize(tmp_os); + os< m_tool_definitions; diff --git a/src/tooldef.h b/src/tooldef.h index fdb02b01..2c758d90 100644 --- a/src/tooldef.h +++ b/src/tooldef.h @@ -85,6 +85,9 @@ public: const std::string &toolname) const =0; virtual bool registerTool(std::string toolname, const ToolDefinition &def)=0; + + virtual void serialize(std::ostream &os)=0; + virtual void deSerialize(std::istream &is)=0; }; IWritableToolDefManager* createToolDefManager(); -- 2.30.2