1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 2 // 3 // demo_xml_load.cpp 4 // 5 // (C) Copyright 2002-4 Robert Ramey - http://www.rrsd.com . 6 // Use, modification and distribution is subject to the Boost Software 7 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 8 // http://www.boost.org/LICENSE_1_0.txt) 9 10 #include <iostream> 11 #include <string> 12 #include <boost/archive/tmpdir.hpp> 13 14 #include <boost/archive/xml_iarchive.hpp> 15 16 #include "demo_gps.hpp" 17 18 void restore_schedule(bus_schedule & s,const char * filename)19restore_schedule(bus_schedule &s, const char * filename) 20 { 21 // open the archive 22 std::ifstream ifs(filename); 23 assert(ifs.good()); 24 boost::archive::xml_iarchive ia(ifs); 25 26 // restore the schedule from the archive 27 ia >> BOOST_SERIALIZATION_NVP(s); 28 } 29 main(int argc,char * argv[])30int main(int argc, char *argv[]) 31 { 32 // make a new schedule 33 bus_schedule new_schedule; 34 35 std::string filename(boost::archive::tmpdir()); 36 filename += "/demo_save.xml"; 37 38 restore_schedule(new_schedule, filename.c_str()); 39 40 // and display 41 std::cout << "\nrestored schedule"; 42 std::cout << new_schedule; 43 44 return 0; 45 } 46