diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a9ecfb..ea95dc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,12 @@ add_library( src/operations/string/substr.cpp ) +# support proper shared library versioning +set_target_properties(${PROJECT_NAME} PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) + # Enable warnings as errors for the library target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror) diff --git a/src/json_logic.cpp b/src/json_logic.cpp index 68baaae..dc2cbd2 100644 --- a/src/json_logic.cpp +++ b/src/json_logic.cpp @@ -137,6 +137,14 @@ namespace json_logic return logic.at(GetOperator(logic)); } + bool JsonLogic::IsOperation(const json& logic) const + { + if (!IsLogic(logic)) return false; + + const auto op { GetOperator(logic) }; + return operations_.find(op) != operations_.end(); + } + bool JsonLogic::Truthy(const json& value) { if (value.is_boolean()) return value.get(); diff --git a/src/json_logic.h b/src/json_logic.h index e6fe5e5..2eca9e2 100644 --- a/src/json_logic.h +++ b/src/json_logic.h @@ -43,6 +43,7 @@ namespace json_logic static bool IsLogic(const json& logic); static std::string GetOperator(const json& logic); static const json& GetValues(const json& logic); + [[maybe_unused]] bool IsOperation(const json& logic) const; private: std::unordered_map operations_;