|
Boost Users : |
Subject: [Boost-users] Specifying a NVP wrapper
From: simone pilozzi (simonepilozzi_at_[hidden])
Date: 2011-03-18 09:30:12
Hi All,
I am working with the serialization library and I made an example class like
this.
class Contact{
public:
Contact(){}
Contact(string& name, int phonenumber,long contactdate):name_(name),
pnumber_(phonenumber),contactdate_(contactdate){}
const string getName() const{return name_;}
const long getPhone() const{return pnumber_;}
const long getDate() const{return contactdate_;}
private:
string name_;
long pnumber_,contactdate_;
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive& ar, const unsigned int version){
ar & boost::serialization::make_nvp("name", name_);
ar & boost::serialization::make_nvp("phone", pnumber_);
ar & boost::serialization::make_nvp("contactdate", contactdate_);
}
};
Now I would like to allocate the xml file created with the use of this class
in a vector, and this is the function:
void getFromFile(std::vector<Contact>& contacts,const char* file){
std::ifstream ifile(file);
boost::archive::xml_iarchive ia(ifile);
ia >> contacts;
ifile.close();
}
The compiler complains because it misses a NVP wrapper for the class. I
could not find an example for that in boost.
Could you help me ?
Thanks in advance
Simone
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