ブーストシリアル化を使用してデータをディスクに保存できました。しかし、私はデータを取り戻すことができませんでした。私は何が間違っていたのか教えてくれませんか?以下はブーストを使用してディスクにシリアル化した後にデータをロードできませんでした。
Insert macro mac1 into database OK!
Insert macro mac2 into database OK!
Insert macro mac3 into database OK!
Insert port P1 OK!
Insert port P2 OK!
Insert port P2 OK!
Insert port P3 OK!
Insert port P1 OK!
Insert port P3 OK!
Layer mac3 is found
Macro mac3 has these port:
Port P3 is found
Port P1 is found
Port P3 of macro mac3 has use CLOCK and dir INOUT
Port P1 of macro mac3 has use POWER and dir OUTPUT
:
は以下void nDB::save_macros(string filename) {
std::ofstream ofs(filename.c_str(), std::ios::out | std::ios::binary);
//assert(ofs.good());
boost::archive::binary_oarchive oa(ofs);
oa << this;
}
void nDB::load_macros(string filename) {
std::ifstream ifs(filename.c_str());
//assert(ifs.good());
boost::archive::binary_iarchive ia(ifs);
nDB *db = new nDB;
ia >> db;
*this = *db;
}
以下は私の実行結果は、実行を保存している私のシリアル化のインスタンス化
template<class Archive>
void nDB::serialize(Archive &ar, const unsigned int version) {
boost::unordered_map<string,macro*,myhash,cmp_str>::iterator M_IT;
boost::unordered_map<string,layer*,myhash,cmp_str>::iterator L_IT;
for (L_IT = _LAYERS.begin();L_IT != _LAYERS.end();L_IT++) {
string tmpstr = L_IT->first;
//ar & L_IT->first;
ar & tmpstr;
ar & *(L_IT->second);
}
for (M_IT = _MACROS.begin();M_IT != _MACROS.end();M_IT++) {
string tmpstr = M_IT->first;
//ar & M_IT->first;
ar & tmpstr;
ar & *(M_IT->second);
}
}
ある以下
は私のコードです、ありがとうはm yの結果ローディング実行ERROR:: Could not find macro mac3 in database
ありがとうAldo、私は実際には、関数unizered_mapは、関数を初期化しました。私はあなたがそのように使うことができるか分からなかった。ご清聴ありがとうございます。 –
http://stackoverflow.com/questions/4287299/boostserialization-of-boostunordered-map – Pablo