new tree file format

This commit is contained in:
vrd
2023-02-21 22:35:45 +02:00
parent ee152edbad
commit 78408bd223
11 changed files with 286 additions and 77 deletions
+6 -11
View File
@@ -60,10 +60,10 @@ void EventTime::print() const
}
Person::Person(const char* name, EventTime birth, bool isMale, EventTime death)
Person::Person(const char* name, EventTime birth, Sex sex, EventTime death)
: name_(name)
, birth_(birth)
, isMale_(isMale)
, sex(sex)
, death_(death)
{
}
@@ -71,7 +71,7 @@ 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_; //&& sex == other.sex; //TODO && day == other.day || !day || !other.day) && (month == other.month || !month || !other.month) && (year == other.year || !year || !other.year);
}
@@ -81,7 +81,7 @@ 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*>(&isMale_), sizeof(isMale_));
file.write(reinterpret_cast<const char*>(&sex), sizeof(sex));
//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));
@@ -97,7 +97,7 @@ void Person::read(std::ifstream &file)
nameBuf[nameLen] = '\0';
name_ = nameBuf;
file.read(reinterpret_cast<char*>(&isMale_), sizeof(isMale_));
file.read(reinterpret_cast<char*>(&sex), sizeof(sex));
//file.read(reinterpret_cast<char*>(&day), sizeof(day)); TODO
//file.read(reinterpret_cast<char*>(&month), sizeof(month));
//file.read(reinterpret_cast<char*>(&year), sizeof(year));
@@ -132,11 +132,6 @@ void Person::displayInfo()const
}
bool Person::isMale() const
{
return isMale_;
}
static U16 strUtf8Symbols(const std::string& str)
{
U16 num = 0;
@@ -172,7 +167,7 @@ void Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpous
WINDOW* pad = newpad(BOX_HEIGHT, width);
auto color_pair = COLOR_PAIR( selected ? COLOR_SELECTED
: (isMale_ ? COLOR_MALE : COLOR_FEMALE) );
: (sex ? COLOR_MALE : COLOR_FEMALE) );
wbkgd(pad, color_pair);
/* wattron(pad, color_pair); */