add death date
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
build
|
||||||
|
.codelite
|
||||||
|
*.workspace
|
||||||
|
|
||||||
+2
-1
@@ -1 +1,2 @@
|
|||||||
g++ -std=gnu++20 -Ofast -flto -fipa-pta -s -DNDEBUG *.cpp\
|
g++ -o build/release/famt -std=gnu++20 -Ofast -flto -fipa-pta -fallow-store-data-races -fgcse-sm -fgcse-las -s -DNDEBUG *.cpp
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1 +1,2 @@
|
|||||||
g++ -std=gnu++20 -g -Og -Wall *.cpp
|
g++ -o build/debug/famt -std=gnu++20 -g -Og -Wall *.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -127,11 +127,11 @@ int main()
|
|||||||
break;
|
break;
|
||||||
case 4: //addPerson
|
case 4: //addPerson
|
||||||
std::cin >> name >> day >> month >> year >> sex;
|
std::cin >> name >> day >> month >> year >> sex;
|
||||||
trees[curTree].addPerson(name, BirthTime(year, month, day) , sex);
|
trees[curTree].addPerson(name, EventTime(year, month, day) , sex);
|
||||||
break;
|
break;
|
||||||
case 5: //addPersonWP
|
case 5: //addPersonWP
|
||||||
std::cin >> name >> day >> month >> year >> sex >> father >> mother;
|
std::cin >> name >> day >> month >> year >> sex >> father >> mother;
|
||||||
trees[curTree].addPerson(name, BirthTime(year, month, day), sex, father, mother);
|
trees[curTree].addPerson(name, EventTime(year, month, day), sex, father, mother);
|
||||||
break;
|
break;
|
||||||
case 6: //addRelation
|
case 6: //addRelation
|
||||||
std::cin >> name >> input >> secondName;
|
std::cin >> name >> input >> secondName;
|
||||||
|
|||||||
+8
-8
@@ -6,40 +6,40 @@
|
|||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
|
||||||
BirthTime::BirthTime(U16 Year, U8 Month, U8 Day, U8 Hour, U8 Minute)
|
EventTime::EventTime(I16 Year, U8 Month, U16 Day, I8 Hour, I8 Minute)
|
||||||
: year(Year)
|
: year(Year)
|
||||||
, month(Month)
|
, month(Month)
|
||||||
, day(Day)
|
, day(Day)
|
||||||
, hour(Hour)
|
, hour(Hour)
|
||||||
, minute(Minute)
|
, minute(Minute)
|
||||||
{
|
{
|
||||||
assert(month <= 12 && day <= 31 && hour <= 23 && minute <= 59 && "Invalid BirthTime data");
|
assert(month <= 12 && day <= 31 && hour <= 23 && minute <= 59 && "Invalid EventTime data");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BirthTime::print() const
|
void EventTime::print() const
|
||||||
{
|
{
|
||||||
cout << "Birth: ";
|
cout << "Birth: ";
|
||||||
if (day != UNKNOWN)
|
if (day != UNKNOWN_DATE)
|
||||||
cout << (I32)day;
|
cout << (I32)day;
|
||||||
else
|
else
|
||||||
cout << "??";
|
cout << "??";
|
||||||
cout << '.';
|
cout << '.';
|
||||||
|
|
||||||
if (month != UNKNOWN)
|
if (month != UNKNOWN_DATE)
|
||||||
cout << (I32)month;
|
cout << (I32)month;
|
||||||
else
|
else
|
||||||
cout << "??";
|
cout << "??";
|
||||||
cout << '.';
|
cout << '.';
|
||||||
|
|
||||||
if (year != UNKNOWN)
|
if (year != UNKNOWN_DATE)
|
||||||
cout << (I32)year;
|
cout << year;
|
||||||
else
|
else
|
||||||
cout << "????";
|
cout << "????";
|
||||||
cout << '\n';
|
cout << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Person::Person(const char* Name, BirthTime Birth, bool IsMale)
|
Person::Person(const char* Name, EventTime Birth, bool IsMale)
|
||||||
: name(Name)
|
: name(Name)
|
||||||
, numRel(0)
|
, numRel(0)
|
||||||
, birth(Birth)
|
, birth(Birth)
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "common/basicTypes.h"
|
#include "common/basicTypes.h"
|
||||||
|
|
||||||
struct BirthTime
|
struct EventTime
|
||||||
{
|
{
|
||||||
static const U16 UNKNOWN = 0;
|
//enum { UNKNOWN_DATE=0, UNKNOWN_TIME=1};
|
||||||
/*explicit*/ BirthTime(U16 Year=UNKNOWN, U8 Month=UNKNOWN, U8 Day=UNKNOWN, U8 Hour=UNKNOWN, U8 Minute=UNKNOWN);
|
static const I16 UNKNOWN_DATE = 0;
|
||||||
|
static const I8 UNKNOWN_TIME = -1;
|
||||||
|
/*explicit*/ EventTime(I16 Year=UNKNOWN_DATE, U8 Month=UNKNOWN_DATE, U16 Day=UNKNOWN_DATE, I8 Hour=UNKNOWN_TIME, I8 Minute=UNKNOWN_TIME);
|
||||||
void print() const;
|
void print() const;
|
||||||
|
|
||||||
U16 year;
|
I16 year; //The year in relation to Chritst's birth - 1 (AD) is the year He was born, -1 (BC) is the previous year. There is no year 0
|
||||||
U8 month, day, hour, minute;
|
U8 month;
|
||||||
|
U16 day;
|
||||||
|
I8 hour; //0-23
|
||||||
|
I8 minute; //0-59
|
||||||
};
|
};
|
||||||
|
|
||||||
class Person
|
class Person
|
||||||
@@ -19,7 +24,7 @@ class Person
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Person() = default;
|
Person() = default;
|
||||||
Person(const char* Name, BirthTime Birth, bool Sex);
|
Person(const char* Name, EventTime Birth, bool Sex);
|
||||||
|
|
||||||
bool operator==(const Person &other)const;
|
bool operator==(const Person &other)const;
|
||||||
|
|
||||||
@@ -32,7 +37,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
unsigned numRel; //Number of close relatives - mother, father, brother, sister, wife/husband, child, ex-wife/husband
|
unsigned numRel; //Number of close relatives - mother, father, brother, sister, wife/husband, child, ex-wife/husband
|
||||||
BirthTime birth;
|
EventTime birth;
|
||||||
bool isMale;
|
bool isMale;
|
||||||
|
EventTime death;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ bool Tree::loadTree()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tree::addPerson(const char *name, BirthTime birth, bool isMale, unsigned father, unsigned mother)
|
void Tree::addPerson(const char *name, EventTime birth, bool isMale, unsigned father, unsigned mother)
|
||||||
{
|
{
|
||||||
Person newPerson(name, birth, isMale);
|
Person newPerson(name, birth, isMale);
|
||||||
people.push(newPerson);
|
people.push(newPerson);
|
||||||
|
|||||||
@@ -30,23 +30,26 @@ public:
|
|||||||
template <class Str>
|
template <class Str>
|
||||||
Tree(Str&& Name) : treeName(std::forward<Str>(Name)), numPeople(0) {}
|
Tree(Str&& Name) : treeName(std::forward<Str>(Name)), numPeople(0) {}
|
||||||
/*Tree(const Tree&);
|
/*Tree(const Tree&);
|
||||||
Tree& operator= (const Tree& other);
|
Tree& operator= (const Tree& other);*/
|
||||||
~Tree();*/
|
|
||||||
|
|
||||||
Tree operator+ (const Tree& other);
|
Tree operator+ (const Tree& other);
|
||||||
Tree operator- (const Tree& other);
|
Tree operator- (const Tree& other);
|
||||||
Tree& operator+= (const Tree& other);
|
Tree& operator+= (const Tree& other);
|
||||||
Tree& operator-= (const Tree& other);
|
Tree& operator-= (const Tree& other);
|
||||||
|
|
||||||
void rename(const char* newName);
|
void rename(const char* newName);
|
||||||
|
|
||||||
unsigned findId(const char*, const short year=0, const unsigned char month=0, const unsigned char day=0)const;
|
unsigned findId(const char*, const short year=0, const unsigned char month=0, const unsigned char day=0)const;
|
||||||
unsigned findOldestAncestor(const unsigned &id, const bool &sex = 0)const;//
|
unsigned findOldestAncestor(const unsigned &id, const bool &sex = 0)const;//
|
||||||
unsigned findCommonAncestor(const unsigned firstId, const unsigned secondId)const; //oldest common ancestor ID
|
unsigned findCommonAncestor(const unsigned firstId, const unsigned secondId)const; //oldest common ancestor ID
|
||||||
|
|
||||||
void saveTree()const;//
|
void saveTree()const;//
|
||||||
bool loadTree();
|
bool loadTree();
|
||||||
void addPerson(const char *name, BirthTime birth, bool isMale, unsigned father = Nobody, unsigned mother = Nobody);
|
|
||||||
|
void addPerson(const char *name, EventTime birth, bool isMale, unsigned father = Nobody, unsigned mother = Nobody);
|
||||||
bool addRelation(const char* firstName, const Relation, const char* secondName); //Adds a new relation or edits an old one. 0 - failure 1 - success
|
bool addRelation(const char* firstName, const Relation, const char* secondName); //Adds a new relation or edits an old one. 0 - failure 1 - success
|
||||||
bool addRelation(const unsigned firstId, const Relation, const unsigned secondId, bool opposite=0); //0 - failure 1 - success
|
bool addRelation(const unsigned firstId, const Relation, const unsigned secondId, bool opposite=0); //0 - failure 1 - success
|
||||||
|
|
||||||
void removePerson(const unsigned id); //Removes a member and the last one takes his ID
|
void removePerson(const unsigned id); //Removes a member and the last one takes his ID
|
||||||
void removePerson(const char*, const short year = 0, const unsigned char month = 0, const unsigned char day = 0);
|
void removePerson(const char*, const short year = 0, const unsigned char month = 0, const unsigned char day = 0);
|
||||||
void removeRelation(const unsigned firstId, const unsigned secondId);
|
void removeRelation(const unsigned firstId, const unsigned secondId);
|
||||||
|
|||||||
Reference in New Issue
Block a user