Ditto 4.5.3
Loading...
Searching...
No Matches
Register.hpp
1
2#ifndef _DITTO_REGISTER_
3#define _DITTO_REGISTER_
4
5#include "AbstractDocumentPath.hpp"
6
7#include "internal_errors.hpp"
8#include "json.hpp"
9
10namespace ditto {
11class Register {
12 friend class AbstractDocumentPath;
13
14public:
15 template <class T> Register(T value);
16 Register(const nlohmann::json &info);
21 template <typename T> T get_value() const;
22 nlohmann::json get_json_value() const;
23 DittoCrdtType get_type() const;
24
25protected:
26 nlohmann::json value;
27};
28
29void to_json(nlohmann::json &j, const Register &a);
30
31template <class T> Register::Register(T ext_value) {
32 value = nlohmann::json(ext_value);
33}
34
35template <class T> T Register::get_value() const { return T(value); }
36} // namespace ditto
37
38#endif
Provides an interface to specify a path to a key in a document that you can then call various update ...
Definition AbstractDocumentPath.hpp:21
Definition Register.hpp:11
T get_value() const
Get the value of the register in the current view of the document.
Definition Register.hpp:35
basic_json<> json
default JSON class
Definition json.hpp:2933