diff --git a/.gitignore b/.gitignore index 49d90de..36a9d28 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ CMakeLists.txt.user # dev generated files nohup.out *.tmp +err.txt diff --git a/EventHandler.cpp b/EventHandler.cpp index b1e7d10..2c04ee6 100644 --- a/EventHandler.cpp +++ b/EventHandler.cpp @@ -1,5 +1,5 @@ #include "EventHandler.h" -#include +#include "Utility.h" #include #include #include diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..a82319c --- /dev/null +++ b/build.sh @@ -0,0 +1,67 @@ +#!/bin/sh +if [ -z "$PREFIX" ]; then + PREFIX="/usr" +fi +#IRR_INCDIR= +#IRR_LIBDIR= +FT2_INCDIR=$PREFIX/include/freetype2 +OUT_BIN=build/b3view +#FT2_LIBDIR= +OBJDIR="./build/tmp" + +# ^ build is in .gitignore + +if [ ! -d "$OBJDIR" ]; then + mkdir -p "$OBJDIR" +fi + +# only for pc file if exists for irrlicht: +#if [ -z "$PKG_CONFIG_PATH" ]; then +# PKG_CONFIG_PATH=$IRR_PATH +#else +# PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$IRR_PATH +#fi +#gcc -o build/b3view main.cpp Debug.cpp Engine.cpp EventHandler.cpp settings.cpp UserInterface.cpp Utility.cpp View.cpp $(pkg-config --libs --cflags irrlicht --cflags freetype2) +#^ can't find a pc file +# gcc -o build/b3view main.cpp Debug.cpp Engine.cpp EventHandler.cpp settings.cpp UserInterface.cpp Utility.cpp View.cpp -I$FT2_INCDIR + +# Qmake does the following: +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/main.o ../b3view/main.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Engine.o ../b3view/Engine.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/EventHandler.o ../b3view/EventHandler.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/UserInterface.o ../b3view/UserInterface.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Debug.o ../b3view/Debug.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/View.o ../b3view/View.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/CGUITTFont.o ../b3view/extlib/CGUITTFont.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Utility.o ../b3view/Utility.cpp +#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/settings.o ../b3view/settings.cpp +#g++ -o build/b3view tmp/main.o tmp/Engine.o tmp/EventHandler.o tmp/UserInterface.o tmp/Debug.o tmp/View.o tmp/CGUITTFont.o tmp/Utility.o tmp/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype + +# based on the above (some options are unclear): +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/main.o ../b3view/main.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Engine.o ../b3view/Engine.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/EventHandler.o ../b3view/EventHandler.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/UserInterface.o ../b3view/UserInterface.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/View.o ../b3view/View.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Debug.o ../b3view/Debug.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/CGUITTFont.o ../b3view/extlib/CGUITTFont.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Utility.o ../b3view/Utility.cpp +g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/settings.o ../b3view/settings.cpp +#-w: suppress warning +# -I.: include the current directory (suppresses errors when using include < instead of include " +#-pipe: "Use pipes rather than intermediate files." +#Options starting with -g, -f, -m, -O, -W, or --param are automatically +# passed on to the various sub-processes invoked by g++. In order to pass +# other options on to these processes the -W options must be used. +rm "$OUT_BIN" +if [ -f "$OUT_BIN" ]; then + echo "Error: $OUT_BIN couldn't be deleted." + exit 1 +fi +g++ -o build/b3view $OBJDIR/main.o $OBJDIR/Engine.o $OBJDIR/EventHandler.o $OBJDIR/UserInterface.o $OBJDIR/Debug.o $OBJDIR/View.o $OBJDIR/CGUITTFont.o $OBJDIR/Utility.o $OBJDIR/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype +if [ ! -f "$OUT_BIN" ]; then + echo "Error: $OUT_BIN couldn't be built." + exit 1 +else + echo "Building $OUT_BIN is complete." +fi diff --git a/build/b3view b/build/b3view deleted file mode 120000 index e9db87d..0000000 --- a/build/b3view +++ /dev/null @@ -1 +0,0 @@ -/home/owner/git/build-b3view-Desktop-Release/build/b3view \ No newline at end of file diff --git a/build/b3view b/build/b3view new file mode 100755 index 0000000..97b76c8 Binary files /dev/null and b/build/b3view differ diff --git a/settings.cpp b/settings.cpp index f760704..a1df4a7 100644 --- a/settings.cpp +++ b/settings.cpp @@ -48,6 +48,7 @@ void Settings::clear_types() bool Settings::load(std::string path) { + bool readable = false; this->section = ""; this->path = path; fstream newfile; @@ -135,13 +136,16 @@ bool Settings::load(std::string path) } } newfile.close(); + readable = true; } this->section = ""; this->pre = ""; + return readable; } bool Settings::save(std::string path) { + bool ok = true; this->path = path; ofstream myfile; myfile.open(path, ios::out); // default is ios_base::out @@ -171,7 +175,7 @@ bool Settings::save(std::string path) } } myfile.close(); - return true; + return ok; } bool Settings::save() @@ -179,17 +183,17 @@ bool Settings::save() if (this->path.length() == 0) { throw std::string("There is no path during save()."); } - this->save(this->path); + return this->save(this->path); } string Settings::ao_trimmed() { - Utility::trim(this->ao_and_spacing); + return Utility::trim(this->ao_and_spacing); } string Settings::cm_trimmed() { - Utility::trim(this->cm_and_spacing); + return Utility::trim(this->cm_and_spacing); } bool Settings::check_type(std::string typeStr, std::string name) @@ -230,7 +234,7 @@ void Settings::set_cm_and_spacing(std::string commentMark) this->cm_and_spacing = commentMark; } -bool Settings::set_all_auto(std::map table) +void Settings::set_all_auto(std::map table) { std::map::iterator it; for (it = table.begin(); it != table.end(); it++) { diff --git a/settings.h b/settings.h index 8749e9c..4818307 100644 --- a/settings.h +++ b/settings.h @@ -36,7 +36,7 @@ public: bool exists(std::string name); void set_ao_and_spacing(std::string assignmentOperator); void set_cm_and_spacing(std::string commentMark); - bool set_all_auto(std::map table); + void set_all_auto(std::map table); void set_section(std::string sectionName); void set_raw(std::string name, std::string value); bool set(std::string name, std::string value);