19#ifndef CPPREALM_MANAGED_LIST_HPP
20#define CPPREALM_MANAGED_LIST_HPP
22#include <cprealm/macros.hpp>
23#include <cprealm/notifications.hpp>
24#include <cprealm/observation.hpp>
25#include <cprealm/types.hpp>
30 estrutura, estrutura managed<std::vector<T>, std::enable_if_t<internal::type_info::is_primitive<T>::value>> :
managed_base {
31 Usando gerenciado<std::vector<T>>::managed_base::operator=;
35 usando iterator_category = std::input_iterator_tag;
37 operador de
bool !=(
const iterador e outros)
const
39 return !(*
isto == outro);
42 operador de
bool ==( iterador
const e outro)
const
44 return (m_parent == other.m_parent) && (m_i == other.m_i);
47 Operador T*()
const noexceto
49 return (*m_parent)[m_i];
52 iterador e operador++()
58 const iterador e operador++(
int i)
64 modelo<
typename,
typename>
65 amigo estrutura, estrutura managed;
67 iterator(
size_t i,
managed<std::vector<T>>* pai)
68 : m_i(i), m_parent(parent)
76 retorna o iterador(0,
este);
81 return iterador(tamanho(),
isto);
83 [[nodiscard]] std::vector<T> detach()
const {
85 usando U =
typename internal::type_info::type_info<T>::internal_type;
87 contagem
size_t = list.size();
89 return std::vetor<T>();
91 auto ret = std::vector<T>();
93 for(
size_t i = 0; i < count; i++) {
94 se constexpr (internal::type_info::MixedPersistableConcept<T>::value) {
95 ret.push_back(deserialize<T>(Realm::internal::bridge::get<U>(list, i)));
96 }
else if constexpr (std::is_enum_v<T>) {
97 ret.push_back(deserialize<T>(Realm::internal::bridge::get<U>(list, i)));
99 ret.push_back(deserialize(Realm::internal::bridge::get<U>(lista, i)));
106 [[nodiscard]] resultes<T> as_results()
const {
111 auto list = std::make_shared<realm::internal::bridge::list>(*m_realm, *m_obj, m_key);
113 std::make_shared<realm::collection_callback_wrapper>(
116 token.m_realm = *m_realm;
122 Operador T[](
size_t idx)
const {
124 usando U =
typename internal::type_info::type_info<T>::internal_type;
125 se 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 Método estático_cast<T
>(deserialize<T>(Realm::internal::ponte::get<U>(lista, idx)));
130 return deserialize(Realm::internal::bridge::get<U>(list, idx));
135 internal::bridge::list(*m_realm, *m_obj, m_key).remove(size() - 1);
137 apagamento
nulo (
size_t idx) {
138 internal::bridge::list(*m_realm, *m_obj, m_key).remove(idx);
141 internal::bridge::list(*m_realm, *m_obj, m_key).remove_all();
143 push_back push( valor de T&
const ) {
144 auto list = internal::bridge::list(*m_realm, *m_obj, m_key);
145 list.add(serialize(value));
147 tamanho_t tamanho() {
148 return internal::bridge::list(*m_realm, *m_obj, m_key.size();
150 size_t find(
const T& a) {
151 se 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 set(
tamanho_t pos ,
const T& a) {
158 internal::bridge::list(*m_realm, *m_obj, m_key).set(pos, a);
161 results<T> sort(
bool ascendente) {
162 retornar resultados<T>(internal::bridge::list(*m_realm, *m_obj, m_key)
163 .sort(std::vector<internal::bridge::sort_descriptor>({{
"auto", crescente}}))));
168 managed(
const managed&) =
delete;
169 managed(managed &&) =
excluir;
170 managed& operator=(
const managed&) =
excluir;
171 managed& operator=(managed&&) =
excluir;
172 modelo<
typename,
typename>
173 amigo estrutura managed;
179 [[nodiscard]] std::vector<T*> detach()
const {
181 contagem
size_t = 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(Realm::internal::bridge::get<internal::bridge::obj>(list, i), *m_realm);
189 auto assign = [&m, &v](
auto& emparelh) {
190 (*v).*(std::decay_t<
decltype(pair.first)>::ptr) = (m.*(pair.second)).detach();
193 std::apply([&v, &m, &assign](
auto && ...pair) {
210 usando change_type = std::ptrdiff_t;
211 usando ponteiro = T*;
212 usando reference = T&;
213 usando iterator_category = std::forward_iterator_tag;
215 operador de
bool !=(
const iterador e outros)
const
217 return !(*
isto == outro);
220 operador de
bool ==( iterador
const e outro)
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 return {std::move(m)};
232 iterador e operador++()
238 const iterador e operador++(
int i)
244 modelo<
typename,
typename>
245 amigo estrutura, estrutura managed;
247 iterador(
size_t i,
managed<std::vector<T*>>* pai)
248 : m_i(i), m_parent(parent)
257 retorna o iterador(0,
este);
262 return iterador(tamanho(),
isto);
266 internal::bridge::list(*m_realm, *m_obj, m_key).remove(size() - 1);
268 apagamento
nulo (
size_t idx) {
269 internal::bridge::list(*m_realm, *m_obj, m_key).remove(idx);
272 internal::bridge::list(*m_realm, *m_obj, m_key).remove_all();
274 push_back
nulo (valor T*)
276 auto list = 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 se constexpr (managed<T>::schema.HasPrimaryKeyProperty) {
280 auto pk = (*value).*(managed<T>::schema.primary_key().ptr);
282 }
mais se (gerenciado<T>::schema.is_embedded()) {
283 m_obj = list.add_embedded();
285 m_obj = table.create_object();
287 std::apply([&m_obj, &value, Realm = *m_realm](
auto && ...p) {
288 (acessador <
typename std::decay_t <
decltype(p)>::Result>::set(
289 m_obj, m_obj.get_table().get_column_key(p.name), domínio,
290 (*value).*(std::decay_t<
decltype(p)>::ptr)), ...);
291 }, managed<T, null>::schema.ps);
292 se (!managed<T>::schema.is_embedded()) {
293 list.add(m_obj.get_key());
296 push_back null( valor
const managed<T>)
298 auto list = internal::bridge::list(*m_realm, *m_obj, m_key);
299 se (!managed<T>::schema.is_embedded()) {
300 list.add(value.m_obj.get_key());
302 lance std::logical_error(
"Não é possível adicionar objeto incorporado existente à lista gerenciada.");
305 push_back ( valor
const gerenciado<T*>&)
307 se (!managed<T>::schema.is_embedded()) {
308 auto list = internal::bridge::list(*m_realm, *m_obj, m_key);
309 list.add(value.m_obj->get_key());
311 lance std::logical_error(
"Não é possível adicionar objeto incorporado existente à lista gerenciada.");
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 typename managed<T*>::ref_type operator[](
size_t idx)
const {
327 Método typename managed<T*>::ref_type(managed<T>(Realm::internal::bridge::get<realm::internal::bridge::obj>(list, idx), *m_realm));
331 auto list = std::make_shared<realm::internal::bridge::list>(*m_realm, *m_obj, m_key);
333 std::make_shared<realm::collection_callback_wrapper>(
336 token.m_realm = *m_realm;
341 resultados<T> onde(
const std::string &query,
const std::vector<realm::mixed> &arguments) {
342 std::vector<internal::bridge::mixed> mixed_args;
343 para(
auto& a : argumentos)
344 mixed_args.push_back(serialize(a));
345 return <T>results(internal::bridge::results(*m_realm, m_obj->get_target_table(m_key).query(query, std::move(mixed_args))));
348 results<T> onde(std::function<rbool(managed<T> &)> &&fn) {
349 estático_assert(
sizeof(managed<T>),
"Deve declarar esquema para T");
350 auto schema = m_realm->schema().find(managed<T>::schema.name);
351 auto group = 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 retornar resultados<T>(internal::bridge::results(*m_realm, full_query));
359 results<T> sort(
const std::string &key_path,
bool ascending) {
360 auto schema = m_realm->schema().find(managed<T>::schema.name);
361 auto table_ref = m_obj->get_target_table(m_key);
362 return <T>results()(internal::bridge::results(*m_realm, table_ref)).sort({{key_path, ascendente}});
365 resultados<T> sort(
const std::vector<internal::bridge::sort_descriptor> &sort_descriptors) {
366 auto schema = m_realm->schema().find(managed<T>::schema.name);
367 auto table_ref = m_obj->get_target_table(m_key);
368 return <T>results(internal::bridge::results(*m_realm, table_ref)).sort(sort_descriptors);
373 managed(
const managed&) =
delete;
374 managed(managed &&) =
excluir;
375 managed& operator=(
const managed&) =
excluir;
376 managed& operator=(managed&&) =
excluir;
377 modelo<
typename,
typename>
378 amigo estrutura managed;
Definição: observação.hpp:176
Definição: macros.hpp:286
Definição: notificações.hpp:38
Definição: results.hpp:411