3 #include <zk/config.hpp>
5 #include <initializer_list>
13 #include "forwards.hpp"
32 std::ostream& operator<<(std::ostream&,
const op_type&);
34 std::string to_string(
const op_type&);
112 op& operator=(const
op&) = delete;
113 op& operator=(
op&&) = delete;
143 explicit
op(any_data&&) noexcept;
145 template <typename T>
146 const T& as(
ptr<const
char> operation) const;
148 friend std::ostream& operator<<(std::ostream&, const
op&);
154 std::ostream& operator<<(std::ostream&, const op&);
156 std::
string to_string(const op&);
165 using iterator = std::vector<op>::iterator;
166 using const_iterator = std::vector<op>::const_iterator;
167 using size_type = std::vector<op>::size_type;
175 multi_op(std::vector<op> ops) noexcept;
185 size_type size()
const {
return _ops.
size(); }
189 const op&
operator[](size_type idx)
const {
return _ops[idx]; }
190 op& operator[](size_type idx) {
return _ops[idx]; }
197 const op&
at(size_type idx)
const {
return _ops.at(idx); }
198 op& at(size_type idx) {
return _ops.at(idx); }
203 iterator
begin() {
return _ops.begin(); }
204 const_iterator begin()
const {
return _ops.begin(); }
205 const_iterator cbegin()
const {
return _ops.begin(); }
210 iterator
end() {
return _ops.end(); }
211 const_iterator end()
const {
return _ops.end(); }
212 const_iterator cend()
const {
return _ops.end(); }
216 void reserve(size_type capacity) { _ops.reserve(capacity); }
221 template <
typename... TArgs>
224 _ops.emplace_back(std::forward<TArgs>(args)...);
230 void push_back(
const op& x) { emplace_back(x); }
234 std::vector<op> _ops;
237 std::ostream& operator<<(std::ostream&,
const multi_op&);
239 std::string to_string(
const multi_op&);
256 part& operator=(
const part&) =
delete;
275 using any_result = std::variant<std::monostate, create_result, set_result>;
277 template <
typename T>
285 using iterator = std::vector<part>::iterator;
286 using const_iterator = std::vector<part>::const_iterator;
287 using size_type = std::vector<part>::size_type;
293 multi_result(std::vector<part> parts) noexcept;
295 ~multi_result() noexcept;
298 size_type size()
const {
return _parts.
size(); }
305 const part& operator[](size_type idx)
const {
return _parts[idx]; }
312 const part&
at(size_type idx)
const {
return _parts.at(idx); }
313 part& at(size_type idx) {
return _parts.at(idx); }
318 iterator
begin() {
return _parts.begin(); }
319 const_iterator begin()
const {
return _parts.begin(); }
320 const_iterator cbegin()
const {
return _parts.begin(); }
325 iterator
end() {
return _parts.end(); }
326 const_iterator end()
const {
return _parts.end(); }
327 const_iterator cend()
const {
return _parts.end(); }
331 void reserve(size_type capacity) { _parts.reserve(capacity); }
336 template <
typename... TArgs>
339 _parts.emplace_back(std::forward<TArgs>(args)...);
345 void push_back(
const part& x) { emplace_back(x); }
349 std::vector<part> _parts;
352 std::ostream& operator<<(std::ostream&,
const multi_result::part&);
353 std::ostream& operator<<(std::ostream&,
const multi_result&);
355 std::string to_string(
const multi_result::part&);
356 std::string to_string(
const multi_result&);
T * ptr
A simple, unowned pointer.
Data for a op::set operation.
Describes the various result types of client operations.
void reserve(size_type capacity)
Increase the reserved memory block so it can store at least capacity operations without reallocating...
const set_data & as_set() const
Get the set-specific data.
part & operator[](size_type idx)
size_type size() const
The number of operations in this transaction bundle.
Represents a single operation of a multi_op.
The result type of client::create.
const part & at(size_type idx) const
op_type
Describes the type of an op.
const create_data & as_create() const
Get the create-specific data.
create_mode
When used in client::set, this value determines how the entry is created on the server.
void reserve(size_type capacity)
Increase the reserved memory block so it can store at least capacity results without reallocating...
multi_op(std::initializer_list< op > ops)
Create an instance from the provided ops.
Standard behavior of an entry – the opposite of doing any of the options.
Data for a op::check operation.
op_type type() const
Get the underlying type of this operation.
A collection of operations that will be performed atomically.
void emplace_back(TArgs &&...args)
Construct an operation emplace on the end of the list using args.
The result type of client::set.
const op & at(size_type idx) const
An access control list is a wrapper around acl_rule instances.
multi_op() noexcept
Create an empty operation set.
const erase_data & as_erase() const
Get the erase-specific data.
Controls the buffer type.
op_type type() const
The op_type of the op that caused this result.
static op check(std::string path, version check=version::any())
Check that the given path exists with the provided version check (which can be version::any).
static constexpr version any()
When specified in an operation, this version specifier will always pass.
const op & operator[](size_type idx) const
static op create(std::string path, buffer data, acl rules, create_mode mode=create_mode::normal)
A part of a result. The behavior depends on the type of op provided to the original transaction...
The result of a successful client::commit operation.
Represents a version of the data.
ZKPP_BUFFER_TYPE buffer
The buffer type.
size_type size() const
The number of results in this transaction bundle.
Data for a op::erase operation.
const check_data & as_check() const
Get the check-specific data.
void emplace_back(TArgs &&...args)
Construct a result emplace on the end of the list using args.
Data for a op::create operation.
static op erase(std::string path, version check=version::any())
Delete the entry at the given path if it matches the version check.
static op set(std::string path, buffer data, version check=version::any())
Set the data for the entry at path if it matches the version check.