Update of /cvsroot/boost/boost/libs/graph/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27723/libs/graph/test

Modified Files:
      Tag: RC_1_34_0
        serialize.cpp 
Log Message:
Fix adjacency list and property map serialization

Index: serialize.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/graph/test/serialize.cpp,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- serialize.cpp       3 Nov 2006 19:17:56 -0000       1.1.2.2
+++ serialize.cpp       5 Feb 2007 22:16:58 -0000       1.1.2.3
@@ -14,15 +14,15 @@
 #include <boost/graph/breadth_first_search.hpp>
 #include <map>
 #include <boost/graph/adj_list_serialize.hpp>
-#include <boost/archive/text_iarchive.hpp>
-#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/xml_iarchive.hpp>
+#include <boost/archive/xml_oarchive.hpp>
 
 struct vertex_properties {
   std::string name;
 
   template<class Archive>
   void serialize(Archive & ar, const unsigned int version) {
-    ar & name;
+    ar & BOOST_SERIALIZATION_NVP(name);
   }  
 };
 
@@ -31,7 +31,7 @@
 
   template<class Archive>
   void serialize(Archive & ar, const unsigned int version) {
-    ar & name;
+    ar & BOOST_SERIALIZATION_NVP(name);
   }  
 };
 
@@ -40,6 +40,8 @@
 typedef adjacency_list<vecS, vecS, undirectedS, 
                vertex_properties, edge_properties> Graph;
 
+typedef graph_traits<Graph>::vertex_descriptor vd_type;
+
 
 typedef adjacency_list<vecS, vecS, undirectedS, 
                vertex_properties> Graph_no_edge_property;
@@ -48,22 +50,34 @@
 {
   {
     std::ofstream ofs("./kevin-bacon2.dat");
-    archive::text_oarchive oa(ofs);
+    archive::xml_oarchive oa(ofs);
     Graph g;
-    oa << g;
+               vertex_properties vp;
+               vp.name = "A";
+               vd_type A = add_vertex( vp, g );
+               vp.name = "B";
+               vd_type B = add_vertex( vp, g );
+
+               edge_properties ep;
+               ep.name = "a";
+               add_edge( A, B, ep, g);
+
+    oa << BOOST_SERIALIZATION_NVP(g);
 
     Graph_no_edge_property g_n;
-    oa << g_n;
+    oa << BOOST_SERIALIZATION_NVP(g_n);
   }
 
   {
     std::ifstream ifs("./kevin-bacon2.dat");
-    archive::text_iarchive ia(ifs);
+    archive::xml_iarchive ia(ifs);
     Graph g;
-    ia >> g;
+    ia >> BOOST_SERIALIZATION_NVP(g);
+
+               if  (!( g[*(vertices( g ).first)].name == "A" )) return -1;
 
     Graph_no_edge_property g_n;
-    ia >> g_n;
+    ia >> BOOST_SERIALIZATION_NVP(g_n);
   }
   return 0;
 }


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to