{
private:friend class boost::serialization::access;
int dumbi; float dumbf; template<class Archive> void serialize(Archive &ar, const unsigned int version){
ar & dumgf;
ar & dumbi;
}
public:A():dumbi(12), dumbf(69.69f)
{
}
A(
int dumb1, float dumb2) : dumbi(dumb1), dumbf(dumb2){
}
};
class
SilvTask { private: typedef DefaultTask Parent; int dumbi; float dumbf;A testA;
bool m_save, m_xml;std::string m_filename;
public:SilvTask():m_save(
false), dumbf(69.69f), dumbi(7), m_xml(false){
}
int SilvTask::ParseArguments(const std::vector<std::string>& args){
for(uint32 i = 0; i < (uint32)args.size(); i++){
if(args[i].find("-xml"))m_xml =
true; if(args[i].find("-save=") != std::string::npos){
m_filename = args[i].substr(6);
m_save =
true;}
else if(args[i].find("-load=" ) != std::string::npos){
m_filename = args[i].substr(6);
m_save =
false;}
}
return FE_OK;}
int SilvTask::LoadData(){
if(m_save)WriteObject();
elseLoadObject();
return FE_OK;}
int SilvTask::WriteObject(){
A aux(12, 69.69f);
// create and open a character archive for outputstd::ofstream ofs(m_filename.c_str());
boost::archive::text_oarchive oa(ofs);
//write class instance to archiveoa << aux;
return FE_OK;}
int SilvTask::LoadObject(){
A newAux;
std::ifstream ifs(m_filename.c_str(), std::ios::binary);
boost::archive::text_iarchive ia(ifs);
// read class state from archiveia >> newAux;
return FE_OK;}
};
any ideias? Thanks
--
Miguel Silvestre