From b6d6e12b0551de07b170286e9a3e349ae5d2bb1c Mon Sep 17 00:00:00 2001 From: Hans Binderup Date: Tue, 17 Feb 2026 09:51:23 +0100 Subject: [PATCH 1/2] jsonlogic: add `IsOperation` helper When implementing more complex logic it might be beneficial to know if the current entry is an operation. Example would be: if (IsOperation(j)) return Apply(j) else return CustomOperation(j) This allows traversing the tree and perform the "CustomOperation" on all but operations and otherwise handle the operations when finding such. Signed-off-by: Hans Binderup --- src/json_logic.cpp | 8 ++++++++ src/json_logic.h | 1 + 2 files changed, 9 insertions(+) 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_; From 023923e62f1ae90e5e1761ceb0151f65cdc4ff69 Mon Sep 17 00:00:00 2001 From: Hans Binderup Date: Tue, 17 Feb 2026 10:13:17 +0100 Subject: [PATCH 2/2] cmake: support proper shared library versioning Versioning shared libraries is standard practice. This improves compatibility with most common packing systems. Signed-off-by: Hans Binderup --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) 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)