Realm C++ SDK Version v2.2.0

obj_key.hpp

1
2//
3// Copyright 2024 Realm Inc.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef CPPREALM_BRIDGE_OBJ_KEY_HPP
20#define CPPREALM_BRIDGE_OBJ_KEY_HPP
21
22#include <cinttypes>
23#include <memory>
24#include <type_traits>
25#include <cpprealm/internal/bridge/utils.hpp>
26
27namespace realm {
28 struct ObjKey;
29 struct ObjLink;
30}
31
32namespace realm::internal::bridge {
33 struct obj_key {
34 obj_key(const ObjKey&);
35 obj_key(int64_t);
36 obj_key();
37 obj_key(const obj_key& other) = default;
38 obj_key& operator=(const obj_key& other) = default;
39 obj_key(obj_key&& other) = default;
40 obj_key& operator=(obj_key&& other) = default;
41 ~obj_key() = default;
42 operator ObjKey() const;
43 private:
44 int64_t m_obj_key;
45 };
46
47 bool operator==(const obj_key &, const obj_key &);
48
49 bool operator!=(const obj_key &, const obj_key &);
50}
51
52namespace realm::internal::bridge {
53 struct obj_link {
54 obj_link(const ObjLink&);
55 obj_link();
56 obj_link(const obj_link& other);
57 obj_link(uint32_t table_key, obj_key obj_key);
58 obj_link& operator=(const obj_link& other);
59 obj_link(obj_link&& other);
60 obj_link& operator=(obj_link&& other);
61 ~obj_link();
62 operator ObjLink() const;
63 obj_key get_obj_key();
64 uint32_t get_table_key();
65 private:
66#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
67 storage::ObjLink m_obj_link[1];
68#else
69 std::shared_ptr<ObjLink> m_obj_link;
70#endif
71 };
72
73 bool operator==(const obj_link &, const obj_link &);
74
75 bool operator!=(const obj_link &, const obj_link &);
76}
77
78
79#endif //CPPREALM_BRIDGE_OBJ_KEY_HPP
Definition: obj_key.hpp:33