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
inline void serialize(
Archive & ar,
boost::tuple& 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 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