3 #include <zk/config.hpp>
5 #include <initializer_list>
13 #include "forwards.hpp"
24 enum class op_type : int
32 std::ostream& operator<<(std::ostream&,
const op_type&);
34 std::string to_string(
const op_type&);
46 op_type type()
const {
return op_type::check; }
61 op_type type()
const {
return op_type::create; }
75 op_type type()
const {
return op_type::erase; }
89 op_type type()
const {
return op_type::set; }
99 op& operator=(const
op&) = delete;
100 op& operator=(
op&&) = delete;
104 op_type type() const;
117 explicit
op(any_data&&) noexcept;
119 template <typename T>
120 const T& as(
ptr<const
char> operation) const;
122 friend std::ostream& operator<<(std::ostream&, const
op&);
128 std::ostream& operator<<(std::ostream&, const op&);
130 std::
string to_string(const op&);
135 using iterator = std::vector<op>::iterator;
136 using const_iterator = std::vector<op>::const_iterator;
137 using size_type = std::vector<op>::size_type;
143 multi_op(std::vector<op> ops) noexcept;
145 multi_op(std::initializer_list<op> ops) :
151 size_type size()
const {
return _ops.size(); }
153 op& operator[](size_type idx) {
return _ops[idx]; }
154 const op& operator[](size_type idx)
const {
return _ops[idx]; }
156 iterator begin() {
return _ops.begin(); }
157 const_iterator begin()
const {
return _ops.begin(); }
158 const_iterator cbegin()
const {
return _ops.begin(); }
160 iterator end() {
return _ops.end(); }
161 const_iterator end()
const {
return _ops.end(); }
162 const_iterator cend()
const {
return _ops.end(); }
164 void reserve(size_type capacity) { _ops.reserve(capacity); }
166 template <
typename... TArgs>
167 void emplace_back(TArgs&&... args)
169 _ops.emplace_back(std::forward<TArgs>(args)...);
172 void push_back(op&& x)
174 emplace_back(std::move(x));
177 void push_back(
const op& x)
183 std::vector<op> _ops;
186 std::ostream& operator<<(std::ostream&,
const multi_op&);
188 std::string to_string(
const multi_op&);
197 explicit part(op_type, std::nullptr_t) noexcept;
204 part& operator=(
const part&) =
delete;
210 op_type
type()
const {
return _type; }
217 using any_result = std::variant<std::monostate, create_result, set_result>;
219 template <
typename T>
227 using iterator = std::vector<part>::iterator;
228 using const_iterator = std::vector<part>::const_iterator;
229 using size_type = std::vector<part>::size_type;
235 multi_result(std::vector<part> parts) noexcept;
237 ~multi_result() noexcept;
239 size_type size()
const {
return _parts.size(); }
241 part& operator[](size_type idx) {
return _parts[idx]; }
242 const part& operator[](size_type idx)
const {
return _parts[idx]; }
244 iterator begin() {
return _parts.begin(); }
245 const_iterator begin()
const {
return _parts.begin(); }
246 const_iterator cbegin()
const {
return _parts.begin(); }
248 iterator end() {
return _parts.end(); }
249 const_iterator end()
const {
return _parts.end(); }
250 const_iterator cend()
const {
return _parts.end(); }
252 void reserve(size_type capacity) { _parts.reserve(capacity); }
254 template <
typename... TArgs>
255 void emplace_back(TArgs&&... args)
257 _parts.emplace_back(std::forward<TArgs>(args)...);
260 void push_back(part&& x)
262 emplace_back(std::move(x));
265 void push_back(
const part& x)
271 std::vector<part> _parts;
274 std::ostream& operator<<(std::ostream&,
const multi_result::part&);
275 std::ostream& operator<<(std::ostream&,
const multi_result&);
277 std::string to_string(
const multi_result::part&);
278 std::string to_string(
const multi_result&);
T * ptr
A simple, unowned pointer.
Describes the various result types of client operations.
The result type of client::create.
create_mode
When used in client::set, this value determines how the znode is created on the server.
Standard behavior of a znode – the opposite of doing any of the options.
You can create a child node.
The result type of client::set.
An access control list is a wrapper around acl_rule instances.
Controls the buffer type.
op_type type() const
The op_type of the op that caused this result.
You can erase a child node (but not necessarily this one).
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.
static op create(std::string path, buffer data, acl rules, create_mode mode=create_mode::normal)
Represents a version of the data.
ZKPP_BUFFER_TYPE buffer
The buffer type.
static op erase(std::string path, version check=version::any())
static op set(std::string path, buffer data, version check=version::any())