Realm C++ SDK Version v2.2.0

table.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_TABLE_HPP
20#define CPPREALM_BRIDGE_TABLE_HPP
21
22#include <string>
23#include <vector>
24#include <cpprealm/internal/bridge/obj_key.hpp>
25
26namespace realm {
27 class TableRef;
28 class ConstTableRef;
29 class Mixed;
30 class TableView;
31
32
33 namespace internal::bridge {
34 struct col_key;
35 struct link_chain;
36 struct mixed;
37 struct obj;
38 struct query;
39
40 struct table {
41 table();
42 table(const table& other) ;
43 table& operator=(const table& other) ;
44 table(table&& other);
45 table& operator=(table&& other);
46 ~table();
47 table(const TableRef &);
48 table(const ConstTableRef &);
49 operator TableRef() const;
50 operator ConstTableRef() const;
51
52 col_key get_column_key(const std::string_view &name) const;
53 uint32_t get_key() const;
54 std::string get_name() const;
55
56 obj create_object_with_primary_key(const mixed &key) const;
57
58 obj create_object(const obj_key &obj_key = {}) const;
59
60 table get_link_target(const col_key col_key) const;
61 link_chain get_link(const col_key col_key) const;
62
63 [[nodiscard]] bool is_embedded() const;
64
65 struct query query(const std::string &, const std::vector <mixed>&) const;
66 struct query where() const;
67
68 void remove_object(const obj_key &) const;
69 obj get_object(const obj_key&) const;
70 bool is_valid(const obj_key&) const;
71 using underlying = TableRef;
72#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
73 storage::TableRef m_table[1];
74#else
75 std::shared_ptr<TableRef> m_table;
76#endif
77 };
78
79 struct table_view {
80 table_view();
81 table_view(const table_view& other) ;
82 table_view& operator=(const table_view& other) ;
83 table_view(table_view&& other);
84 table_view& operator=(table_view&& other);
86 table_view(const TableView &);
87 operator TableView() const;
88 using underlying = TableView;
89#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
90 storage::TableView m_table_view[1];
91#else
92 std::shared_ptr<TableView> m_table_view;
93#endif
94 };
95
96 bool operator==(const table &, const table &);
97
98 bool operator!=(const table &, const table &);
99 }
100}
101
102#endif //CPPREALM_BRIDGE_TABLE_HPP
Definition: col_key.hpp:28
Definition: mixed.hpp:69
Definition: obj_key.hpp:33
Definition: obj.hpp:123
Definition: query.hpp:131
Definition: table.hpp:79
Definition: table.hpp:40