|
Boost Users : |
From: Christian Henning (chhenning_at_[hidden])
Date: 2006-05-26 09:32:57
Thanks Robert, here is my proof of concept for a triple ( tuple with 3
entries ). Any comments? I'm on MSVC 7.1.
namespace boost {
namespace serialization {
// triple
template<class Archive, class F, class S, class T>
inline void serialize(
Archive & ar,
boost::tuple<F, S, T>& t,
const unsigned int /* file_version */
)
{
ar & boost::serialization::make_nvp("first" , t.get<0>() );
ar & boost::serialization::make_nvp("second", t.get<1>() );
ar & boost::serialization::make_nvp("third" , t.get<2>() );
}
} // serialization
} // namespace boost
using namespace std;
using namespace boost;
typedef tuple< string, string, string > Key;
typedef map< Key, int > MyMap;
void print( pair<Key, int> oEntry )
{
std::cout << oEntry.first;
std::cout << " - " << oEntry.second << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
MyMap aMap;
aMap[ make_tuple( "aa", "bb", "cc" ) ] = 90;
{
const MyMap& caMap = aMap;
ofstream ofs( "Settings.txt" );
boost::archive::text_oarchive oa( ofs );
oa & caMap;
}
MyMap aMap_2;
{
ifstream ifs( "Settings.txt" );
boost::archive::text_iarchive ia( ifs );
ia & aMap_2;
}
for_each( aMap_2.begin(), aMap_2.end(), print );
return 0;
}
Regards,
Christian
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net