19#ifndef CPPREALM_MANAGED_MIXED_HPP
20#define CPPREALM_MANAGED_MIXED_HPP
22#include <cpprealm/macros.hpp>
23#include <cpprealm/rbool.hpp>
24#include <cpprealm/types.hpp>
27 template <
typename T>
28 struct 托管 <T, std::enable_if_t< 域::internal::type_info::<T> MixedPersistableConcept::value>> :
publicmanaged_base {
29 运用 托管 <T>::managed_base:: 操作符=;
49 Managed & Operator =(
const T& v) {
50 m_obj-> 设立(m_key, std::visit([](
auto && arg) {
57 template <
typename U>
58 托管 & 操作符 =(
const U& v) {
63 [[nodiscard]] Stored_type get_stored_type()
const {
66 return Stored_Type::Null;
68 return static_cast< stored_type
> (val.type());
72 [[nodiscard]] T 分离 ()
const {
76 [[nodiscard]] T操作符*()
const {
81 rbool 操作符==(
const T& rhs)
const noException {
82 if (this->m_rbool_query) {
83 return this->m_rbool_query->mixed_equal(m_key,serialize(rhs));
85 return detach() == rhs;
88 rbool操作符!=(
const T& rhs)
const noException {
89 if (this->m_rbool_query) {
90 return this->m_rbool_query->mixed_not_equal(m_key,serialize(rhs));
92 return detach() != rhs;
95 rbool 操作符==(
const std::nullopt_t&)
const noException {
96 if (this->m_rbool_query) {
99 return detach() == T(std::monostate());
102 rbool操作符!=(
const std::nullopt_t&)
const noException {
103 if (this->m_rbool_query) {
106 return detach() != T(std::monostate());
109 bool has_link()
const {
110 return (get_stored_type() == Stored_type::TypedLink);
113 template <
typename U>
115 m_realm->read_group();
119 uint 32 _t Alternative_key = m_realm->table_for_object_type(
托管 <std::remove_pointer_t<U>>:: 模式.name).get_key();
120 uint32_t stored_table = obj.get_obj().get_table().get_key();
122 if (alternative_key != Stored_table) {
123 throw std::runtime_error(
"Different link type Stored in Mixed Type. Stored type: " + obj.get_object_schema().get_name());
128 template <
typename U>
129 void set_link(U &&v) {
130 static_assert (
sizeof (
managed<U> ),
"Must describe schema for T" );
131 static_assert (
managed<U>::object_type == ObjectType::TopLevel,
"Mixed properties can only store Top Level objects." );
132 auto class = m_realm->table_for_object_type(
托管<U>:: 模式 .name);
134 if constexpr (
managed<U>:: schema.HasPrimaryKeyProperty) {
135 auto pk = v.*(
托管<U>:: 模式 .primary_key().ptr);
138 o = Table.create_object();
141 std:: 应用([&o, &v,
this ](
auto && ...p) {
142 (
accessor <
typename std::decay_t<
decltype (p)>::Result>::set(
143 o, o.get_table().get_column_key(p.name), *this->m_realm, v.*(std::decay_t<
decltype (p)>::ptr)
149 template <
typename U>
150 std::enable_if_t< 托管<U>::is_object &&
托管<U>::object_type == ObjectType::TopLevel,
void >
151 set_link(
托管<U> & link) {
157 托管 (
const 托管 &) =
delete ;
158 托管 (
托管 &&) =
delete ;
159 托管 & 操作符=(
const 托管 &) =
delete ;
160 托管 & 操作符=(
托管 &&) =
delete ;
161 template <
typename ,
typename >
165 template <
typename T,
typename Types>
166 boolholds_alternative (
const 域:: 托管<Types> & v)
noException {
167 auto val = v.get_stored_type();
170 if constexpr (std::is_same_v<T, int64_t>)
174 if constexpr (std::is_same_v<T, bool>)
178 if constexpr (std::is_same_v<T, std::string>)
182 if constexpr (std::is_same_v<T, std::vector<uint8_t>>)
186 if constexpr (std::is_same_v<T, Types>)
190 if constexpr (std::is_same_v<T, std::chrono::time_point<std::chrono::system_clock>>)
194 if constexpr (std::is_same_v<T, float>)
198 if constexpr (std::is_same_v<T, double>)
202 if constexpr (std::is_same_v<T, realm::decimal 128 >)
206 if constexpr (std::is_same_v<T, realm::object_id>)
211 if constexpr (std::is_same_v<T, realm::uuid>)
215 if constexpr (std::is_same_v<T, std::monostate>)
219 if constexpr (std::is_pointer_v<T>) {
220 auto m = v.m_obj->template get<internal::bridge::mixed>(v.m_key);
221 uint 32 _t Alternative_key = v.m_realm->table_for_object_type(
managed <std::remove_pointer_t<T>>::schema.name).get_key();
223 returnternal_key ==stored_key;