diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 70940ec..207b3f5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -33,10 +33,10 @@ - - + + - + @@ -45,8 +45,8 @@ - - + + @@ -91,8 +91,8 @@ - - + + @@ -103,10 +103,10 @@ - - + + - + @@ -589,12 +589,12 @@ 1491540343823 - + - @@ -682,14 +682,6 @@ - - - - - - - - @@ -827,20 +819,28 @@ - + - - + + + + + + + + + + - + - - + + @@ -849,10 +849,10 @@ - - + + - + diff --git a/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o b/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o index da8997e..f853916 100644 Binary files a/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o and b/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o index 01831fc..e5b86c2 100644 Binary files a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o and b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o differ diff --git a/cmake-build-debug/ftests b/cmake-build-debug/ftests index e705f7c..2c51d37 100755 Binary files a/cmake-build-debug/ftests and b/cmake-build-debug/ftests differ diff --git a/main.cpp b/main.cpp index ab9c5ce..90da2c5 100644 --- a/main.cpp +++ b/main.cpp @@ -5,17 +5,6 @@ #include "src/json/json-forwards.h" #include "src/loaders.h" - -void json_file_to_json_obj(std::string filename) -{ - Conf jsonLoader = Conf(filename); - Json::Value root = jsonLoader.get_root(); - - const std::string planpath = root.get("plan_path", NULL).asString(); - - std::cout << planpath; -} - /*configuration load_config_file( std::string filename ) { json j_conf = json_file_to_json_obj( filename ); @@ -25,10 +14,8 @@ void json_file_to_json_obj(std::string filename) int main() { - // configuration appconf = load_config_file( "./config.json" ); - // std::cout << appconf.plan_path << std::endl; - // std::cout << appconf.units_path << std::endl; + Conf jsonLoader = Conf("config.json"); - json_file_to_json_obj( "config.json" ); + std::cout << jsonLoader.get_units_path(); return 0; } \ No newline at end of file diff --git a/src/loaders.cpp b/src/loaders.cpp index c41c27a..57a3ecd 100644 --- a/src/loaders.cpp +++ b/src/loaders.cpp @@ -23,7 +23,7 @@ JLoader::JLoader( std::string filename ) if (! exists( filename ) ) { - std::cout << "File '" << filename << "' does not exist."; + std::cerr << "File '" << filename << "' does not exist."; exit(1); } @@ -32,7 +32,7 @@ JLoader::JLoader( std::string filename ) bool parsingSuccessful = reader.parse( jfile, this->json_root ); if (! parsingSuccessful ) { - std::cout << "Failed to parse " << filename << ":\n\t" << reader.getFormattedErrorMessages(); + std::cerr << "Failed to parse " << filename << ":\n\t" << reader.getFormattedErrorMessages(); exit(1); } else { std::cout << "Parsed " << filename << " with " << this->json_root.size() << " elements." << std::endl; @@ -57,5 +57,17 @@ Plan::Plan( std::string filename ): JLoader( filename ) Conf::Conf( std::string filename ): JLoader( filename ) { - + this->plan_path = this->get_root()["plan_path"].asString(); + this->units_path = this->get_root()["units_path"].asString(); }; + +std::string Conf::get_plan_path() +{ + return this->plan_path; +} + +std::string Conf::get_units_path() +{ + return this->units_path; +} + diff --git a/src/loaders.h b/src/loaders.h index ebd3df8..604e214 100644 --- a/src/loaders.h +++ b/src/loaders.h @@ -45,9 +45,14 @@ class Conf: public JLoader { private: Json::Value json_root; + std::string plan_path; + std::string units_path; + public: using JLoader::JLoader; Conf( std::string filename ); + std::string get_plan_path(); + std::string get_units_path(); };