boost::redis::resp3::flat_tree

A generic response that stores data contiguously.

Synopsis

class flat_tree;

Description

Implements a container of RESP3 nodes. It's similar to boost::redis::resp3::tree, but node data is stored contiguously. This allows for amortized no allocations when re‐using flat_tree objects. Like tree, it can contain the response to several Redis commands or several server pushes. Use get_total_msgs to obtain how many responses this object contains.

Objects are typically created by the user and passed to connection::async_exec to be used as response containers. Once populated, they can be used as a const range of resp3::node_view objects. The usual random access range methods (like at, size or front) are provided. Once populated, flat_tree can't be modified, except for clear and assignment.

flat_tree models std::ranges::contiguous_range.

A flat_tree is conceptually similar to a pair of std::vector objects, one holding resp3::node_view objects, and another owning the the string data that these views point to. The node capacity and the data capacity are the capacities of these two vectors.

Types

Name

Description

iterator

The type of the iterators returned by begin and end.

reverse_iterator

The type of the iterators returned by rbegin and rend.

Member Functions

Name

Description

flat_tree [constructor]

Constructors

operator=

Assignment operators

begin

Returns an iterator to the first element of the node range.

end

Returns an iterator past the last element in the node range.

rbegin

Returns an iterator to the first element of the reversed node range.

rend

Returns an iterator past the last element of the reversed node range.

at

Returns a reference to the node at the specified position (checked access).

operator[]

Returns a reference to the node at the specified position (unchecked access).

front

Returns a reference to the first node.

back

Returns a reference to the last node.

data

Returns a pointer to the underlying node storage.

empty

Checks whether the tree is empty.

size

Returns the number of nodes in the tree.

reserve

Reserves capacity for incoming data.

clear

Clears the tree so it contains no nodes.

data_size

Returns the size of the data buffer, in bytes.

capacity

Returns the capacity of the node container.

data_capacity

Returns the capacity of the data buffer, in bytes.

get_reallocs

Returns the number of memory reallocations that took place in the data buffer.

get_total_msgs

Returns the number of complete RESP3 messages contained in this object.

Friends

Name Description

boost::redis::adapter::detail::general_aggregate

Non-Member Functions

Name

Description

operator!=

Inequality operator.

operator==

Equality operator.

Created with MrDocs