From 1d7a3e265c32645238ac24b4d45618ba0587b1e9 Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Mon, 30 Dec 2019 13:21:03 +0100 Subject: [PATCH 1/3] some cmake changes --- CMakeLists.txt | 1 + deserialize/CMakeLists.txt | 3 +-- deserialize/test/CMakeLists.txt | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37e6499..5ebd8b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(agency-node CXX C) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_subdirectory(velocypack) add_subdirectory(deserialize) diff --git a/deserialize/CMakeLists.txt b/deserialize/CMakeLists.txt index e8cc73c..ad9c561 100644 --- a/deserialize/CMakeLists.txt +++ b/deserialize/CMakeLists.txt @@ -1,8 +1,7 @@ - +cmake_minimum_required(VERSION 3.15) project(vpack-deserializer CXX) add_library(deserializer-lib INTERFACE) - target_include_directories(deserializer-lib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(test) diff --git a/deserialize/test/CMakeLists.txt b/deserialize/test/CMakeLists.txt index 2c9d3fb..750f49d 100644 --- a/deserialize/test/CMakeLists.txt +++ b/deserialize/test/CMakeLists.txt @@ -1,6 +1,13 @@ add_executable(deserializer-test test.cpp) -target_link_libraries(deserializer-test deserializer-lib) -target_link_libraries(deserializer-test velocypack) +# why is there no error without this check in case +# the velocypack target is not defined. +if(NOT TARGET velocypack) + message(FATAL_ERROR "velocypack not found") +endif() +target_link_libraries(deserializer-test + deserializer-lib + velocypack +) target_compile_options(deserializer-test PRIVATE "-ftemplate-backtrace-limit=0") From 98fa66052bbd5f496706e5535a8fb9f25135b86e Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Mon, 30 Dec 2019 13:38:48 +0100 Subject: [PATCH 2/3] add include for clang completion --- .clang_complete | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .clang_complete diff --git a/.clang_complete b/.clang_complete new file mode 100644 index 0000000..f57a720 --- /dev/null +++ b/.clang_complete @@ -0,0 +1,2 @@ +-I +velocypack/include From 40e7c5e251147b21a220f5aad6988f5338d77a36 Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Tue, 31 Dec 2019 06:54:17 +0100 Subject: [PATCH 3/3] add missing includes and eliminate warnings --- deserialize/conditional.h | 4 ++-- deserialize/errors.h | 2 +- deserialize/field-name-dependent.h | 5 +++-- deserialize/field-value-dependent.h | 4 ++-- deserialize/fixed-order.h | 2 +- deserialize/gadgets.h | 1 + deserialize/map.h | 7 +++---- deserialize/parameter-list.h | 16 ++++++++-------- deserialize/plan-executor.h | 2 ++ deserialize/try-alternatives.h | 3 ++- deserialize/unpack-proxy.h | 4 ++++ deserialize/utilities.h | 1 + deserialize/values.h | 2 +- 13 files changed, 31 insertions(+), 22 deletions(-) diff --git a/deserialize/conditional.h b/deserialize/conditional.h index 4d64f46..fa11377 100644 --- a/deserialize/conditional.h +++ b/deserialize/conditional.h @@ -122,7 +122,7 @@ template struct conditional_executor { using R = typename E::variant_type; using unpack_result = result; - static auto unpack(::deserializer::slice_type s, ::deserializer::slice_type v) + static auto unpack(::deserializer::slice_type /*s*/, ::deserializer::slice_type v) -> unpack_result { using namespace std::string_literals; return unpack_result{deserialize_error{"unrecognized value `"s + v.toJson() + "`"}}; @@ -145,7 +145,7 @@ struct deserialize_plan_executor, H> { using variant_type = typename plan_result_tuple_type::variant; using unpack_result = result; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> unpack_result { /* * Select the sub deserializer depending on the value. diff --git a/deserialize/errors.h b/deserialize/errors.h index a94f6aa..fc3a8f3 100644 --- a/deserialize/errors.h +++ b/deserialize/errors.h @@ -86,7 +86,7 @@ struct error { } operator std::string() const { return as_string(); } - [[nodiscard]] std::string as_string(bool detailed = false) const { + [[nodiscard]] std::string as_string(bool /*detailed*/ = false) const { using deserializer::detail::gadgets::visitor; std::string result; bool was_terminated = false; diff --git a/deserialize/field-name-dependent.h b/deserialize/field-name-dependent.h index db39b10..07bb453 100644 --- a/deserialize/field-name-dependent.h +++ b/deserialize/field-name-dependent.h @@ -3,6 +3,7 @@ #include "plan-executor.h" #include "types.h" #include "vpack-types.h" +#include "deserialize-with.h" namespace deserializer { @@ -51,7 +52,7 @@ struct field_name_dependent_executor, fiel template struct field_name_dependent_executor { using unpack_result = result; - static auto unpack(::deserializer::slice_type s) -> unpack_result { + static auto unpack(::deserializer::slice_type /*s*/) -> unpack_result { using namespace std::string_literals; return unpack_result{deserialize_error{"format not recognized"}}; } @@ -74,7 +75,7 @@ struct deserialize_plan_executor, H> { using tuple_type = std::tuple; using result_type = result; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { return ::deserializer::detail::field_name_dependent_executor::unpack(s) .visit(::deserializer::detail::gadgets::visitor{ [](variant_type const& v) { return result_type{std::make_tuple(v)}; }, diff --git a/deserialize/field-value-dependent.h b/deserialize/field-value-dependent.h index f25a0c6..094f9d7 100644 --- a/deserialize/field-value-dependent.h +++ b/deserialize/field-value-dependent.h @@ -112,7 +112,7 @@ struct deserialize_plan_executor, H> { using variant_type = typename plan_result_tuple_type::variant; using unpack_result = result; constexpr static auto name = N; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> unpack_result { /* * Select the sub deserializer depending on the value. @@ -135,7 +135,7 @@ struct deserialize_plan_executor, H> { template struct deserialize_plan_executor, H> { - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) { + static auto unpack(::deserializer::slice_type /*s*/, typename H::state_type /*hints*/) { /* * No matching type was found, we can not deserialize. */ diff --git a/deserialize/fixed-order.h b/deserialize/fixed-order.h index 398e967..2838a9c 100644 --- a/deserialize/fixed-order.h +++ b/deserialize/fixed-order.h @@ -77,7 +77,7 @@ struct deserialize_plan_executor, H> { constexpr static auto expected_array_length = sizeof...(Ds); - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { using namespace std::string_literals; if (!s.isArray()) { diff --git a/deserialize/gadgets.h b/deserialize/gadgets.h index f33e673..1525294 100644 --- a/deserialize/gadgets.h +++ b/deserialize/gadgets.h @@ -2,6 +2,7 @@ #define VELOCYPACK_GADGETS_H #include #include +#include namespace deserializer::detail::gadgets { namespace detail { diff --git a/deserialize/map.h b/deserialize/map.h index f654629..b57ca97 100644 --- a/deserialize/map.h +++ b/deserialize/map.h @@ -1,8 +1,7 @@ #ifndef VELOCYPACK_MAP_H #define VELOCYPACK_MAP_H -#include "plan-executor.h" -#include "utilities.h" -#include "vpack-types.h" +#include "deserialize-with.h" +#include "value-reader.h" namespace deserializer { @@ -40,7 +39,7 @@ struct deserialize_plan_executor, H> { using proxy_type = typename map_deserializer::constructed_type; using tuple_type = std::tuple; using result_type = result; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { proxy_type result; using namespace std::string_literals; diff --git a/deserialize/parameter-list.h b/deserialize/parameter-list.h index 03d4c37..393c154 100644 --- a/deserialize/parameter-list.h +++ b/deserialize/parameter-list.h @@ -96,7 +96,7 @@ struct parameter_executor, H using result_type = result, deserialize_error>; constexpr static bool has_value = true; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) { using namespace std::string_literals; auto value_slice = s.get(N); @@ -124,7 +124,7 @@ struct parameter_executor, H> { using result_type = result, deserialize_error>; constexpr static bool has_value = true; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { using namespace std::string_literals; auto value_slice = s.get(N); @@ -149,7 +149,7 @@ struct parameter_executor, H> { using result_type = result, deserialize_error>; constexpr static bool has_value = true; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { using namespace std::string_literals; auto value_slice = s.get(N); @@ -178,7 +178,7 @@ struct parameter_executor, H> { using result_type = result, deserialize_error>; constexpr static bool has_value = true; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { auto value_slice = s.get(N); if (!value_slice.isNone()) { return result_type{std::make_pair(value_slice, true)}; @@ -201,17 +201,17 @@ struct parameter_executor, H> { using result_type = result, deserialize_error>; constexpr static bool has_value = false; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { values::ensure_value_comparator{}; if constexpr (!hints::hint_list_contains_v, H>) { auto value_slice = s.get(N); if (!values::value_comparator::compare(value_slice)) { using namespace std::string_literals; - return result_type{std::move(deserialize_error{ + return result_type{deserialize_error{ "value at `"s + N + "` not as expected, found: `" + value_slice.toJson() + "`, expected: `" + to_string(V{}) + "`"} - .trace(N))}; + .trace(N)}; } } @@ -269,7 +269,7 @@ struct parameter_list_executor, H> { using unpack_result = result; template - static auto unpack(T& t, ::deserializer::slice_type s, typename H::state_type hints) + static auto unpack(T& /*t*/, ::deserializer::slice_type s, typename H::state_type /*hints*/) -> unpack_result { if (s.length() != K) { return unpack_result{deserialize_error{ diff --git a/deserialize/plan-executor.h b/deserialize/plan-executor.h index d918b34..212421c 100644 --- a/deserialize/plan-executor.h +++ b/deserialize/plan-executor.h @@ -1,6 +1,8 @@ #ifndef VELOCYPACK_PLAN_EXECUTOR_H #define VELOCYPACK_PLAN_EXECUTOR_H +#include + namespace deserializer::executor { /* diff --git a/deserialize/try-alternatives.h b/deserialize/try-alternatives.h index 82bdc27..d460675 100644 --- a/deserialize/try-alternatives.h +++ b/deserialize/try-alternatives.h @@ -1,6 +1,7 @@ #ifndef VELOCYPACK_TRY_ALTERNATIVES_H #define VELOCYPACK_TRY_ALTERNATIVES_H #include "utilities.h" +#include "deserialize-with.h" namespace deserializer { namespace try_alternatives { @@ -43,7 +44,7 @@ struct deserialize_plan_executor::constructed_type; using tuple_type = std::tuple; using result_type = result; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { /* * Try one alternative after the other. Take the first that does not fail. If all fail, fail. */ diff --git a/deserialize/unpack-proxy.h b/deserialize/unpack-proxy.h index 6a629d6..76a3992 100644 --- a/deserialize/unpack-proxy.h +++ b/deserialize/unpack-proxy.h @@ -5,6 +5,10 @@ #ifndef VELOCYPACK_UNPACK_PROXY_H #define VELOCYPACK_UNPACK_PROXY_H +#include +#include "deserialize-with.h" +#include "utilities.h" + namespace deserializer { template struct unpack_proxy { diff --git a/deserialize/utilities.h b/deserialize/utilities.h index 43c17c4..fcf4b14 100644 --- a/deserialize/utilities.h +++ b/deserialize/utilities.h @@ -1,5 +1,6 @@ #ifndef VELOCYPACK_UTILITIES_H #define VELOCYPACK_UTILITIES_H +#include #include "gadgets.h" namespace deserializer::utilities { diff --git a/deserialize/values.h b/deserialize/values.h index 8bb5cd3..bc321b0 100644 --- a/deserialize/values.h +++ b/deserialize/values.h @@ -126,7 +126,7 @@ struct deserialize_plan_executor, H> { using value_type = T; using tuple_type = std::tuple; using result_type = result; - static auto unpack(::deserializer::slice_type s, typename H::state_type hints) -> result_type { + static auto unpack(::deserializer::slice_type s, typename H::state_type /*hints*/) -> result_type { ensure_value_reader{}; return value_reader::read(s).map( [](T t) { return std::make_tuple(std::move(t)); });