19#ifndef CPPRALM_MANAGED_LIST_HPP
20#define CPPREALM_MANAGED_LIST_HPP
22#include <cpprealm/macros.hpp>
23#include <cpprealm/notifications.hpp>
24#include <cpprealm/observation.hpp>
25#include <cpprealm/types.hpp>
30 구조체 managed<std::vector<T>, std::enable_if_t<internal::type_info::is_primitive<T>::value>> :
managed_base {
31 사용 managed<std::vector<T>>::managed_base:: 연산자=;
35 iterator_category = std::input_iterator_tag;
37 bool 연산자!=(
const iterator& other)
const
39 return !(*
this == other);
42 bool 연산자==(
const iterator& other)
const
44 return (m_parent == other.m_parent) && (m_i == other.m_i);
47 T 연산자*()
const noException
49 return (*m_parent)[m_i];
52 iterator& operator++()
58 const iterator& operator++(
int i)
64 템플릿<
typename,
typename>
67 iterator(
size_t i,
managed<std::vector<T>>* parent)
68 : m_i(i), m_parent(parent)
76 return iterator(0,
this);
81 return iterator(size(),
this);
83 [[nodiscard]] std::vector<T> fetch()
const {
85 using U =
typename internal::type_info::type_info<T>::internal_type;
87 size_t count = list.size();
89 return std::vector<T>();
91 auto ret = std::vector<T>();
93 for(
size_t i = 0; i < count; i++) {
94 만약 constexpr (internal::type_info::MixedPersistableConcept<T>::value) {
95 ret.push_back(deserialize<T>(영역::internal::bridge::get<U>(list, i))));
96 }
else if constexpr (std::is_enum_v<T>) {
97 ret.push_back(deserialize<T>(영역::internal::bridge::get<U>(list, i))));
99 ret.push_back(deserialize(영역::internal::bridge::get<U>(list, i)));
106 [[nodiscard]] results<T> as_results()
const {
111 auto list = std::make_shared(*m_realm,<realm::internal::bridge::list> *m_obj, m_key);
113 <realm::collection_callback_wrapper>std::make_shared(
116 token.m_realm = *m_realm;
122 T 연산자[](
size_t idx)
const {
124 using U =
typename internal::type_info::type_info<T>::internal_type;
125 만약 constexpr (internal::type_info::MixedPersistableConcept<T>::value) {
126 return deserialize<T>(realm::internal::bridge::get<U>(list, idx));
127 }
else if constexpr (std::is_enum_v<T>) {
128 반환 static_cast<T
>(deserialize<T>(영역::internal::bridge::get<U>(list, idx))));
130 return deserialize(영역::internal::bridge::get<U>(list, idx));
135 internal::bridge::list(*m_realm, *m_obj, m_key). (제거() - 1);
138 internal::bridge::list(*m_realm, *m_obj, m_key). (idx) 제거 합니다.
141 internal::bridge::list(*m_realm, *m_obj, m_key).remove_all();
143 무효 push_back(
const T& value) {
144 자동 목록 = internal::bridge::list(*m_realm, *m_obj, m_key);
145 list.add(serialize(value));
148 return internal::bridge::list(*m_realm, *m_obj, m_key).size();
150 size_t find(
const T& a) {
151 만약 constexpr (std::is_enum_v<T>) {
152 return internal::bridge::list(*m_realm, *m_obj, m_key).find(
static_cast<int64_t
>(a));
154 return internal::bridge::list(*m_realm, *m_obj, m_key).find(a);
157 oid set(
size_t pos,
const T& a) {
158 internal::bridge::list(*m_realm, *m_obj, m_key). 설정하다(위치, a);
161 결과<T> sort(
bool 오름차순) {
162 return results<T>(internal::bridge::list(*m_realm, *m_obj, m_key)
163 .sort(std::vector<internal::bridge::sort_descriptor>({{
"self", 오름차순}}))));
168 managed(
const managed&) =
delete;
169 managed(managed &&) =
삭제;
170 managed& 연산자=(
const managed&) =
삭제;
171 managed& operator=(managed&&) =
delete;
172 템플릿<
typename,
typename>
179 [[nodiscard]] std::vector<T*> take()
const {
181 size_t count = list.size();
183 return std::vector<T*>();
184 auto ret = std::vector<T*>();
186 for(
size_t i = 0; i < count; i++) {
187 managed<T> m(영역::internal::bridge::get<internal::bridge::obj>(list, i), *m_realm);
189 자동 할당 = [&m, &v](
자동& 쌍) {
190 (*v).*(std::decay_t<
decltype(pair.first)>::ptr) = (m.*(pair.second)).ttach();
193 std:: 적용([&v, &m, &assign](
auto && ...pair) {
210 차등 유형
사용 = std::ptrdiff_t;
213 iterator_category = std::
forward_iterator_tag ;
215 bool 연산자!=(
const iterator& other)
const
217 return !(*
this == other);
220 bool 연산자==(
const iterator& other)
const
222 return (m_parent == other.m_parent) && (m_i == other.m_i);
228 managed<T> m(realm::internal::bridge::get<realm::internal::bridge::obj>(list, m_i), *m_parent->m_realm);
229 {std::move(m)}를
반환 합니다.
232 iterator& operator++()
238 const iterator& operator++(
int i)
244 템플릿<
typename,
typename>
247 iterator(
size_t i,
managed<std::vector<T*>>* parent)
248 : m_i(i), m_parent(parent)
257 return iterator(0,
this);
262 return iterator(size(),
this);
266 internal::bridge::list(*m_realm, *m_obj, m_key). (제거() - 1);
269 internal::bridge::list(*m_realm, *m_obj, m_key). (idx) 제거 합니다.
272 internal::bridge::list(*m_realm, *m_obj, m_key).remove_all();
276 자동 목록 = internal::bridge::list(*m_realm, *m_obj, m_key);
277 auto table = m_obj->get_target_table(m_key);
278 internal::bridge::obj m_obj;
279 만약 constexpr (managed<T>:: 스키마.HasPrimaryKeyProperty) {
280 auto pk = (*value).*(managed<T>::schema.primary_key().ptr);
282 }
other if (managed::<T> 스키마.is_embedded ()) {
283 m_obj = list.add_embedded();
285 m_obj = table.create_object();
287 std:: 적용([&m_obj, &value, 영역 = *m_realm](
auto && ...p) {
288 (접근자<
typename std::decay_t<
decltype(p)>::Result>:: 설정하다(
289 m_obj, m_obj.get_table().get_column_key(p.name), Realm,
290 (*value).*(std::decay_t<
decltype(p)>::ptr)), ...);
291 }, managed<T, 무효>:: 스키마.ps);
292 if (!managed<T>::schema.is_embedded()) {
293 list.add(m_obj.get_key());
296 oid push_back(
const managed<T>& value)
298 자동 목록 = internal::bridge::list(*m_realm, *m_obj, m_key);
299 if (!managed<T>::schema.is_embedded()) {
300 list.add(value.m_obj.get_key());
302 throw std::logic_error(
"기존 내장된 객체 를 managed 목록에 추가할 수 없습니다.");
305 oid push_back(
const managed<T*>& value)
307 if (!managed<T>::schema.is_embedded()) {
308 자동 목록 = internal::bridge::list(*m_realm, *m_obj, m_key);
309 list.add(value.m_obj->get_key());
311 throw std::logic_error(
"기존 내장된 객체 를 managed 목록에 추가할 수 없습니다.");
317 return internal::bridge::list(*m_realm, *m_obj, m_key).size();
319 size_t find(
const managed<T>& a) {
320 return internal::bridge::list(*m_realm, *m_obj, m_key).find(a.m_obj.get_key());
322 size_t find(
const typename managed<T*>::ref_type& a)
const {
323 return internal::bridge::list(*m_realm, *m_obj, m_key).find(a->m_obj.get_key());
325 유형 이름 managed<T*>::
ref_type 연산자[](
size_t idx)
const {
327 반환 유형
이름 <T><realm::internal::bridge::obj> managed<T*>:: ref_type (managed(영역::internal::bridge::get(list, idx), *m_realm));
331 auto list = std::make_shared(*m_realm,<realm::internal::bridge::list> *m_obj, m_key);
333 <realm::collection_callback_wrapper>std::make_shared(
336 token.m_realm = *m_realm;
341 results<T> where(
const std::string &query,
const std::vector<realm::mixed> &arguments) {
342 std::vector<internal::bridge::mixed> mixed_args;
344 mixed_args.push_back(serialize(a));
345 return results<T>(internal::bridge::results(*m_realm, m_obj->get_target_table( 쿼리 , std::move(mixed_args)))));
348 결과<T> where(std::function<rbool(managed<T> &)> &&fn) {
349 static_assert(
sizeof(managed<T>),
"Must explain schema for T");
350 auto 스키마 = m_realm-> 스키마().find(managed<T>:: 스키마.name);
351 자동 그룹 = m_realm->read_group();
352 auto table_ref = group.get_table(schema.table_key());
353 rbool query = rbool(internal::bridge::query(table_ref));
354 auto query_object = managed<T>::prepare_for_query(*m_realm, &query);
355 auto full_query = fn(query_object).q;
356 return results<T>(internal::bridge::results(*m_realm, full_query));
359 결과<T> sort(
const std::string &key_path,
bool 오름차순) {
360 auto 스키마 = m_realm-> 스키마().find(managed<T>:: 스키마.name);
361 auto table_ref = m_obj->get_target_table(m_key);
362 return results<T>(internal::bridge::results(*m_realm, Table_ref)).sort({{key_path, 오름차순}});
365 결과<T> sort(
const std::vector<internal::bridge::sort_descriptor> &sort_descriptors) {
366 auto 스키마 = m_realm-> 스키마().find(managed<T>:: 스키마.name);
367 auto table_ref = m_obj->get_target_table(m_key);
368 return results<T>(internal::bridge::results(*m_realm, table_ref)).sort(sort_descriptors);
373 managed(
const managed&) =
delete;
374 managed(managed &&) =
삭제;
375 managed& 연산자=(
const managed&) =
삭제;
376 managed& operator=(managed&&) =
delete;
377 템플릿<
typename,
typename>