tft create user tree
This commit is contained in:
@@ -5,3 +5,4 @@ GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
|
||||
*.tft
|
||||
|
||||
Executable
+30
@@ -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"
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
mkdir -p bin/release
|
||||
cd src
|
||||
# mkdir -p bin/release
|
||||
|
||||
language='
|
||||
-std=c++17
|
||||
@@ -29,5 +31,7 @@ warnings='
|
||||
|
||||
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
|
||||
@@ -3,10 +3,10 @@
|
||||
#include "tree.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "create_tree.hpp"
|
||||
#include "user_tree.hpp"
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
/* using std::cin; */
|
||||
/* using std::cout; */
|
||||
int main()
|
||||
{
|
||||
setlocale(LC_ALL, "en_US.UTF-8");
|
||||
@@ -29,15 +29,15 @@ int main()
|
||||
Tree test1("Dechkovi");
|
||||
test1.loadFromFile();
|
||||
|
||||
Tree test2("Karamanovi");
|
||||
|
||||
/* test1.addPerson("Rumen", true, Nobody, Nobody, {1968, 8, 9}); */
|
||||
/* test1.addPerson("Nadejda", false, Nobody, Nobody, {1972, 12, 15}); */
|
||||
/* test1.addRelation(0, Spouse, 1); */
|
||||
/* test1.addPerson("Venelin", true, 0, 1, {1998, 6, 9}); */
|
||||
/* 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("Maria", false);
|
||||
test2.addRelation(0, Spouse, 1);
|
||||
@@ -206,7 +206,7 @@ RelType Tree::findRelation(person_id first, person_id second) 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));
|
||||
for (const Person& p: people)
|
||||
@@ -222,7 +222,7 @@ void Tree::saveToFile() const
|
||||
|
||||
bool Tree::loadFromFile()
|
||||
{
|
||||
ifstream file(treeName + ".famt", std::ios::binary);
|
||||
ifstream file(treeName + ".tft", std::ios::binary);
|
||||
|
||||
file.read((char*)(&numPeople), sizeof(numPeople));
|
||||
|
||||
Reference in New Issue
Block a user