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
2 changes: 2 additions & 0 deletions .clang_complete
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-I
velocypack/include
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions deserialize/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions deserialize/conditional.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ template <std::size_t I, typename E>
struct conditional_executor<I, E> {
using R = typename E::variant_type;
using unpack_result = result<R, deserialize_error>;
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() + "`"}};
Expand All @@ -145,7 +145,7 @@ struct deserialize_plan_executor<conditional<CSs...>, H> {
using variant_type = typename plan_result_tuple_type::variant;
using unpack_result = result<unpack_tuple_type, deserialize_error>;

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.
Expand Down
2 changes: 1 addition & 1 deletion deserialize/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions deserialize/field-name-dependent.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "plan-executor.h"
#include "types.h"
#include "vpack-types.h"
#include "deserialize-with.h"

namespace deserializer {

Expand Down Expand Up @@ -51,7 +52,7 @@ struct field_name_dependent_executor<R, field_name_deserializer_pair<N, D>, fiel
template <typename R>
struct field_name_dependent_executor<R> {
using unpack_result = result<R, deserialize_error>;
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"}};
}
Expand All @@ -74,7 +75,7 @@ struct deserialize_plan_executor<field_name_dependent<NDs...>, H> {
using tuple_type = std::tuple<value_type>;
using result_type = result<tuple_type, deserialize_error>;

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<variant_type, NDs...>::unpack(s)
.visit(::deserializer::detail::gadgets::visitor{
[](variant_type const& v) { return result_type{std::make_tuple(v)}; },
Expand Down
4 changes: 2 additions & 2 deletions deserialize/field-value-dependent.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct deserialize_plan_executor<field_value_dependent<N, VSs...>, H> {
using variant_type = typename plan_result_tuple_type::variant;
using unpack_result = result<unpack_tuple_type, deserialize_error>;
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.
Expand All @@ -135,7 +135,7 @@ struct deserialize_plan_executor<field_value_dependent<N, VSs...>, H> {

template <const char N[], typename H>
struct deserialize_plan_executor<field_value_dependent<N>, 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.
*/
Expand Down
2 changes: 1 addition & 1 deletion deserialize/fixed-order.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct deserialize_plan_executor<fixed_order_deserializer<Ds...>, 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()) {
Expand Down
1 change: 1 addition & 0 deletions deserialize/gadgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define VELOCYPACK_GADGETS_H
#include <cstddef>
#include <tuple>
#include <optional>

namespace deserializer::detail::gadgets {
namespace detail {
Expand Down
7 changes: 3 additions & 4 deletions deserialize/map.h
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -40,7 +39,7 @@ struct deserialize_plan_executor<map_deserializer<D, C, K, F>, H> {
using proxy_type = typename map_deserializer<D, C, K, F>::constructed_type;
using tuple_type = std::tuple<proxy_type>;
using result_type = result<tuple_type, deserialize_error>;
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;

Expand Down
16 changes: 8 additions & 8 deletions deserialize/parameter-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct parameter_executor<factory_simple_parameter<N, T, required, default_v>, H
using result_type = result<std::pair<T, bool>, 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);
Expand Down Expand Up @@ -124,7 +124,7 @@ struct parameter_executor<factory_optional_parameter<N, T>, H> {
using result_type = result<std::pair<value_type, bool>, 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);
Expand All @@ -149,7 +149,7 @@ struct parameter_executor<factory_deserialized_parameter<N, D, required>, H> {
using result_type = result<std::pair<value_type, bool>, 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);
Expand Down Expand Up @@ -178,7 +178,7 @@ struct parameter_executor<factory_slice_parameter<N, required>, H> {
using result_type = result<std::pair<value_type, bool>, 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)};
Expand All @@ -201,17 +201,17 @@ struct parameter_executor<expected_value<N, V>, H> {
using result_type = result<std::pair<unit_type, bool>, 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<V>{};
if constexpr (!hints::hint_list_contains_v<hints::has_field_with_value<N, V>, H>) {
auto value_slice = s.get(N);
if (!values::value_comparator<V>::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)};
}
}

Expand Down Expand Up @@ -269,7 +269,7 @@ struct parameter_list_executor<I, K, parameter_list<>, H> {
using unpack_result = result<unit_type, deserialize_error>;

template <typename T>
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{
Expand Down
2 changes: 2 additions & 0 deletions deserialize/plan-executor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef VELOCYPACK_PLAN_EXECUTOR_H
#define VELOCYPACK_PLAN_EXECUTOR_H

#include <tuple>

namespace deserializer::executor {

/*
Expand Down
11 changes: 9 additions & 2 deletions deserialize/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 2 additions & 1 deletion deserialize/try-alternatives.h
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -43,7 +44,7 @@ struct deserialize_plan_executor<try_alternatives::try_alternatives_deserializer
typename try_alternatives::try_alternatives_deserializer<Ds...>::constructed_type;
using tuple_type = std::tuple<value_type>;
using result_type = result<tuple_type, deserialize_error>;
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.
*/
Expand Down
4 changes: 4 additions & 0 deletions deserialize/unpack-proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#ifndef VELOCYPACK_UNPACK_PROXY_H
#define VELOCYPACK_UNPACK_PROXY_H

#include <memory>
#include "deserialize-with.h"
#include "utilities.h"

namespace deserializer {
template <typename D, typename P = D>
struct unpack_proxy {
Expand Down
1 change: 1 addition & 0 deletions deserialize/utilities.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef VELOCYPACK_UTILITIES_H
#define VELOCYPACK_UTILITIES_H
#include <memory>
#include "gadgets.h"

namespace deserializer::utilities {
Expand Down
2 changes: 1 addition & 1 deletion deserialize/values.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct deserialize_plan_executor<values::value_deserializer<T>, H> {
using value_type = T;
using tuple_type = std::tuple<value_type>;
using result_type = result<tuple_type, deserialize_error>;
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<T>{};
return value_reader<T>::read(s).map(
[](T t) { return std::make_tuple(std::move(t)); });
Expand Down