我试图在我的类中获取两个数组以使用 boost 序列化库。我可以很好地保存数据,但由于某种原因,我无法将其加载回来。我认为它与 ia >> *this; 但我不知道如何解决它。任何人都可以指出我正确的轨道吗?
class foo
{
private:
int tileType[512];
int tileSubType[512];
friend std::ostream & operator<<(std::ostream &os, const foo &gp);
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & tileType;
ar & tileSubType;
}
public:
foo();
void loadType(string data)
{
std::stringstream is(data);
boost::archive::text_iarchive ia(is);
ia >> *this;
}
string saveType()
{
stringstream ss(stringstream::in | stringstream::out);
boost::archive::text_oarchive oa(ss);
oa << this;
return ss.str().c_str();
}
};