This commit is contained in:
vrd
2023-02-24 09:00:29 +02:00
parent 864d40cb81
commit e626470f71
5 changed files with 34 additions and 20 deletions
+13 -13
View File
@@ -60,8 +60,8 @@ void EventTime::print() const
}
Person::Person(const char* name, EventTime birth, Sex sex, EventTime death)
: name_(name)
Person::Person(const char* aName, EventTime birth, Sex aSex, EventTime death)
: name(aName)
, birth_(birth)
, sex(sex)
, death_(death)
@@ -71,16 +71,16 @@ Person::Person(const char* name, EventTime birth, Sex sex, EventTime death)
bool Person::operator==(const Person &other)const
{
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);
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);
}
void Person::write(std::ofstream &file)const
{
//
char nameLen = name_.size();
char nameLen = name.size();
file.write(reinterpret_cast<char*>(&nameLen), sizeof(nameLen));
file.write(name_.data(), nameLen * sizeof(name_[0]));
file.write(name.data(), nameLen * sizeof(name[0]));
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));
@@ -95,7 +95,7 @@ void Person::read(std::ifstream &file)
char nameBuf[128];
file.read(nameBuf, nameLen * sizeof(*nameBuf));
nameBuf[nameLen] = '\0';
name_ = nameBuf;
name = nameBuf;
file.read(reinterpret_cast<char*>(&sex), sizeof(sex));
//file.read(reinterpret_cast<char*>(&day), sizeof(day)); TODO
@@ -105,14 +105,14 @@ void Person::read(std::ifstream &file)
void Person::rename(const char* newName)
{
name_ = newName;
name = newName;
}
void Person::displayInfo()const
{
info_tab = newwin(LINES, COLS, 0, 0);
waddstr(info_tab, name_.data());
waddstr(info_tab, name.data());
waddch(info_tab,'\n');
waddstr(info_tab, "Birth: ");
@@ -143,17 +143,17 @@ static U16 strUtf8Symbols(const std::string& str)
U16 Person::boxWidth() const
{
return strUtf8Symbols(name_) + 4;
return strUtf8Symbols(name) + 4;
}
/* WINDOW* Person::createPad()const */
/* { */
/* U16 width = name_.size() + 4; */
/* U16 width = name.size() + 4; */
/* WINDOW* pad = newpad(5, width); */
/* box(pad, 5, width); */
/* mvwaddstr(pad, 2, 2, name_.data()); */
/* mvwaddstr(pad, 2, 2, name.data()); */
/* return pad; */
/* } */
@@ -167,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
: (sex ? COLOR_MALE : COLOR_FEMALE) );
: (sex==M ? COLOR_MALE : COLOR_FEMALE) );
wbkgd(pad, color_pair);
/* wattron(pad, color_pair); */
@@ -176,7 +176,7 @@ void Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpous
isSpouse ? ACS_TTEE : ACS_LTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER,
hasKids ? ACS_LTEE : ACS_LLCORNER, ACS_LRCORNER );
mvwaddstr(pad, 2, 2, name_.data());
mvwaddstr(pad, 2, 2, name.data());
/* wattroff(pad, color_pair); */