pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata groundpiece_data.cxx,1


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata groundpiece_data.cxx,1.7,1.8 groundpiece_data.hxx,1.3,1.4
Date: 20 Dec 2002 18:45:44 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/worldobjsdata
In directory dark:/tmp/cvs-serv22357/worldobjsdata

Modified Files:
        groundpiece_data.cxx groundpiece_data.hxx 
Log Message:
added generic reader/write classes


Index: groundpiece_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/groundpiece_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- groundpiece_data.cxx        28 Sep 2002 19:31:06 -0000      1.7
+++ groundpiece_data.cxx        20 Dec 2002 18:45:41 -0000      1.8
@@ -21,6 +21,8 @@
 #include "../editorobjs/groundpiece_obj.hxx"
 #include "../worldobjs/groundpiece.hxx"
 #include "../xml_helper.hxx"
+#include "../file_reader.hxx"
+#include "../file_writer.hxx"
 #include "groundpiece_data.hxx"
 
 namespace WorldObjsData {
@@ -121,6 +123,30 @@
   XMLhelper::write_desc_xml(xml, desc);
   XMLhelper::write_vector_xml(xml, pos);
   xml << "</worldobj>\n" << std::endl;
+}
+
+void 
+GroundpieceData::serialize(FileWriter& writer)
+{
+  writer.begin_section("groundpiece");
+  writer.write_string("type", Groundtype::type_to_string (gptype));
+  //writer.write_desc  ("desc", desc);
+  writer.write_vector("pos",  pos);
+  writer.end_section();
+}
+
+void 
+GroundpieceData::deserialize(FileReader& reader)
+{
+  std::string gptype_str = "default value";
+
+  // Factory in the Reader ensures that we are in the 'groundpiece'
+  // section
+  reader.read_string("type", &gptype_str);
+  //reader.read_desc  ("desc", &desc);
+  reader.read_vector("pos",  &pos);
+
+  gptype = Groundtype::string_to_type (gptype_str);
 }
 
 } // namespace WorldObjsData

Index: groundpiece_data.hxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/groundpiece_data.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- groundpiece_data.hxx        28 Sep 2002 11:52:26 -0000      1.3
+++ groundpiece_data.hxx        20 Dec 2002 18:45:41 -0000      1.4
@@ -27,6 +27,9 @@
 #include "../worldobj_data.hxx"
 #include "../groundtype.hxx"
 
+class FileWriter;
+class FileReader;
+
 namespace WorldObjsData {
 
 class GroundpieceData : public WorldObjData
@@ -50,6 +53,9 @@
   EditorObjLst create_EditorObj ();
 
   void write_xml (std::ostream& xml);
+
+  void serialize(FileWriter& writer);
+  void deserialize(FileReader& reader);
 };
 
 } // namespace WorldObjsData




reply via email to

[Prev in Thread] Current Thread [Next in Thread]