当尝试使用升压序列化保存数据库,我遇到我解决不了段错误。 请你帮忙吗? 任何的建议是greately理解。 我下面牵制声明的罪魁祸首,但不知道如何解决它
oa << *this;
我的代码部分低于:
template<class Archive>
void nDB::serialize(Archive &ar, const unsigned int version) {
ar & _LAYERS;
ar & _MACROS;
ar & _MODULES;
ar & _INSTS;
}
void nDB::save_db(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;
ofs.close();
}
您好,我是能够发出针点在我的数据库中的循环引用。 代码低于:
template<class Archive>
void pin::serialize(Archive &ar, const unsigned int version) {
ar & pin_Port;
ar & pin_Layer;
}
和
template<class Archive>
void port::serialize(Archive & ar, const unsigned int version){
ar & port_Name;
ar & port_Use;
ar & port_Dir;
ar & port_PINS;
}
你好下面是我的类定义
class pin {
public:
port* pin_Port;
layer* pin_Layer;
// rect* pin_shape;
pin();
~pin();
void set_port(port*);
void set_layer(layer*);
string get_name();
port* get_port();
layer* get_layer();
string get_layer_name();
double get_layer_width();
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version);
};
class port {
public:
string port_Name;
char port_Use;
char port_Dir;
pin_vector port_PINS;
port();
~port();
void set_name(string);
void set_use(int);
void set_dir(int);
string get_name(void);
string get_use(void);
string get_dir(void);
void add_pin(pin*);
pin_vector get_all_pins(void);
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version);
};