From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/graph/test/serialize.cpp | 83 +++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/boost/libs/graph/test/serialize.cpp (limited to 'src/boost/libs/graph/test/serialize.cpp') diff --git a/src/boost/libs/graph/test/serialize.cpp b/src/boost/libs/graph/test/serialize.cpp new file mode 100644 index 00000000..5f5a6712 --- /dev/null +++ b/src/boost/libs/graph/test/serialize.cpp @@ -0,0 +1,83 @@ +// Copyright (C) 2006 Trustees of Indiana University +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct vertex_properties { + std::string name; + + template + void serialize(Archive & ar, const unsigned int /*version*/) { + ar & BOOST_SERIALIZATION_NVP(name); + } +}; + +struct edge_properties { + std::string name; + + template + void serialize(Archive & ar, const unsigned int /*version*/) { + ar & BOOST_SERIALIZATION_NVP(name); + } +}; + +using namespace boost; + +typedef adjacency_list Graph; + +typedef graph_traits::vertex_descriptor vd_type; + + +typedef adjacency_list Graph_no_edge_property; + +int main() +{ + { + std::ofstream ofs("./kevin-bacon2.dat"); + archive::xml_oarchive oa(ofs); + Graph 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 << BOOST_SERIALIZATION_NVP(g_n); + } + + { + std::ifstream ifs("./kevin-bacon2.dat"); + archive::xml_iarchive ia(ifs); + Graph g; + ia >> BOOST_SERIALIZATION_NVP(g); + + if (!( g[*(vertices( g ).first)].name == "A" )) return -1; + + Graph_no_edge_property g_n; + ia >> BOOST_SERIALIZATION_NVP(g_n); + } + return 0; +} -- cgit v1.2.3