Loading cmake/Modules/FindJsonCpp.cmake +10 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,12 @@ PKG_CHECK_MODULES(PC_JSONCPP jsoncpp) SET(JSONCPP_DEFINITIONS ${PC_JSONCPP_CFLAGS_OTHER}) FIND_PATH(JSONCPP_INCLUDE_DIR json/reader.h HINTS ${PC_JSONCPP_INCLUDE_DIR} ${PC_JSONCPP_INCLUDE_DIRS} HINTS ${PC_JSONCPP_INCLUDE_DIR} ${PC_JSONCPP_INCLUDE_DIRS} PATHS /usr/include /usr/local/include PATH_SUFFIXES jsoncpp) # Get the GCC compiler version Loading @@ -27,7 +32,10 @@ EXEC_PROGRAM(${CMAKE_CXX_COMPILER} # Try to find a library that was compiled with the same compiler version as we currently use. FIND_LIBRARY(JSONCPP_LIBRARY NAMES libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so libjsoncpp.so NAMES libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so libjsoncpp.so libjsoncpp.dylib HINTS ${PC_JSONCPP_LIBDIR} ${PC_JSONCPP_LIBRARY_DIRS} PATHS /usr/lib /usr/local/lib) Loading src/config/CMDArgs.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ #include <boost/program_options.hpp> #include <string> #include <memory> namespace po = boost::program_options; class CMDArgs { Loading Loading @@ -62,4 +64,6 @@ class CMDArgs { std::string jsonOutFile; }; typedef std::shared_ptr<CMDArgs> CMDArgs_Ptr; #endif src/config/Config.cpp +1 −4 Original line number Diff line number Diff line Loading @@ -46,10 +46,7 @@ Config::Config(std::string fileName) { } Config_Ptr Config::subConfig(std::string propertyName) { std::pair<Json::Value, std::string> node = getSubNode(propertyName); Json::Value& nd = node.first; std::string& key = node.second; return Config_Ptr(new Config(nd[key])); return Config_Ptr(new Config(getSubValue(propertyName))); } Config::Config(Json::Value node) : _config(node) { Loading src/db/InternetUsageStatistics.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ #include <boost/log/trivial.hpp> InternetUsageStatistics::InternetUsageStatistics(std::string dbPath) { int retval = sqlite3_open(dbPath.c_str(), &_statDB); int retval = sqlite3_open(dbPath.c_str(), &_sqliteDB); // If connection failed, handle returns NULL if (retval != SQLITE_OK) { Loading @@ -51,7 +51,7 @@ InternetUsageStatistics::InternetUsageStatistics(std::string dbPath) { " GROUP BY un.country_or_area" " HAVING max(year)"); assert(sqlite3_prepare_v2(_statDB, queryString.c_str(), queryString.size(), &_stmt, NULL) == SQLITE_OK); assert(sqlite3_prepare_v2(_sqliteDB, queryString.c_str(), queryString.size(), &_stmt, NULL) == SQLITE_OK); } // returns percent of population with Internet access in this country Loading @@ -68,5 +68,5 @@ double InternetUsageStatistics::operator[](std::string& countryName) { InternetUsageStatistics::~InternetUsageStatistics() { sqlite3_finalize(_stmt); sqlite3_close(_statDB); sqlite3_close(_sqliteDB); } src/db/InternetUsageStatistics.hpp +4 −6 Original line number Diff line number Diff line Loading @@ -30,20 +30,18 @@ #ifndef INTERNETUSAGESTATISTICS_HPP #define INTERNETUSAGESTATISTICS_HPP #include <sqlite3.h> #include "SQLiteReader.hpp" #include <string> class InternetUsageStatistics { class InternetUsageStatistics : public SQLiteReader { public: InternetUsageStatistics(std::string dbPath); double operator[](std::string& countryName); ~InternetUsageStatistics(); virtual ~InternetUsageStatistics(); private: sqlite3* _statDB; sqlite3_stmt* _stmt; }; #endif Loading
cmake/Modules/FindJsonCpp.cmake +10 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,12 @@ PKG_CHECK_MODULES(PC_JSONCPP jsoncpp) SET(JSONCPP_DEFINITIONS ${PC_JSONCPP_CFLAGS_OTHER}) FIND_PATH(JSONCPP_INCLUDE_DIR json/reader.h HINTS ${PC_JSONCPP_INCLUDE_DIR} ${PC_JSONCPP_INCLUDE_DIRS} HINTS ${PC_JSONCPP_INCLUDE_DIR} ${PC_JSONCPP_INCLUDE_DIRS} PATHS /usr/include /usr/local/include PATH_SUFFIXES jsoncpp) # Get the GCC compiler version Loading @@ -27,7 +32,10 @@ EXEC_PROGRAM(${CMAKE_CXX_COMPILER} # Try to find a library that was compiled with the same compiler version as we currently use. FIND_LIBRARY(JSONCPP_LIBRARY NAMES libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so libjsoncpp.so NAMES libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so libjsoncpp.so libjsoncpp.dylib HINTS ${PC_JSONCPP_LIBDIR} ${PC_JSONCPP_LIBRARY_DIRS} PATHS /usr/lib /usr/local/lib) Loading
src/config/CMDArgs.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ #include <boost/program_options.hpp> #include <string> #include <memory> namespace po = boost::program_options; class CMDArgs { Loading Loading @@ -62,4 +64,6 @@ class CMDArgs { std::string jsonOutFile; }; typedef std::shared_ptr<CMDArgs> CMDArgs_Ptr; #endif
src/config/Config.cpp +1 −4 Original line number Diff line number Diff line Loading @@ -46,10 +46,7 @@ Config::Config(std::string fileName) { } Config_Ptr Config::subConfig(std::string propertyName) { std::pair<Json::Value, std::string> node = getSubNode(propertyName); Json::Value& nd = node.first; std::string& key = node.second; return Config_Ptr(new Config(nd[key])); return Config_Ptr(new Config(getSubValue(propertyName))); } Config::Config(Json::Value node) : _config(node) { Loading
src/db/InternetUsageStatistics.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ #include <boost/log/trivial.hpp> InternetUsageStatistics::InternetUsageStatistics(std::string dbPath) { int retval = sqlite3_open(dbPath.c_str(), &_statDB); int retval = sqlite3_open(dbPath.c_str(), &_sqliteDB); // If connection failed, handle returns NULL if (retval != SQLITE_OK) { Loading @@ -51,7 +51,7 @@ InternetUsageStatistics::InternetUsageStatistics(std::string dbPath) { " GROUP BY un.country_or_area" " HAVING max(year)"); assert(sqlite3_prepare_v2(_statDB, queryString.c_str(), queryString.size(), &_stmt, NULL) == SQLITE_OK); assert(sqlite3_prepare_v2(_sqliteDB, queryString.c_str(), queryString.size(), &_stmt, NULL) == SQLITE_OK); } // returns percent of population with Internet access in this country Loading @@ -68,5 +68,5 @@ double InternetUsageStatistics::operator[](std::string& countryName) { InternetUsageStatistics::~InternetUsageStatistics() { sqlite3_finalize(_stmt); sqlite3_close(_statDB); sqlite3_close(_sqliteDB); }
src/db/InternetUsageStatistics.hpp +4 −6 Original line number Diff line number Diff line Loading @@ -30,20 +30,18 @@ #ifndef INTERNETUSAGESTATISTICS_HPP #define INTERNETUSAGESTATISTICS_HPP #include <sqlite3.h> #include "SQLiteReader.hpp" #include <string> class InternetUsageStatistics { class InternetUsageStatistics : public SQLiteReader { public: InternetUsageStatistics(std::string dbPath); double operator[](std::string& countryName); ~InternetUsageStatistics(); virtual ~InternetUsageStatistics(); private: sqlite3* _statDB; sqlite3_stmt* _stmt; }; #endif