Realm C++ SDK Version v2.2.0

object_schema.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_OBJECT_SCHEMA_HPP
20#define CPPREALM_BRIDGE_OBJECT_SCHEMA_HPP
21
22#include <cstdint>
23#include <string>
24#include <vector>
25#include <cpprealm/internal/bridge/utils.hpp>
26
27namespace realm {
28 class ObjectSchema;
29}
30namespace realm::internal::bridge {
31 struct property;
32
34 enum class object_type : uint8_t { TopLevel = 0, Embedded = 0x1, TopLevelAsymmetric = 0x2 };
35
37
38 object_schema(const object_schema& other) ;
39 object_schema& operator=(const object_schema& other) ;
41 object_schema& operator=(object_schema&& other);
43
44
45 object_schema(const std::string& name,
46 const std::vector<property>& properties,
47 const std::string& primary_key,
48 object_type type);
49 object_schema(const ObjectSchema&);
50 operator ObjectSchema() const;
51 uint32_t table_key();
52 void add_property(const property&);
53
54 void set_name(const std::string& name);
55 std::string get_name() const;
56 void set_primary_key(const std::string& primary_key);
57 void set_object_type(object_type);
58 property property_for_name(const std::string&);
59 bool operator==(const object_schema& rhs);
60 private:
61 ObjectSchema* get_object_schema();
62 const ObjectSchema* get_object_schema() const;
63#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
64 storage::ObjectSchema m_schema[1];
65#else
66 std::shared_ptr<ObjectSchema> m_schema;
67#endif
68 };
69}
70
71#endif //CPPREALM_BRIDGE_OBJECT_SCHEMA_HPP
Definition: object_schema.hpp:33
Definition: property.hpp:33
Definition: managed_primary_key.hpp:30