tft create user tree

This commit is contained in:
vrd
2023-02-18 19:04:39 +02:00
parent 4e3816ae15
commit 16894e2983
13 changed files with 46 additions and 11 deletions
+1
View File
@@ -5,3 +5,4 @@ GPATH
GRTAGS GRTAGS
GTAGS GTAGS
*.tft
Executable
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
set -e
if [ "$1" = '' ]
then
echo 'The first argument needs to be the tree file'
exit 1
fi
tree_file="$(realpath "$1")"
start_dir="$PWD"
script_dir="$(dirname $(readlink -f $0))"
cd "$script_dir/src"
language='
-std=c++17
-fno-rtti
-fno-exceptions
-fno-non-call-exceptions
-fno-common'
# force each global variable to be only defined once
warnings='-Wall -Wextra -Wpedantic' #-fanalyzer
cp -f "$tree_file" user_tree.hpp
g++ -o "$start_dir/${1%.*}.tft" $language $warnings -march=native -DNDEBUG -pipe -g *.cpp -lncursesw
rm user_tree.hpp
cd "$start_dir"
exec "./${1%.*}.tft"
+6 -2
View File
@@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
set -e
mkdir -p bin/release cd src
# mkdir -p bin/release
language=' language='
-std=c++17 -std=c++17
@@ -29,5 +31,7 @@ warnings='
other='-fno-fat-lto-objects' other='-fno-fat-lto-objects'
g++ -o bin/release/famt $language $optimizations $warnings $other -DNDEBUG -pipe -s *.cpp -lncursesw g++ -o tft $language $optimizations $warnings $other -DNDEBUG -pipe -s *.cpp -lncursesw
chmod 775 tft
exec mv tft /usr/local/bin
#-static -lncursesw -ltinfo #-static -lncursesw -ltinfo
+5 -5
View File
@@ -3,10 +3,10 @@
#include "tree.hpp" #include "tree.hpp"
#include "utils.hpp" #include "utils.hpp"
#include "create_tree.hpp" #include "user_tree.hpp"
using std::cin; /* using std::cin; */
using std::cout; /* using std::cout; */
int main() int main()
{ {
setlocale(LC_ALL, "en_US.UTF-8"); setlocale(LC_ALL, "en_US.UTF-8");
@@ -29,15 +29,15 @@ int main()
Tree test1("Dechkovi"); Tree test1("Dechkovi");
test1.loadFromFile(); test1.loadFromFile();
Tree test2("Karamanovi");
/* test1.addPerson("Rumen", true, Nobody, Nobody, {1968, 8, 9}); */ /* test1.addPerson("Rumen", true, Nobody, Nobody, {1968, 8, 9}); */
/* test1.addPerson("Nadejda", false, Nobody, Nobody, {1972, 12, 15}); */ /* test1.addPerson("Nadejda", false, Nobody, Nobody, {1972, 12, 15}); */
/* test1.addRelation(0, Spouse, 1); */ /* test1.addRelation(0, Spouse, 1); */
/* test1.addPerson("Venelin", true, 0, 1, {1998, 6, 9}); */ /* test1.addPerson("Venelin", true, 0, 1, {1998, 6, 9}); */
/* test1.addPerson("Vasil", true, 0, 1, {2001, 1, 16}); */ /* test1.addPerson("Vasil", true, 0, 1, {2001, 1, 16}); */
test1.saveToFile(); /* test1.saveToFile(); */
Tree test2("Karamanovi");
test2.addPerson("Vasil Dimitrov", true, Nobody, Nobody, {1941, 5, 18}); test2.addPerson("Vasil Dimitrov", true, Nobody, Nobody, {1941, 5, 18});
test2.addPerson("Maria", false); test2.addPerson("Maria", false);
test2.addRelation(0, Spouse, 1); test2.addRelation(0, Spouse, 1);
View File
View File
+2 -2
View File
@@ -206,7 +206,7 @@ RelType Tree::findRelation(person_id first, person_id second) const
void Tree::saveToFile() const void Tree::saveToFile() const
{ {
ofstream file(treeName + ".famt", std::ios::binary); ofstream file(treeName + ".tft", std::ios::binary);
file.write((const char*)(&numPeople), sizeof(numPeople)); file.write((const char*)(&numPeople), sizeof(numPeople));
for (const Person& p: people) for (const Person& p: people)
@@ -222,7 +222,7 @@ void Tree::saveToFile() const
bool Tree::loadFromFile() bool Tree::loadFromFile()
{ {
ifstream file(treeName + ".famt", std::ios::binary); ifstream file(treeName + ".tft", std::ios::binary);
file.read((char*)(&numPeople), sizeof(numPeople)); file.read((char*)(&numPeople), sizeof(numPeople));
View File
View File
View File
+1 -1
View File
@@ -1,6 +1,6 @@
Help Help
ffindRelative findRelative
findRelation - extend findRelation - extend