// SerializationDemo.cpp

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <exception>

#include <boost/serialization/map.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>

using namespace std;
using namespace boost::archive;

int main()
{
  map<string, string> am;

  am["c"] = "COUNTRY";
  am["city"] = "CITY";
  am["email"] = "SMTP";
  am["homephone"] = "PRIVTEL";
  am["l"] = "DIVISION";
  am["mobile"] = "GSM";
  am["ou"] = "COMPANY";
  am["postalcode"] = "ZIP";
  am["preferredlanguage"] = "LANGUAGE_ID";
  am["st"] = "STATE";
  am["street"] = "ADDR1";

  ostringstream os;
  text_oarchive oa(os);

  try {
    oa << am;
  }
  catch (archive_exception& e) {
    cout << "archive exception: " << e.what() << endl;
  }
  catch (exception& e) {
    cout << "std exception: " << e.what() << endl;
  }

  cout << "'" << os.str() << "'" << endl;
}