2
0
mirror of https://github.com/boostorg/redis.git synced 2026-02-21 15:22:14 +00:00
Files
redis/tests/basic_flat_array_adapter.hpp
Marcelo Zimbres 42da305b01 Refactoring.
2021-11-06 11:32:52 +01:00

44 lines
1010 B
C++

/* Copyright (c) 2019 - 2021 Marcelo Zimbres Silva (mzimbres at gmail dot com)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <aedis/resp3/type.hpp>
#include <aedis/resp3/response_adapter_base.hpp>
#include "adapter_utils.hpp"
namespace aedis {
namespace resp3 {
namespace detail {
template <class T>
using basic_flat_array = std::vector<T>;
template <class T>
struct basic_flat_array_adapter : response_adapter_base {
int i = 0;
basic_flat_array<T>* result = nullptr;
basic_flat_array_adapter(basic_flat_array<T>* p) : result(p) {}
void add(type t, int n, int depth, std::string_view s = {}) override
{
if (is_aggregate(t)) {
i = 0;
result->resize(n);
} else {
from_string_view(s, result->at(i));
++i;
}
}
};
} // detail
} // resp3
} // aedis