Boost logo

Boost Users :

From: Miguel Silvestre (msilvestre_at_[hidden])
Date: 2007-01-04 12:31:40


Hi folks!

I've just installed the serialization boost library and I'm trying to run it
but I get the error in the subject.

I'm trying to integrate the serialization in my project and for the begining
I'm trying to follow the very simple example :-/.

I've already searched the internet for this error, and I get some pages but
without any answer...

So here is the code:

class A

{

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();

else

LoadObject();

return FE_OK;

}

int SilvTask::WriteObject()

{

A aux(12, 69.69f);

// create and open a character archive for output

std::ofstream ofs(m_filename.c_str());

boost::archive::text_oarchive oa(ofs);

//write class instance to archive

oa << 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 archive

ia >> newAux;

return FE_OK;

}

};

any ideias? Thanks

-- 
Miguel Silvestre


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