mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
Call prepare_done function to form response
This commit is contained in:
committed by
Marcelo Zimbres
parent
9419c857fd
commit
ecd1573257
@@ -53,6 +53,7 @@ public:
|
||||
static auto create_impl(T& resp) -> impl_t
|
||||
{
|
||||
using namespace boost::redis::adapter;
|
||||
|
||||
return [adapter2 = boost_redis_adapt(resp)](
|
||||
any_adapter::parse_event ev,
|
||||
resp3::node_view const& nd,
|
||||
|
||||
@@ -139,6 +139,24 @@ void boost_redis_from_bulk(T& t, resp3::basic_node<String> const& node, system::
|
||||
|
||||
//================================================
|
||||
|
||||
template <typename T>
|
||||
auto prepare_done(T&) noexcept -> std::function<void()>
|
||||
{
|
||||
return [] { };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto prepare_done(generic_flat_response& resp) noexcept -> std::function<void()>
|
||||
{
|
||||
return [resp]() mutable {
|
||||
if (resp.has_value()) {
|
||||
resp.value().set_view();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//================================================
|
||||
|
||||
template <class Result>
|
||||
class general_aggregate {
|
||||
private:
|
||||
|
||||
@@ -50,11 +50,7 @@ public:
|
||||
offset_string.offset = data_.size();
|
||||
offset_string.size = nd.value.size();
|
||||
|
||||
data_.append(nd.value.data());
|
||||
|
||||
offset_string.data = std::string_view{
|
||||
data_.data() + offset_string.offset,
|
||||
offset_string.size};
|
||||
data_.append(nd.value.data(), nd.value.size());
|
||||
|
||||
resp3::offset_node new_node;
|
||||
new_node.data_type = nd.data_type;
|
||||
@@ -65,6 +61,16 @@ public:
|
||||
view_.push_back(std::move(new_node));
|
||||
}
|
||||
|
||||
void set_view()
|
||||
{
|
||||
for (auto& node : view_) {
|
||||
auto& offset_string = node.value;
|
||||
offset_string.data = std::string_view{
|
||||
data_.data() + offset_string.offset,
|
||||
offset_string.size};
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::string data_;
|
||||
std::vector<resp3::offset_node> view_;
|
||||
|
||||
Reference in New Issue
Block a user