Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions src/json_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>();
Expand Down
1 change: 1 addition & 0 deletions src/json_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, Operation> operations_;
Expand Down