19#ifndef CPPREALM_RBOOL_HPP
20#define CPPREALM_RBOOL_HPP
22#include <cpprealm/internal/bridge/ 쿼리.hpp>
23#include <cpprealm/internal/bridge/realm.hpp>
24#include <cpprealm/internal/bridge/table.hpp>
25#include <cpprealm/internal/bridge/utils.hpp>
26#include <cpprealm/types.hpp>
45 m_link_chain->link(col_key);
47 m_link_chain = m_table.get_link(col_key);
52#define 정의_쿼리(유형, 비교) \
53 rbool& comparison(const internal::bridge::col_key& col_key, const std::optional<type>& rhs) { \
54 if (auto lc = m_link_chain) { \
55 q = lc->column<type>(col_key).comparison(rhs); \
56 m_link_chain = std::nullopt; \
57 } 다른 경우 (m_dictionary_ctx) { \
58 q = q.dictionary_link_subexpr(m_dictionary_ctx->origin_col_key, col_key, m_dictionary_ctx->m_key).comparison(rhs); \
59 m_dictionary_ctx = std::nullopt; \
62 q = internal::bridge::query(q.get_table()).comparison(col_key, *rhs); \
64 q = internal::bridge::query(q.get_table()).comparison(col_key, std::nullopt); \
69 rbool& comparison(const internal::bridge::col_key& col_key, const type& rhs) { \
70 if (auto lc = m_link_chain) { \
71 q = lc->column<type>(col_key).comparison(std::optional<type>(rhs)); \
72 m_link_chain = std::nullopt; \
73 } 다른 경우 (m_dictionary_ctx) { \
74 q = q.dictionary_link_subexpr(m_dictionary_ctx->origin_col_key, col_key, m_dictionary_ctx->m_key).comparison(std::optional<type>(rhs)); \
75 m_dictionary_ctx = std::nullopt; \
77 q = internal::bridge:: 쿼리(q.get_table()).comparison(col_key, rhs); \
82#define describe_numeric_query(type, 비교) \
83 rbool& comparison(const internal::bridge::col_key& col_key, const type& rhs) { \
84 if (auto lc = m_link_chain) { \
85 q = lc->column<type>(col_key).comparison(:: 영역::serialize(std::optional<type>(rhs))); \
86 m_link_chain = std::nullopt; \
87 } 다른 경우 (m_dictionary_ctx) { \
88 q = q.dictionary_link_subexpr(m_dictionary_ctx->origin_col_key, col_key, m_dictionary_ctx->m_key).comparison(std::optional<type>(rhs)); \
89 m_dictionary_ctx = std::nullopt; \
91 q = internal::bridge:: 쿼리(q.get_table()).comparison(col_key, rhs); \
96 describe_query(std::string, equal)
97 describe_query(std::string, not_equal)
99 rbool& contains(
const internal::bridge::col_key& col_key,
const std::string& rhs,
bool case_센시티브 =
true) {
100 if (
auto lc = m_link_chain) {
101 q = lc->column<std::string>(col_key).contains(:: 영역::serialize(std::optional<std::string>(rhs)), 대소문자 구분);
102 m_link_chain = std::nullopt;
104 q = internal::bridge:: 쿼리(q.get_table()).contains(col_key, rhs, 대소문자 구분);
109 describe_query(int64_t, equal)
110 describe_query(int64_t, not_equal)
111 describe_numeric_query(int64_t, 보다 큼)
112 describe_numeric_query(int64_t, Less)
113 describe_numeric_query(int64_t,grer_equal)
114 describe_numeric_query(int64_t,less_equal)
116 define_query(
bool, equal)
117 describe_query(
bool, not_equal)
119 describe_query(
double, equal)
120 describe_query(
double, not_equal)
121 describe_numeric_query(
double, large)
122 describe_numeric_query(
double, Less)
123 describe_numeric_query(
double, large_equal)
124 describe_numeric_query(
double,less_equal)
126 describe_query(std::vector<uint8_t>, equal)
127 describe_query(std::vector<uint8_t>, not_equal)
129 describe_query(std::chrono::time_point<std::chrono::system_clock>, equal)
130 describe_query(std::chrono::time_point<std::chrono::system_clock>, not_equal)
131 define_numeric_query(std::chrono::time_point<std::chrono::system_clock>, 그보다 큼)
132 describe_numeric_query(std::chrono::time_point<std::chrono::system_clock>, Less)
133 define_numeric_query(std::chrono::time_point<std::chrono::system_clock>,grer_equal)
134 describe_numeric_query(std::chrono::time_point<std::chrono::system_clock>, Less_equal)
136 describe_query(uuid, equal)
137 정의_쿼리(uuid, not_equal)
139 define_query(object_id, equal)
140 describe_query(object_id, not_equal)
142 describe_query(decimal128, equal)
143 describe_query(decimal128, not_equal)
144 describe_numeric_query(decimal128, 보다 큼)
145 describe_numeric_query(decimal128, 덜)
146 describe_numeric_query(decimal128,grer_equal)
147 describe_numeric_query(decimal128,less_equal)
149 rbool& mixed_equal(
const internal::bridge::col_key& col_key,
const internal::bridge::mixed& rhs) {
150 if (
auto lc = m_link_chain) {
151 q = lc->column<std::string>(col_key).mixed_equal(rhs);
152 m_link_chain = std::nullopt;
154 q.equal(col_key, rhs);
159 rbool& mixed_not_equal(
const internal::bridge::col_key& col_key,
const internal::bridge::mixed& rhs) {
160 if (
auto lc = m_link_chain) {
161 q = lc->column_mixed(col_key).mixed_not_equal(rhs);
162 m_link_chain = std::nullopt;
164 q.not_equal(col_key, rhs);
169 rbool& link_equal(
const internal::bridge::col_key& col_key,
const std::optional<internal::bridge::obj>& rhs) {
170 if (
auto lc = m_link_chain) {
171 q = lc->column<internal::bridge::obj>(col_key).equal(rhs);
172 m_link_chain = std::nullopt;
175 q.links_to(col_key, *rhs);
177 q.links_to(col_key, internal::bridge::obj());
183 rbool& link_not_equal(
const internal::bridge::col_key& col_key,
const std::optional<internal::bridge::obj>& rhs) {
184 if (
auto lc = m_link_chain) {
185 q = lc->column<internal::bridge::obj>(col_key).not_equal(rhs);
186 m_link_chain = std::nullopt;
189 q.not_links_to(col_key, *rhs);
191 q.not_links_to(col_key, internal::bridge::obj());
199 rbool& dictionary_has_value_for_key_equals(internal::bridge::col_key column_key,
const std::string& key,
const internal::bridge::mixed& value) {
200 q = internal::bridge:: 쿼리(q.get_table()).dictionary_has_value_for_key_equals(column_key, 키, 값);
204 rbool& dictionary_has_value_for_key_not_equals(internal::bridge::col_key column_key,
const std::string& key,
const internal::bridge::mixed& value) {
205 q = internal::bridge:: 쿼리(q.get_table()).dictionary_has_value_for_key_not_equals(column_key, 키, 값);
209 rbool& dictionary_has_value_for_key_greater_than(internal::bridge::col_key column_key,
const std::string& key,
const internal::bridge::mixed& value) {
210 q = internal::bridge:: 쿼리(q.get_table()).dictionary_has_value_for_key_greater_than(column_key, 키, 값);
214 rbool& dictionary_has_value_for_key_less_than(internal::bridge::col_key column_key,
const std::string& key,
const internal::bridge::mixed& value) {
215 q = internal::bridge:: 쿼리(q.get_table()).dictionary_has_value_for_key_less_than(column_key, 키, 값);
219 rbool& dictionary_has_value_for_key_greater_than_equals(internal::bridge::col_key column_key,
const std::string& key,
const internal::bridge::mixed& value) {
220 q = internal::bridge:: 쿼리(q.get_table()).dictionary_has_value_for_key_greater_than_equals(column_key, 키, 값);
224 rbool& dictionary_has_value_for_key_less_than_equals(internal::bridge::col_key column_key,
const std::string& key,
const internal::bridge::mixed& value) {
225 q = internal::bridge:: 쿼리(q.get_table()).dictionary_has_value_for_key_less_than_equals(column_key, 키, 값);
229 rbool& dictionary_contains_string_for_key(internal::bridge::col_key column_key,
const std::string& key,
const std::string& value) {
230 q = internal::bridge:: 쿼리(q.get_table()).dictionary_contains_string_for_key(column_key, 키, 값);
234 rbool& add_dictionary_link_chain(dictionary_context&& ctx) {
235 m_dictionary_ctx = ctx;
239 rbool& dictionary_has_key(internal::bridge::col_key column_key,
const std::string& key) {
240 q = internal::bridge:: 쿼리(q.get_table()).dictionary_contains_key(column_key, 키);
252 if (is_for_queries) {
260 mutable internal::bridge:: 쿼리 q;
263 rbool(internal::bridge:: 쿼리 &&q) : q(q), is_for_queries(true) {
264 m_table = q.get_table();
266 rbool(
bool b) : b(b) {}
267 rbool(
const rbool &r) {
268 if (r.is_for_queries) {
269 new (&q) internal::bridge:: 쿼리(rq);
270 is_for_queries =
true;
276 bool is_for_queries =
false;
277 bool is_dictionary_link =
false;
278 std::optional<internal::bridge::link_chain> m_link_chain;
279 internal::bridge::table m_table;
280 std::optional<dictionary_context> m_dictionary_ctx;
284 친구 rbool 연산자&&(
const rbool &lhs,
const rbool &rhs);
285 친구 rbool 연산자||(
const rbool &lhs,
const rbool &rhs);
288 인라인 rbool 연산자 &&(
const rbool& lhs,
const rbool& rhs) {
289 if (lhs.is_for_queries) {
290 lhs.q.and_query(rhs.q);
293 return lhs.b && rhs.b;
295 인라인 rbool 연산자 ||(
const rbool& lhs,
const rbool& rhs) {
296 if (lhs.is_for_queries) {
297 lhs.q = lhs.q || rhs.q;
300 return lhs.b && rhs.b;
305 인라인 rbool truepredicate(
const T& o) {
308 rbool* rb = internal::get_rbool(o);
310 throw std::runtime_error(
"관리되는 객체 가 쿼리 컨텍스트에서 사용되지 않았습니다");
311 auto table = rb->q.get_table();
317 인라인 rbool falsepredicate(
const T& o) {
318 rbool* rb = internal::get_rbool(o);
320 throw std::runtime_error(
"관리되는 객체 가 쿼리 컨텍스트에서 사용되지 않았습니다");
321 auto table = rb->q.get_table();
322 auto q = internal::bridge:: 쿼리(table).and_query(internal::bridge:: 쿼리(table).falsepredicate());
323 return rbool(std::move(q));