19#ifndef CPPRALM_RESULTS_HPP
20#define CPPREALM_RESULTS_HPP
22#include <cpprealm/internal/bridge/mixed.hpp>
23#include <cpprealm/internal/bridge/ 쿼리.hpp>
24#include <cpprealm/internal/bridge/results.hpp>
25#include <cpprealm/internal/bridge/table.hpp>
26#include <cpprealm/macros.hpp>
27#include <cpprealm/notifications.hpp>
28#include <cpprealm/schema.hpp>
29#include <cpprealm/rbool.hpp>
32 struct mutable_sync_subscription_set;
37 sort_descriptor
사용 = internal::bridge::sort_descriptor;
41 템플릿<
typename T,
typename 파생,
typename ShouldEnable= oid >
43 템플릿<
typename T,
typename 파생>
46 템플릿<
typename T,
typename 파생>
53 std::vector<uint64_t> 삭제;
54 std::vector<uint64_t> 삽입;
55 std::vector<uint64_t> 수정;
60 bool collection_root_was_deleted =
false;
62 [[nodiscard]]
bool empty()
const noException {
63 반환 deletes.empty() && inserts.empty() && Modifys.empty() &&
64 !collection_root_was_deleted;
69 return m_parent.size();
73 파생 where(
const std::string &query,
const std::vector<realm::mixed>& arguments) {
74 std::vector<internal::bridge::mixed> mixed_args;
76 mixed_args.push_back(serialize(a));
78 m_parent.get_table(). 쿼리(쿼리, std::move(mixed_args)))));
81 파생 where(std::function<rbool(managed<T>&)>&& fn) {
82 static_assert(
sizeof(managed<T>),
"Must explain schema for T");
83 auto realm = m_parent.get_realm();
84 auto schema = realm.schema().find(managed<T>::schema.name);
85 자동 그룹 = 영역.read_group();
86 auto table_ref = group.get_table(schema.table_key());
87 rbool query = rbool(internal::bridge::query(table_ref));
88 auto query_object = managed<T>::prepare_for_query(realm, &query);
89 auto full_query = fn(query_object).q;
90 return Derived(internal::bridge::results(m_parent.get_realm(), full_query));
96 bool ignore_initial_notification =
true)
97 : m_handler(std::move(fn)),
99 m_ignore_changes_in_initial_notification(ignore_initial_notification) {}
104 if (m_ignore_changes_in_initial_notification) {
105 m_ignore_changes_in_initial_notification =
false;
106 m_handler({collection, {}, {}, {}});
107 }
if (
changes.empty ()) {
108 m_handler({collection, {}, {}, {}});
109 }
다른 경우 if (!changes.collection_root_was_deleted() || !changes.deletions().empty()) {
112 to_vector(changes.deletions()),
113 to_vector(changes.insertions()),
114 to_vector(changes.modifications()),
123 bool m_ignore_changes_in_initial_notification;
125 자동 벡터 = std::vector<uint64_t>();
126 for (
auto index: index_set.as_indexes()) {
127 vector.push_back(index);
134 auto r = std::make_shared<internal::bridge::results>(m_parent.get_realm(), m_parent.get_realm().table_for_object_type(
managed<T>:: 스키마.name));
135 영역::notification_token token = r->add_notification_callback(std::make_shared<results_callback_wrapper>(std::move(handler),
static_cast<파생*
>(
this)));
136 token.m_realm = r->get_realm();
142 자동 동결 영역 = m_parent.get_realm().freeze();
147 auto thawed_realm = m_parent.get_realm().thaw();
148 return Derived(internal::bridge::results(thawed_realm, thawed_realm.table_for_object_type(managed<T>:: 스키마.name)));
152 return m_parent.get_realm().is_frozen();
155 파생 정렬(
const std::string& key_path,
bool 오름차순) {
156 return 파생(m_parent.sort({{key_path, 오름차순}}));
159 파생 정렬(
const std::vector<sort_descriptor>& sort_descriptors) {
160 return 파생(m_parent.sort(sort_descriptors));
164 internal::bridge::results m_parent;
165 템플릿 <auto>
친구 구조체 linking_objects;
169 using results_is_primitive = std::enable_if_t<!managed<T>::is_object && !std::is_enum_v<T> && !internal::type_info::is_variant_t<T>::value>;
171 using results_is_enum = std::enable_if_t<!managed<T>::is_object && std::is_enum_v<T> && !internal::type_info::is_variant_t<T>::value>;
173 results_is_mixed = std::
enable_if_t <! managed<T>::is_object && !std::is_enum_v<T> && internal::type_info::is_variant_t<T>::value>;
175 템플릿<
typename T,
typename 파생>
181 T 연산자[](
size_t 인덱스) {
182 if (index >= this->m_parent.size())
183 throw std::out_of_range(
"인덱스가 범위 를 벗어났습니다.");
184 return internal::bridge::get<T>(This->m_parent, index);
191 iterator_category = std::input_iterator_tag;
193 bool 연산자!=(
const iterator & other)
const {
194 return !(*
this == other);
197 bool 연산자==(
const iterator & other)
const {
198 return (m_parent == other.m_parent) && (m_idx == other.m_idx);
201 value_type 연산자*()
noException {
202 return m_parent->operator[](m_idx);
205 iterator &operator++() {
215 명시적 반복기(
size_t idx, 파생 *parent)
216 : m_idx(idx), m_parent(parent) {
224 return iterator(0,
static_cast<파생*
>(
this));
228 return iterator( this->m_parent.size(),
static_cast<파생*
>(
this));
232 템플릿<
typename T,
typename 파생>
238 T 연산자[](
size_t 인덱스) {
239 if (index >= this->m_parent.size())
240 throw std::out_of_range(
"인덱스가 범위 를 벗어났습니다.");
241 return deserialize<T>(internal::bridge::get<internal::bridge::mixed>(This->m_parent, index));
254 iterator_category = std::input_iterator_tag;
256 bool 연산자!=(
const iterator & other)
const {
257 return !(*
this == other);
260 bool 연산자==(
const iterator & other)
const {
261 return (m_parent == other.m_parent) && (m_idx == other.m_idx);
264 value_type 연산자*()
noException {
265 return m_parent->operator[](m_idx);
268 iterator &operator++() {
278 명시적 반복기(
size_t idx, 파생 *parent)
279 : m_idx(idx), m_parent(parent) {
287 return iterator(0,
static_cast<파생*
>(
this));
291 return iterator( this->m_parent.size(),
static_cast<파생*
>(
this));
295 템플릿<
typename T,
typename 파생>
301 T 연산자[](
size_t 인덱스) {
302 if (index >= this->m_parent.size())
303 throw std::out_of_range(
"인덱스가 범위 를 벗어났습니다.");
304 반환 static_cast<T
>(internal::bridge::get<int64_t>(This->m_parent, index));
311 iterator_category = std::input_iterator_tag;
313 bool 연산자!=(
const iterator & other)
const {
314 return !(*
this == other);
317 bool 연산자==(
const iterator & other)
const {
318 return (m_parent == other.m_parent) && (m_idx == other.m_idx);
321 value_type 연산자*()
noException {
322 return m_parent->operator[](m_idx);
325 iterator &operator++() {
335 명시적 반복기(
size_t idx, 파생 *parent)
336 : m_idx(idx), m_parent(parent) {
344 return iterator(0,
static_cast<파생*
>(
this));
348 return iterator( this->m_parent.size(),
static_cast<파생*
>(
this));
352 템플릿<
typename T,
typename 파생>
359 if (index >= this->m_parent.size())
360 throw std::out_of_range(
"인덱스가 범위 를 벗어났습니다.");
361 반환 managed<T, oid>(internal::bridge::get<internal::bridge::obj>(This->m_parent, index), this->m_parent.get_realm());
368 iterator_category = std::input_iterator_tag;
370 bool 연산자!=(
const iterator & other)
const {
371 return !(*
this == other);
374 bool 연산자==(
const iterator & other)
const {
375 return (m_parent == other.m_parent) && (m_idx == other.m_idx);
380 반환 managed<T, oid>(std::move(obj), this->m_parent->m_parent.get_realm());
383 iterator &operator++() {
393 명시적 반복기(
size_t idx, 파생 *parent)
394 : m_idx(idx), m_parent(parent) {
402 return iterator(0,
static_cast<파생*
>(
this));
406 return iterator( this->m_parent.size(),
static_cast<파생*
>(
this));
420 static 인라인 자동 Ptr = Ptr;
435 return iterator(0, get_results());
439 auto r = get_results();
440 return iterator(r.size(), r);
444 return get_results().size();
447 return get_results()[idx];
452 auto table = m_obj->get_table();
453 if (!table.is_valid(m_obj->get_key())) {
454 throw std::logic_error(
"객체가 삭제되었거나 무효화되었습니다.");
459 auto linking_property = schema.property_for_name(
managed<Class>::schema.
template name_for_property<ptr>());
460 if (!linking_property.column_key()) {
461 throw std::logic_error(
"원점 속성에 대한 열 키가 잘못되었습니다.");
464 internal::bridge::results 결과(*m_realm, obj->get_backlink_view(m_realm->get_table(schema.table_key())), linking_property.column_key()));
465 return ::realm::results<Class>(std::move(
results));