12 static std::string to_string_generic(
const T&
self)
14 std::ostringstream os;
23 std::ostream& operator<<(std::ostream& os,
const op_type&
self)
27 case op_type::check:
return os <<
"check";
28 case op_type::create:
return os <<
"create";
29 case op_type::erase:
return os <<
"erase";
30 case op_type::set:
return os <<
"set";
31 default:
return os <<
"op_type(" <<
static_cast<int>(
self) <<
')';
35 std::string to_string(
const op_type&
self)
37 return to_string_generic(
self);
46 op::check_data::check_data(std::string path, version check_) :
47 path(
std::move(path)),
51 std::ostream& operator<<(std::ostream& os,
const op::check_data&
self)
53 os <<
'{' <<
self.path;
54 os <<
' ' <<
self.check;
63 op::any_data::any_data(
check_data&& src) noexcept :
68 _type(op_type::check),
69 _storage(std::move(src))
74 if (_type != op_type::check)
75 throw std::logic_error(
"Invalid op type for as_check: " + to_string(_type));
77 return _storage.check;
83 path(std::move(path)),
84 data(std::move(data)),
85 rules(std::move(rules)),
91 os <<
'{' <<
self.path;
92 os <<
' ' <<
self.mode;
93 os <<
' ' <<
self.rules;
99 return op(
create_data(std::move(path), std::move(data), std::move(rules), mode));
104 return create(std::move(path), std::move(data), acls::open_unsafe(), mode);
107 op::any_data::any_data(
create_data&& src) noexcept :
112 _type(op_type::create),
113 _storage(std::move(src))
118 if (_type != op_type::create)
119 throw std::logic_error(
"Invalid op type for as_create: " + to_string(_type));
121 return _storage.create;
126 op::erase_data::erase_data(std::string path,
version check) :
127 path(std::move(path)),
131 std::ostream& operator<<(std::ostream& os,
const op::erase_data&
self)
133 os <<
'{' <<
self.path;
134 os <<
' ' <<
self.check;
143 op::any_data::any_data(
erase_data&& src) noexcept :
144 erase(std::move(src))
148 _type(op_type::erase),
149 _storage(std::move(src))
154 if (_type != op_type::erase)
155 throw std::logic_error(
"Invalid op type for as_erase: " + to_string(_type));
157 return _storage.erase;
162 op::set_data::set_data(std::string path,
buffer data,
version check) :
163 path(std::move(path)),
164 data(std::move(data)),
168 std::ostream& operator<<(std::ostream& os,
const op::set_data&
self)
170 os <<
'{' <<
self.path;
171 os <<
' ' <<
self.check;
177 return op(
set_data(std::move(path), std::move(data), check));
180 op::any_data::any_data(
set_data&& src) noexcept :
186 _storage(std::move(src))
191 if (_type != op_type::set)
192 throw std::logic_error(
"Invalid op type for as_set: " + to_string(_type));
199 op::any_data::any_data(std::nullptr_t) noexcept
202 op::any_data::~any_data() noexcept
207 template <
typename T,
typename... TArgs>
208 static void place_new(
ptr<T> destination, TArgs&&... args)
209 noexcept(noexcept(T(std::forward<TArgs>(args)...)))
211 new (
static_cast<ptr<void>>(destination)) T(std::forward<TArgs>(args)...);
214 op::op(
const op& src) :
220 case op_type::check: place_new(&_storage.check, src._storage.check);
break;
221 case op_type::create: place_new(&_storage.create, src._storage.create);
break;
222 case op_type::erase: place_new(&_storage.erase, src._storage.erase);
break;
223 case op_type::set: place_new(&_storage.set, src._storage.set);
break;
227 op::op(
op&& src) noexcept :
233 case op_type::check: place_new(&_storage.check, std::move(src._storage.check));
break;
234 case op_type::create: place_new(&_storage.create, std::move(src._storage.create));
break;
235 case op_type::erase: place_new(&_storage.erase, std::move(src._storage.erase));
break;
236 case op_type::set: place_new(&_storage.set, std::move(src._storage.set));
break;
244 case op_type::check: _storage.check.~auto();
break;
245 case op_type::create: _storage.create.~auto();
break;
246 case op_type::erase: _storage.erase.~auto();
break;
247 case op_type::set: _storage.set.~auto();
break;
251 std::ostream& operator<<(std::ostream& os,
const op&
self)
256 case op_type::check:
return os <<
self.as_check();
257 case op_type::create:
return os <<
self.as_create();
258 case op_type::erase:
return os <<
self.as_erase();
259 case op_type::set:
return os <<
self.as_set();
260 default:
return os <<
"{ ??? }";
264 std::string to_string(
const op&
self)
266 std::ostringstream os;
275 multi_op::multi_op(std::vector<op> ops) noexcept :
279 multi_op::~multi_op() noexcept
282 std::ostream& operator<<(std::ostream& os,
const multi_op&
self)
286 for (
const auto& x :
self)
301 multi_result::any_result::any_result(std::nullptr_t) noexcept
304 multi_result::part::part(op_type type, std::nullptr_t) noexcept :
309 multi_result::any_result::any_result(
create_result&& res) noexcept :
314 _type(op_type::create),
315 _storage(std::move(res))
318 multi_result::any_result::any_result(
set_result&& res) noexcept :
322 multi_result::part::part(
set_result res) noexcept :
324 _storage(std::move(res))
327 multi_result::any_result::~any_result() noexcept
332 multi_result::part::part(
const part& src) :
338 case op_type::create: place_new(&_storage.create, src._storage.create);
break;
339 case op_type::set: place_new(&_storage.set, src._storage.set);
break;
344 multi_result::part::part(part&& src) noexcept :
350 case op_type::create: place_new(&_storage.create, std::move(src._storage.create));
break;
351 case op_type::set: place_new(&_storage.set, std::move(src._storage.set));
break;
356 multi_result::part::~part() noexcept
360 case op_type::create: _storage.create.~create_result();
break;
361 case op_type::set: _storage.set.~set_result();
break;
368 if (_type != op_type::create)
369 throw std::logic_error(
"Invalid part type for as_create: " + to_string(_type));
371 return _storage.create;
374 const set_result& multi_result::part::as_set()
const 376 if (_type != op_type::set)
377 throw std::logic_error(
"Invalid part type for as_set: " + to_string(_type));
382 multi_result::multi_result(std::vector<part> parts) noexcept :
383 _parts(std::move(parts))
386 multi_result::~multi_result() noexcept
393 case op_type::create:
return os <<
self.as_create();
394 case op_type::set:
return os <<
self.as_set();
395 default:
return os <<
self.type() <<
"_result{}";
399 std::ostream& operator<<(std::ostream& os,
const multi_result&
self)
403 for (
const auto& x :
self)
416 return to_string_generic(
self);
421 return to_string_generic(
self);
T * ptr
A simple, unowned pointer.
The result type of client::create.
create_mode
When used in client::set, this value determines how the znode is created on the server.
You can create a child node.
The result type of client::set.
An access control list is a wrapper around acl_rule instances.
You can erase a child node (but not necessarily this one).
Represents a version of the data.
ZKPP_BUFFER_TYPE buffer
The buffer type.