mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
Addressed some comments
This commit is contained in:
committed by
Marcelo Zimbres
parent
ccb17f89cd
commit
7d959c1039
@@ -178,12 +178,12 @@ public:
|
||||
};
|
||||
|
||||
template <>
|
||||
class general_aggregate<result<flat_response_impl>> {
|
||||
class general_aggregate<result<flat_response_value>> {
|
||||
private:
|
||||
result<flat_response_impl>* result_;
|
||||
result<flat_response_value>* result_;
|
||||
|
||||
public:
|
||||
explicit general_aggregate(result<flat_response_impl>* c = nullptr)
|
||||
explicit general_aggregate(result<flat_response_value>* c = nullptr)
|
||||
: result_(c)
|
||||
{ }
|
||||
template <class String>
|
||||
@@ -198,8 +198,7 @@ public:
|
||||
std::string{std::cbegin(nd.value), std::cend(nd.value)}
|
||||
};
|
||||
break;
|
||||
default:
|
||||
result_->value().push_back(nd);
|
||||
default: result_->value().push_back(nd);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,14 +59,6 @@ using node = basic_node<std::string>;
|
||||
/// A node in the response tree that does not own its data.
|
||||
using node_view = basic_node<std::string_view>;
|
||||
|
||||
/**
|
||||
* TODO: documentation
|
||||
*/
|
||||
struct offset_node : node_view {
|
||||
std::size_t offset{};
|
||||
std::size_t size{};
|
||||
};
|
||||
|
||||
} // namespace boost::redis::resp3
|
||||
|
||||
#endif // BOOST_REDIS_RESP3_NODE_HPP
|
||||
|
||||
@@ -31,7 +31,7 @@ using response = std::tuple<adapter::result<Ts>...>;
|
||||
*/
|
||||
using generic_response = adapter::result<std::vector<resp3::node>>;
|
||||
|
||||
struct flat_response_impl {
|
||||
struct flat_response_value {
|
||||
private:
|
||||
class iterator {
|
||||
public:
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
using reference = value_type;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
explicit iterator(flat_response_impl* owner, std::size_t i) noexcept
|
||||
explicit iterator(flat_response_value* owner, std::size_t i) noexcept
|
||||
: owner_(owner)
|
||||
, index_(i)
|
||||
{ }
|
||||
@@ -58,10 +58,15 @@ private:
|
||||
bool operator!=(const iterator& other) const { return !(*this == other); }
|
||||
|
||||
private:
|
||||
flat_response_impl* owner_;
|
||||
flat_response_value* owner_;
|
||||
std::size_t index_;
|
||||
};
|
||||
|
||||
struct offset_node : resp3::node_view {
|
||||
std::size_t offset{};
|
||||
std::size_t size{};
|
||||
};
|
||||
|
||||
public:
|
||||
resp3::node_view at(std::size_t index) { return make_node_view(view_.at(index)); }
|
||||
|
||||
@@ -76,37 +81,36 @@ public:
|
||||
template <typename String>
|
||||
void push_back(const resp3::basic_node<String>& nd)
|
||||
{
|
||||
resp3::offset_node new_node;
|
||||
offset_node new_node;
|
||||
new_node.data_type = nd.data_type;
|
||||
new_node.aggregate_size = nd.aggregate_size;
|
||||
new_node.depth = nd.depth;
|
||||
new_node.offset = data_.size();
|
||||
new_node.size = nd.value.size();
|
||||
|
||||
data_ += std::string{std::cbegin(nd.value), std::cend(nd.value)};
|
||||
|
||||
data_.append(nd.value.data());
|
||||
view_.push_back(std::move(new_node));
|
||||
}
|
||||
|
||||
private:
|
||||
resp3::node_view make_node_view(const resp3::offset_node& n)
|
||||
resp3::node_view make_node_view(const offset_node& nd)
|
||||
{
|
||||
return resp3::node_view{
|
||||
.data_type = n.data_type,
|
||||
.aggregate_size = n.aggregate_size,
|
||||
.depth = n.depth,
|
||||
.value = std::string_view{data_.data() + n.offset, n.size}
|
||||
};
|
||||
resp3::node_view result;
|
||||
result.data_type = nd.data_type;
|
||||
result.aggregate_size = nd.aggregate_size;
|
||||
result.depth = nd.depth;
|
||||
result.value = std::string_view{data_.data() + nd.offset, nd.size};
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string data_;
|
||||
std::vector<resp3::offset_node> view_;
|
||||
std::vector<offset_node> view_;
|
||||
};
|
||||
|
||||
/**
|
||||
* TODO: documentation
|
||||
*/
|
||||
using generic_flat_response = adapter::result<flat_response_impl>;
|
||||
using generic_flat_response = adapter::result<flat_response_value>;
|
||||
|
||||
/** @brief Consume on response from a generic response
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user