fix save and load
This commit is contained in:
+3
-6
@@ -62,7 +62,6 @@ void EventTime::print() const
|
||||
|
||||
Person::Person(const char* name, EventTime birth, bool isMale, EventTime death)
|
||||
: name_(name)
|
||||
, numRel_(0)
|
||||
, birth_(birth)
|
||||
, isMale_(isMale)
|
||||
, death_(death)
|
||||
@@ -72,24 +71,23 @@ Person::Person(const char* name, EventTime birth, bool isMale, EventTime death)
|
||||
|
||||
bool Person::operator==(const Person &other)const
|
||||
{
|
||||
return name_ == other.name_ && isMale_ == other.isMale_; //TODO && day == other.day || !day || !other.day) && (month == other.month || !month || !other.month) && (year == other.year || !year || !other.year);
|
||||
return name_ == other.name_; //&& isMale_ == other.isMale_; //TODO && day == other.day || !day || !other.day) && (month == other.month || !month || !other.month) && (year == other.year || !year || !other.year);
|
||||
}
|
||||
|
||||
|
||||
void Person::save(std::ofstream &file)const
|
||||
void Person::write(std::ofstream &file)const
|
||||
{
|
||||
//
|
||||
char nameLen = name_.size();
|
||||
file.write(reinterpret_cast<char*>(&nameLen), sizeof(nameLen));
|
||||
file.write(name_.data(), nameLen * sizeof(name_[0]));
|
||||
file.write(reinterpret_cast<const char*>(&numRel_), sizeof(numRel_));
|
||||
file.write(reinterpret_cast<const char*>(&isMale_), sizeof(isMale_));
|
||||
//file.write(reinterpret_cast<const char*>(&day), sizeof(day)); TODO
|
||||
//file.write(reinterpret_cast<const char*>(&month), sizeof(month));
|
||||
//file.write(reinterpret_cast<const char*>(&year), sizeof(year));
|
||||
}
|
||||
|
||||
void Person::load(std::ifstream &file)
|
||||
void Person::read(std::ifstream &file)
|
||||
{
|
||||
U8 nameLen;
|
||||
file.read((char*)&nameLen, sizeof(nameLen)); //Check len
|
||||
@@ -99,7 +97,6 @@ void Person::load(std::ifstream &file)
|
||||
nameBuf[nameLen] = '\0';
|
||||
name_ = nameBuf;
|
||||
|
||||
file.read(reinterpret_cast<char*>(&numRel_), sizeof(numRel_));
|
||||
file.read(reinterpret_cast<char*>(&isMale_), sizeof(isMale_));
|
||||
//file.read(reinterpret_cast<char*>(&day), sizeof(day)); TODO
|
||||
//file.read(reinterpret_cast<char*>(&month), sizeof(month));
|
||||
|
||||
Reference in New Issue
Block a user