19#ifndef CPPREALM_MANAGED_NUMERIC_HPP
20#define CPPREALM_MANAGED_NUMERIC_HPP
22#include <cprealm/macros.hpp>
23#include <cprealm/rbool.hpp>
28 Usando gerenciado<int64_t>::managed_base::operator=;
31 this->m_obj->template set<int64_t>(m_key, v);
35 [[nodiscard]] int64_t detach()
const {
36 retornar m_obj->template get<int64_t>(m_key);
39 [[nodiscard]] int64operador _t *()
const {
43 [[nodiscard]]
operador int64_t()
const {
48 std::enable_if_t<std::is_integral_v<T>,
rbool> operator==(
const T& rhs)
const noexceto {
50 return this->m_rbool_query->equal(m_key, (int64_t)rhs);
52 return serialize(detach()) == rhs;
56 std::enable_if_t<std::is_integral_v<T>,
rbool> operator!=(
const T& rhs)
const noexceto {
58 return this->m_rbool_query->not_equal(m_key, (int64_t)rhs);
60 return serialize(detach()) != rhs;
64 std::enable_if_t<std::is_integral_v<T>,
rbool> operator>(
const T& rhs)
const noexceto {
66 return this->m_rbool_query->greter(m_key, (int64_t)rhs);
68 return serialize(detach()) > rhs;
72 std::enable_if_t<std::is_integral_v<T>,
rbool> operator<(
const T& rhs)
const noexceto {
74 return this->m_rbool_query->less(m_key, (int64_t)rhs);
76 return serialize(detach()) < rhs;
80 std::enable_if_t<std::is_integral_v<T>,
rbool> operator>=(
const T& rhs)
const noexceto {
82 return this->m_rbool_query->greter_equal(m_key, (int64_t)rhs);
84 return serialize(detach()) >= rhs;
88 std::enable_if_t<std::is_integral_v<T>,
rbool> operator<=(
const T& rhs)
const noexceto {
90 return this->m_rbool_query->less_equal(m_key, (int64_t)rhs);
92 return serialize(detach()) <= rhs;
95 managed& operator+=(
const int64_t& o) {
96 auto old_val = m_obj->template get<int64_t>(m_key);
97 m_obj->template set<int64_t>(This->m_key, old_val + o);
100 operador
nulo ++(
int) {
101 auto old_val = m_obj->template get<int64_t>(m_key);
102 m_obj->template set<int64_t>(This->m_key, old_val + 1);
105 auto old_val = m_obj->template get<int64_t>(m_key);
106 m_obj->template set<int64_t>(This->m_key, old_val + 1);
108 managed& operator-=(
const int64_t& o) {
109 auto old_val = m_obj->template get<int64_t>(m_key);
110 m_obj->template set<int64_t>(This->m_key, old_val - o);
113 operador de
cancelamento -- (
int) {
114 auto old_val = m_obj->template get<int64_t>(m_key);
115 m_obj->template set<int64_t>(This->m_key, old_val - 1);
117 operador
vazio --() {
118 auto old_val = m_obj->template get<int64_t>(m_key);
119 m_obj->template set<int64_t>(This->m_key, old_val - 1);
121 managed& operator*=(
const int64_t& o) {
122 auto old_val = m_obj->template get<int64_t>(m_key);
123 m_obj->template set<int64_t>(This->m_key, old_val * o);
133 modelo<
typename,
typename>
134 amigo estrutura, estrutura managed;
139 Usando gerenciado<
double>::managed_base::operator=;
142 this->m_obj->template set<double>(m_key, v);
147 este->m_obj->template set<double>(m_key, (
double)v);
151 [[nodiscard]]
double detach()
const {
152 return m_obj->template get<double>(m_key);
155 operador
double *()
const {
156 return desvincular();
158 [[nodiscard]]
operator double()
const {
159 return desvincular();
163 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool> operator==(
const T& rhs)
const noexceto {
165 return this->m_rbool_query->equal(m_key, (
double)rhs);
167 return serialize(detach()) == rhs;
171 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool> operator!=(
const T& rhs)
const noexceto {
173 return this->m_rbool_query->not_equal(m_key, (
double)rhs);
175 return serialize(detach()) != rhs;
179 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool> operator>(
const T& rhs)
const noexceto {
181 return this->m_rbool_query->greter(m_key, (
double)rhs);
183 return serialize(detach()) > rhs;
187 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool> operator<(
const T& rhs)
const noexceto {
189 return this->m_rbool_query->less(m_key, (
double)rhs);
191 return serialize(detach()) < rhs;
195 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool> operator>=(
const T& rhs)
const noexceto {
197 return this->m_rbool_query->greter_equal(m_key, (
double)rhs);
199 return serialize(detach()) >= rhs;
203 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool> operator=(
const T& rhs)
const noexceto {
205 return this->m_rbool_query->less_equal(m_key, (
double)rhs);
207 return serialize(detach()) <= rhs;
210 operador
nulo +=(
const double& o) {
211 auto old_val = m_obj->template get<double>(m_key);
212 m_obj->template set<double>(This->m_key, old_val + o);
214 operador
nulo ++(
int) {
215 auto old_val = m_obj->template get<double>(m_key);
216 m_obj->template set<double>(This->m_key, old_val + 1.0);
219 auto old_val = m_obj->template get<double>(m_key);
220 m_obj->template set<double>(This->m_key, old_val + 1.0);
222 operador
nulo -=(
const double& o) {
223 auto old_val = m_obj->template get<double>(m_key);
224 m_obj->template set<double>(This->m_key, old_val - o);
226 operador de
cancelamento -- (
int) {
227 auto old_val = m_obj->template get<double>(m_key);
228 m_obj->template set<double>(This->m_key, old_val - 1.0);
230 operador
vazio --() {
231 auto old_val = m_obj->template get<double>(m_key);
232 m_obj->template set<double>(This->m_key, old_val - 1.0);
234 operador
nulo *=(
const double& o) {
235 auto old_val = m_obj->template get<double>(m_key);
236 m_obj->template set<double>(This->m_key, old_val * o);
245 modelo<
typename,
typename>
246 amigo estrutura, estrutura managed;
251 Usando managed<
bool>::managed_base::operator=;
253 [[nodiscard]]
bool detach()
const {
254 return m_obj->template get<bool>(m_key);
256 [[nodiscard]]
operator bool()
const {
257 return desvincular();
259 operador de
bool *()
const {
260 return desvincular();
263 rbool operator==(
const bool& rhs)
const noexceto;
264 operador de
rbool !=(
const bool& rhs)
const noexceto;
272 modelo<
typename,
typename>
273 amigo estrutura, estrutura managed;
276#define CPP_REALM_MANAGED_OPTIONAL_NUMERIC(tipo) \
278 estrutura managed <std::opcional<type>> : managed_base { \
279 usando managed <std::opcional<type>>::managed_base::operator=; \
281 managed<std::optional<type>>& operator =(const double& v) { \
282 this->m_obj->template set<type>(m_key, v); \
286 managed<std::optional<type>>& operator =(const int& v) { \
287 this->m_obj->template set<type>(m_key, (double)v); \
291 [[nodiscard]] std::optional<type> detach() const { \
292 return m_obj->get_optional<type>(m_key); \
295 [[nodiscard]] std::optional<type> operator *() const { \
298 [[nodiscard]] operador std::optional<type>() const { \
301 rbool operator==(const std::optional<type>& rhs) const noexceto; \
302 operador de rbool!=(const std::optional<type>& rhs) const noexceto; \
303 operador nulo+=(tipo const& o) { \
304 auto old_val = m_obj->get_optional<type>(m_key); \
306 lance std::runtime_error("Não é possível executar aritmética em valor nulo."); \
308 m_obj->template set<type>(This->m_key, (*old_val) + o); \
310 operador nulo++(int) { \
311 auto old_val = m_obj->get_optional<type>(m_key); \
313 lance std::runtime_error("Não é possível executar aritmética em valor nulo."); \
315 m_obj->template set<type>(This->m_key, (*old_val) + 1); \
317 operador nulo-=(tipo const& o) { \
318 auto old_val = m_obj->get_optional<type>(m_key); \
320 lance std::runtime_error("Não é possível executar aritmética em valor nulo."); \
322 m_obj->template set<type>(This->m_key, (*old_val) - o); \
324 operador de vazio--(int) { \
325 auto old_val = m_obj->get_optional<type>(m_key); \
327 lance std::runtime_error("Não é possível executar aritmética em valor nulo."); \
329 m_obj->template set<type>(This->m_key, (*old_val) - 1); \
331 operador de cancelamento*=(tipo de const& o) { \
332 auto old_val = m_obj->get_optional<type>(m_key); \
334 lance std::runtime_error("Não é possível executar aritmética em valor nulo."); \
336 m_obj->template set<type>(This->m_key, (*old_val) * o); \
338 operador nulo*(tipo const& o) { \
339 auto old_val = m_obj->get_optional<type>(m_key); \
341 lance std::runtime_error("Não é possível executar aritmética em valor nulo."); \
343 m_obj->template set<type>(This->m_key, (*old_val) * o); \
345 operador de cancelamento/(tipo de const& o) { \
346 auto old_val = m_obj->get_optional<type>(m_key); \
348 lance std::runtime_error("Não é possível executar aritmética em valor nulo."); \
350 m_obj->template set<type>(This->m_key, (*old_val) / o); \
353 managed() = padrão; \
354 managed(const managed&) = excluir; \
355 managed(managed &&) = excluir; \
356 managed& operator=(const managed&) = excluir; \
357 managed& operator=(managed&&) = excluir; \
358 template<typename, typename> \
359 estrutura de amigos gerenciada; \
362CPP_REALM_MANAGED_OPTIONAL_NUMERIC(int64_t)
363CPP_REALM_MANAGED_OPTIONAL_NUMERIC(
double)
367 Usando gerenciado<std::opcional<bool>>::managed_base::operator=;
369 [[nodiscard]] std::optional<bool> detach()
const {
370 return m_obj->template get_optional<bool>(m_key);
373 [[nodiscard]]
operador std::opcional<bool>()
const {
374 return m_obj->template get_optional<bool>(m_key);
377 std::opcional<bool> operador *()
const {
378 return desvincular();
381 rbool operator==(
const std::opcional<bool>& rhs)
const noexceto;
382 operador de
rbool !=(
const std::optional<bool>& rhs)
const noexceto;
390 modelo<
typename,
typename>
391 amigo estrutura, estrutura managed;
397 m_obj->template set<int64_t>(m_key,
static_cast<int64_t
>(v));
401 [[nodiscard]] T detach()
const {
402 Método estático_cast<T
>(m_obj->get<int64_t>(m_key));
405 [[nodiscard]] Operador de T *()
const {
406 return desvincular();
409 [[nodiscard]]
operador T()
const {
410 return desvincular();
414 rbool operator==(
const T& rhs)
const noexceto {
416 retornar isto->query>equal(m_key, serializar(rhs));
418 return detach() == rhs;
420 operador
rbool !=(
const T& rhs)
const noexceto {
422 retornar isto->m_rbool_query->not_equal(m_key, serialize(rhs));
424 return detach() != rhs;
426 operador
rbool >(
const T& rhs)
const noexceto {
428 return this->m_rbool_query->greter(m_key, serialize(rhs));
430 return detach() > rhs;
432 operador
rbool <(
const T& rhs)
const noexceto {
434 return this->m_rbool_query->greter(m_key, serialize(rhs));
436 return desvinculação() < rhs;
438 operador
rbool >=(
const T& rhs)
const noexceto {
440 return this->m_rbool_query->greter_equal(m_key, serialize(rhs));
442 return detach() >= rhs;
444 operador
rbool <=(
const T& rhs)
const noexceto {
446 return this->m_rbool_query->less_equal(m_key, serialize(rhs));
448 return desvinculação() <= rhs;
457 modelo<
typename,
typename>
458 amigo estrutura, estrutura managed;
462 estrutura, estrutura managed<std::optional<T>, std::enable_if_t<std::is_enum_v<T>>> :
public managed_base {
465 m_obj->template set<std::optional<int64_t>>(m_key,
static_cast<int64_t
>(*v));
467 m_obj->set_null(m_key);
472 [[nodiscard]] std::optional<T> detach()
const {
473 se (
auto v = m_obj->get_optional<int64_t>(m_key)) {
474 Método estático_cast<T
>(*v);
479 [[nodiscard]] std::optional<T> operator *()
const {
480 return desvincular();
483 [[nodiscard]]
operator std::optional<T>()
const {
484 return desvincular();
488 rbool operator==(
const std::opcional<T>& rhs)
const noexceto {
490 retornar isto->query>equal(m_key, serializar(rhs));
492 return detach() == rhs;
494 operador de
rbool !=(
const std::optional<T>& rhs)
const noexceto {
496 retornar isto->m_rbool_query->not_equal(m_key, serialize(rhs));
498 return detach() != rhs;
500 operador
rbool >(
const T& rhs)
const noexceto {
502 return this->m_rbool_query->greter(m_key, rhs);
504 return detach() > rhs;
506 operador
rbool <(
const T& rhs)
const noexceto {
508 return this->m_rbool_query->less(m_key, rhs);
510 return desvinculação() < rhs;
512 operador
rbool >=(
const T& rhs)
const noexceto {
514 return this->m_rbool_query->greter_equal(m_key, rhs);
516 return detach() >= rhs;
518 operador
rbool <=(
const T& rhs)
const noexceto {
520 return this->m_rbool_query->less_equal(m_key, rhs);
522 return desvinculação() <= rhs;
531 modelo<
typename,
typename>
532 amigo estrutura, estrutura managed;
Definição: macros.hpp:286