Ditto  3.0.4
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 
10 namespace ditto {
11 class Register {
12  friend class AbstractDocumentPath;
13 
14 public:
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 
25 protected:
26  nlohmann::json value;
27 };
28 
29 void to_json(nlohmann::json &j, const Register &a);
30 
31 template <class T> Register::Register(T ext_value) {
32  value = nlohmann::json(ext_value);
33 }
34 
35 template <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