diff --git a/CMakeLists.txt b/CMakeLists.txt index f10d906..a77b616 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,29 +1,32 @@ cmake_minimum_required(VERSION 2.8.4) project(goodform) -include_directories("./include") +include_directories("${CMAKE_CURRENT_LIST_DIR}/include") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -#set(CMAKE_CXX_COMPILER "/opt/local/bin/g++-mp-4.9") -#set(CMAKE_CC_COMPILER "/opt/local/bin/gcc-mp-4.9") +# set(CMAKE_CXX_COMPILER "/opt/local/bin/g++-mp-4.9") +# set(CMAKE_CC_COMPILER "/opt/local/bin/gcc-mp-4.9") -set(HEADER_FILES - include/form.hpp - include/variant.hpp - include/msgpack.hpp - include/json.hpp - include/portable_endian.hpp) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_DEBUG "-g") +set(CMAKE_CXX_FLAGS_RELEASE "-O2") set(SOURCE_FILES src/variant.cpp src/msgpack.cpp src/json.cpp) -add_library(goodform SHARED ${SOURCE_FILES} ${HEADER_FILES}) +add_library(goodform SHARED ${SOURCE_FILES}) + +add_library(goodform-static STATIC ${SOURCE_FILES}) -add_library(goodform-static STATIC ${SOURCE_FILES} ${HEADER_FILES}) +add_executable(variant-test tests/variant-test.cpp ${SOURCE_FILES}) -add_executable(variant-test tests/variant-test.cpp ${SOURCE_FILES} ${HEADER_FILES}) \ No newline at end of file +target_include_directories(goodform PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include) diff --git a/include/form.hpp b/include/goodform/form.hpp similarity index 99% rename from include/form.hpp rename to include/goodform/form.hpp index 06f3000..d258941 100644 --- a/include/form.hpp +++ b/include/goodform/form.hpp @@ -40,8 +40,8 @@ namespace goodform class number_validator { private: - error_message& error_; const N value_; + error_message& error_; public: number_validator(N value, error_message& error_message); number_validator(const number_validator& source); @@ -89,8 +89,8 @@ namespace goodform class string_validator { private: - error_message& error_; const std::string& value_; + error_message& error_; public: string_validator(const std::string& value, error_message& error_message); @@ -187,11 +187,11 @@ namespace goodform //======================================================================// class sub_form { + protected: + const variant& variant_; private: error_message& error_; //static double convert_to_double(const variant& v); - protected: - const variant& variant_; public: sub_form(const variant& v, error_message& error_message); sub_form(const sub_form& source); @@ -558,7 +558,7 @@ namespace goodform //======================================================================// //======================================================================// - array_validator::array_validator(const std::vector& value, error_message& errorMessage) : value_(value), error_(errorMessage) + array_validator::array_validator(const std::vector& value, error_message& errorMessage) : error_(errorMessage), value_(value) { } @@ -602,7 +602,7 @@ namespace goodform //======================================================================// //======================================================================// - object_validator::object_validator(const std::map& value, error_message& errorMessage) : value_(value), error_(errorMessage) + object_validator::object_validator(const std::map& value, error_message& errorMessage) : error_(errorMessage), value_(value) { } @@ -1012,7 +1012,7 @@ namespace goodform //======================================================================// //======================================================================// - form::form(const variant& v) : error_(""), sub_form(v, error_) + form::form(const variant& v) : sub_form(v, error_), error_("") { } @@ -1024,4 +1024,4 @@ namespace goodform //======================================================================// } //######################################################################// -#endif //GOODFORM_FORM_HPP \ No newline at end of file +#endif //GOODFORM_FORM_HPP diff --git a/include/json.hpp b/include/goodform/json.hpp similarity index 100% rename from include/json.hpp rename to include/goodform/json.hpp diff --git a/include/msgpack.hpp b/include/goodform/msgpack.hpp similarity index 100% rename from include/msgpack.hpp rename to include/goodform/msgpack.hpp diff --git a/include/portable_endian.hpp b/include/goodform/portable_endian.hpp similarity index 100% rename from include/portable_endian.hpp rename to include/goodform/portable_endian.hpp diff --git a/include/variant.hpp b/include/goodform/variant.hpp similarity index 98% rename from include/variant.hpp rename to include/goodform/variant.hpp index 8ec5784..e24dead 100644 --- a/include/variant.hpp +++ b/include/goodform/variant.hpp @@ -114,7 +114,7 @@ namespace goodform //----------------------------------------------------------------------// //----------------------------------------------------------------------// - variant& operator=(std::nullptr_t value); + variant& operator=(std::nullptr_t value [[maybe_unused]]); variant& operator=(bool value); variant& operator=(std::int8_t value); @@ -206,4 +206,4 @@ namespace goodform //======================================================================// } //######################################################################// -#endif //GOODFORM_VARIANT_HPP \ No newline at end of file +#endif //GOODFORM_VARIANT_HPP diff --git a/src/json.cpp b/src/json.cpp index 33d2de7..18556b1 100755 --- a/src/json.cpp +++ b/src/json.cpp @@ -3,7 +3,7 @@ #include #include -#include "json.hpp" +#include "goodform/json.hpp" //######################################################################// namespace goodform diff --git a/src/msgpack.cpp b/src/msgpack.cpp index 751c469..e62263f 100644 --- a/src/msgpack.cpp +++ b/src/msgpack.cpp @@ -1,5 +1,5 @@ -#include "msgpack.hpp" -#include "portable_endian.hpp" +#include "goodform/msgpack.hpp" +#include "goodform/portable_endian.hpp" namespace goodform { @@ -589,4 +589,4 @@ namespace goodform return ret; } //----------------------------------------------------------------// -} \ No newline at end of file +} diff --git a/src/variant.cpp b/src/variant.cpp index ec59c84..ce26012 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -1,5 +1,5 @@ -#include "variant.hpp" +#include "goodform/variant.hpp" #include @@ -161,7 +161,7 @@ namespace goodform //----------------------------------------------------------------------// //----------------------------------------------------------------------// - variant::variant(std::nullptr_t value) + variant::variant(std::nullptr_t value [[maybe_unused]] ) { this->type_ = variant_type::null; } @@ -358,7 +358,7 @@ namespace goodform //----------------------------------------------------------------------// //----------------------------------------------------------------------// - variant& variant::operator=(std::nullptr_t value) + variant& variant::operator=(std::nullptr_t value [[maybe_unused]]) { this->destroy(); this->type_ = variant_type::null; diff --git a/tests/variant-test.cpp b/tests/variant-test.cpp index 769ba40..4c81a9f 100644 --- a/tests/variant-test.cpp +++ b/tests/variant-test.cpp @@ -3,15 +3,15 @@ #include #include -#include "variant.hpp" -#include "form.hpp" -#include "msgpack.hpp" -#include "json.hpp" +#include "goodform/variant.hpp" +#include "goodform/form.hpp" +#include "goodform/msgpack.hpp" +#include "goodform/json.hpp" #include -int main(int argc, char** argv) +int main(int argc [[maybe_unused]], char** argv [[maybe_unused]]) { { bool passed = false; @@ -106,4 +106,4 @@ int main(int argc, char** argv) return 0; -} \ No newline at end of file +}