#include #include #include #include #include #include #include "boost/version.hpp" int main(int argc, char *argv[]) { if ( argc > 1 && !strcmp(argv[1], "write") ) { std::map m; m["aaa"] = 111; m["bbb"] = 222; std::string filename("archive-"); filename+=BOOST_LIB_VERSION; filename+=".ser"; std::ofstream fb(filename); boost::archive::binary_oarchive oa(fb); oa << m; } else if ( argc > 2 && !strcmp(argv[1], "read") ) { std::map m; std::string filename(argv[2]); std::ifstream fb(filename); boost::archive::binary_iarchive ia(fb); ia >> m; for (std::map::const_iterator iter=m.begin(); iter!=m.end(); ++iter) { std::cout << "m[" << iter->first << "] = " << iter->second << std::endl; } } else { printf("parameter error.\n"); } }