19#ifndef CPPREALM_MANAGED_NUMERIC_HPP
20#define CPPREALM_MANAGED_NUMERIC_HPP
22#include <cpprealm/macros.hpp>
23#include <cpprealm/rbool.hpp>
28 运用 managed <int 64 _t>::managed_base::operator=;
31 this->m_obj->template set<int 64 _t>(m_key, v);
35 [[nodiscard]] int 64 _t detach()
const {
36 return m_obj->template get<int64_t>(m_key);
39 [[nodiscard]] int 64 _t 操作符 *()
const {
43 [[nodiscard]]
操作符 int 64 _t()
const {
47 template <
typename T>
48 std::enable_if_t<std::is_integral_v<T>,
rbool > 操作符==(
const T& rhs)
const noException {
49 if (this->m_rbool_query) {
50 return this->m_rbool_query->equal(m_key, (int 64 _t)rhs);
55 template <
typename T>
56 std::enable_if_t<std::is_integral_v<T>,
rbool > Operator!=(
const T& rhs)
const noException {
57 if (this->m_rbool_query) {
58 return this->m_rbool_query->not_equal(m_key, (int 64 _t)rhs);
63 template <
typename T>
64 std::enable_if_t<std::is_integral_v<T>,
rbool > 操作符>(
const T& rhs)
const noException {
65 if (this->m_rbool_query) {
66 return this->m_rbool_query->greater(m_key, (int 64 _t)rhs);
71 template <
typename T>
72 std::enable_if_t<std::is_integral_v<T>,
rbool > 操作符<(
const T& rhs)
const noException {
73 if (this->m_rbool_query) {
74 return this->m_rbool_query->less(m_key, (int 64 _t)rhs);
79 template <
typename T>
80 std::enable_if_t<std::is_integral_v<T>,
rbool > Operator>=(
const T& rhs)
const noException {
81 if (this->m_rbool_query) {
82 return this->m_rbool_query->greater_equal(m_key, (int 64 _t)rhs);
87 template <
typename T>
88 std::enable_if_t<std::is_integral_v<T>,
rbool > 操作符<=(
const T& rhs)
const noException {
89 if (this->m_rbool_query) {
90 return this->m_rbool_query->less_equal(m_key, (int 64 _t)rhs);
95 Managed & Operator+=(
const int 64 _t& o) {
96 auto old_val = m_obj->template get<int 64 _t>(m_key);
97 m_obj->template 设立<int 64 _t>(this->m_key, old_val + o);
100 void Operator++(
int ) {
101 auto old_val = m_obj->template get<int 64 _t>(m_key);
102 m_obj->template 设立<int 64 _t>(this->m_key, old_val + 1 );
105 auto old_val = m_obj->template get<int 64 _t>(m_key);
106 m_obj->template 设立<int 64 _t>(this->m_key, old_val + 1 );
108 托管 & 操作符-=(
const int 64 _t& o) {
109 auto old_val = m_obj->template get<int 64 _t>(m_key);
110 m_obj->template 设立<int 64 _t>(this->m_key, old_val - o);
114 auto old_val = m_obj->template get<int 64 _t>(m_key);
115 m_obj->template 设立<int 64 _t>(this->m_key, old_val - 1 );
118 auto old_val = m_obj->template get<int 64 _t>(m_key);
119 m_obj->template 设立<int 64 _t>(this->m_key, old_val - 1 );
121 Managed & Operator*=(
const int 64 _t& o) {
122 auto old_val = m_obj->template get<int 64 _t>(m_key);
123 m_obj->template 设立<int 64 _t>(this->m_key, old_val * o);
129 托管 (
const 托管 &) =
delete ;
130 托管 (
托管 &&) =
delete ;
131 托管 & 操作符=(
const 托管 &) =
delete ;
132 托管 & 操作符=(
托管 &&) =
delete ;
133 template <
typename ,
typename >
139 运用 托管 <
double >::managed_base:: 操作符=;
142 this->m_obj->template set<double>(m_key, v);
147 this->m_obj->template 设立<double>(m_key, (
double )v);
151 [[nodiscard]]
double detach()
const {
152 return m_obj->template get<double>(m_key);
155 double 操作符 *()
const {
158 [[nodiscard]]
操作符double()
const {
162 template <
typename T>
163 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool > 操作符==(
const T& rhs)
const noException {
164 if (this->m_rbool_query) {
165 return this->m_rbool_query->equal(m_key, (
double )rhs);
170 template <
typename T>
171 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool > 操作符!=(
const T& rhs)
const noException {
172 if (this->m_rbool_query) {
173 return this->m_rbool_query->not_equal(m_key, (
double )rhs);
178 template <
typename T>
179 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool > 操作符>(
const T& rhs)
const noException {
180 if (this->m_rbool_query) {
181 return this->m_rbool_query->greater(m_key, (
double )rhs);
186 template <
typename T>
187 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool > 操作符<(
const T& rhs)
const noException {
188 if (this->m_rbool_query) {
189 return this->m_rbool_query->less(m_key, (
double )rhs);
194 template <
typename T>
195 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool > 操作符>=(
const T& rhs)
const noException {
196 if (this->m_rbool_query) {
197 return this->m_rbool_query->greater_equal(m_key, (
double )rhs);
202 template <
typename T>
203 std::enable_if_t< std::disjunction_v<std::is_integral<T>, std::is_floating_point<T>>,
rbool > 操作符<=(
const T& rhs)
const noException {
204 if (this->m_rbool_query) {
205 return this->m_rbool_query->less_equal(m_key, (
double )rhs);
210 void Operator+=(
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 void Operator++(
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 void Operator-=(
const double & o) {
223 auto old_val = m_obj->template get<double>(m_key);
224 m_obj->template 设立<double>(this->m_key, old_val - o);
227 auto old_val = m_obj->template get<double>(m_key);
228 m_obj->template 设立<double>(this->m_key, old_val - 1.0 );
231 auto old_val = m_obj->template get<double>(m_key);
232 m_obj->template 设立<double>(this->m_key, old_val - 1.0 );
234 void 操作符*=(
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);
241 托管 (
const 托管 &) =
delete ;
242 托管 (
托管 &&) =
delete ;
243 托管 & 操作符=(
const 托管 &) =
delete ;
244 托管 & 操作符=(
托管 &&) =
delete ;
245 template <
typename ,
typename >
251 运用 托管 <
bool >::managed_base:: 操作符=;
253 [[nodiscard]]
bool detach()
const {
254 return m_obj->template get<bool>(m_key);
256 [[nodiscard]]
操作符 bool()
const {
259 bool Operator *()
const {
263 rbool Operator==(
const bool & rhs)
const noException ;
264 rbool操作符!=(
const bool & rhs)
const noException ;
268 托管 (
const 托管 &) =
delete ;
269 托管 (
托管 &&) =
delete ;
270 托管 & 操作符=(
const 托管 &) =
delete ;
271 托管 & 操作符=(
托管 &&) =
delete ;
272 template <
typename ,
typename >
276#define CPP_REALM_MANAGED_OPTIONAL_NUMERIC(type) \
278 struct 托管<std::Optional<type>> : Managed_base { \
279 using 托管<std::Optional<type>>::Managed_base:: 操作符=; \
281 托管<std::Optional<type>>& 操作符 =(const double& v) { \
282 this->m_obj->template set<type>(m_key, v); \
286 托管<std::Optional<type>>& 操作符 =(const int& v) { \
287 this->m_obj->template set<type>(m_key, (double)v); \
291 [[nodiscard]] std::Optional<type> 分离() const { \
292 return m_obj->get_optional<type>(m_key); \
295 [[nodiscard]] std::Optional<type> Operator *() const { \
298 [[nodiscard]] 操作符 std::Optional<type>() const { \
301 rbool 操作符==(const std::Optional<type>& rhs) const noException; \
302 rbool操作符!=(const std::Optional<type>& rhs) const noException; \
303 void Operator+=(const type& o) { \
304 auto old_val = m_obj->get_Optional<type>(m_key); \
306throw std::runtime_error("无法对 null 值执行算术。" ); \
308 m_obj->template set<type>(this->m_key, (*old_val) + o); \
310 void Operator++(int) { \
311 auto old_val = m_obj->get_Optional<type>(m_key); \
313 throw std::runtime_error("无法对 null 值执行算术运算。"); \
315 m_obj->template 设立<type>(this->m_key, (*old_val) + 1 ); \
317 void 操作符-=(const type& o) { \
318 auto old_val = m_obj->get_Optional<type>(m_key); \
320 throw std::runtime_error("无法对 null 值执行算术运算。"); \
322 m_obj->template 设立<type>(this->m_key, (*old_val) - o); \
325 auto old_val = m_obj->get_Optional<type>(m_key); \
327 throw std::runtime_error("无法对 null 值执行算术运算。"); \
329 m_obj->template 设立<type>(this->m_key, (*old_val) - 1 ); \
331 void 操作符*=(const type& o) { \
332 auto old_val = m_obj->get_Optional<type>(m_key); \
334 throw std::runtime_error("无法对 null 值执行算术运算。"); \
336 m_obj->template set<type>(this->m_key, (*old_val) * o); \
338 void 操作符*(const type& o) { \
339 auto old_val = m_obj->get_Optional<type>(m_key); \
341 throw std::runtime_error("无法对 null 值执行算术运算。"); \
343 m_obj->template set<type>(this->m_key, (*old_val) * o); \
345 void 操作符/(const type& o) { \
346 auto old_val = m_obj->get_Optional<type>(m_key); \
348 throw std::runtime_error("无法对 null 值执行算术运算。"); \
350 m_obj->template set<type>(this->m_key, (*old_val) / o); \
354 托管(const Managed&) = 删除; \
356 Managed& 操作符=(const Managed&) = 删除; \
357 Managed& 操作符=(managed&&) = 删除; \
358 template<typename, typename> \
362 CPP_REALM_MANAGED_OPTIONAL_NUMERIC(int 64 _t)
363 CPP_REALM_MANAGED_OPTIONAL_NUMERIC(
double )
367 运用 托管 <std::Optional<bool>>::managed_base:: 操作符=;
369 [[nodiscard]] std::Optional<bool> detach()
const {
370 return m_obj->template get_Optional<bool>(m_key);
373 [[nodiscard]]
操作符std::Optional<bool>()
const {
374 return m_obj->template get_Optional<bool>(m_key);
377 std::Optional<bool> 操作符 *()
const {
381 rbool 操作符==(
const std::Optional<bool>& rhs)
const noException ;
382 rbool操作符!=(
const std::Optional<bool>& rhs)
const noException ;
386 托管 (
const 托管 &) =
delete ;
387 托管 (
托管 &&) =
delete ;
388 托管 & 操作符=(
const 托管 &) =
delete ;
389 托管 & 操作符=(
托管 &&) =
delete ;
390 template <
typename ,
typename >
394 template <
typename T>
396 托管<T> & 操作符 =(
const T& v) {
397 m_obj->template 设立<int 64 _t>(m_key,
static_cast< int 64 _t
> (v));
401 [[nodiscard]] T 分离 ()
const {
402 return static_cast< T
> (m_obj->get<int 64 _t>(m_key));
405 [[nodiscard]] T操作符*()
const {
409 [[nodiscard]]
操作符T()
const {
414 rbool 操作符==(
const T& rhs)
const noException {
415 if (this->m_rbool_query) {
416 return this->查询>equal(m_key,serialize(rhs));
418 return detach() == rhs;
420 rbool操作符!=(
const T& rhs)
const noException {
第 421 章 if (this->m_rbool_query) {
第 422 章 return this->m_rbool_query->not_equal(m_key,serialize(rhs));
424 return detach() != rhs;
426 rbool Operator>(
const T& rhs)
const noException {
第 427 章 if (this->m_rbool_query) {
428 return this->m_rbool_query->greater(m_key,serialize(rhs));
430 return detach() > rhs;
第 432 章 rbool 操作符<(
const T& rhs)
const noException {
第 433 章 if (this->m_rbool_query) {
第 434 章 return this->m_rbool_query->greater(m_key,serialize(rhs));
第 436 章 return detach() < rhs;
第 438 章 rbool 操作符>=(
const T& rhs)
const noException {
第 439 章 if (this->m_rbool_query) {
440 return this->m_rbool_query->greater_equal(m_key,serialize(rhs));
第 442 章 return detach() >= rhs;
第 444 章 rbool 操作符<=(
const T& rhs)
const noException {
445 if (this->m_rbool_query) {
第 446 章 return this->m_rbool_query->less_equal(m_key,serialize(rhs));
第 448 章 return detach() <= rhs;
453 托管 (
const 托管 &) =
delete ;
第 454 章 托管 (
托管 &&) =
delete ;
455 托管 & 操作符=(
const 托管 &) =
delete ;
第 456 章 托管 & 操作符=(
托管 &&) =
delete ;
第 457 章 template <
typename ,
typename >
第 461 章 template <
typename T>
465 m_obj->template 设立<std::Optional<int 64 _t>>(m_key,
static_cast< int 64 _t
> (*v));
467 m_obj->set_null(m_key);
472 [[nodiscard]] std::可选<T> 分离()
const {
473 if (
auto v = m_obj->get_Optional<int 64 _t>(m_key)) {
474 return static_cast< T
> (*v);
479 [[nodiscard]] std::Optional<T> 操作符 *()
const {
483 [[nodiscard]]
操作符std::Optional<T>()
const {
488 rbool 操作符==(
const std::Optional<T>& rhs)
const noException {
489 if (this->m_rbool_query) {
490 return this->查询>equal(m_key,serialize(rhs));
492 return detach() == rhs;
494 rbool操作符!=(
const std::Optional<T>& rhs)
const noException {
495 if (this->m_rbool_query) {
496 return this->m_rbool_query->not_equal(m_key,serialize(rhs));
498 return detach() != rhs;
500 rbool Operator>(
const T& rhs)
const noException {
501 if (this->m_rbool_query) {
502 return this->m_rbool_query->greater(m_key, rhs);
504 return detach() > rhs;
506 rbool 操作符<(
const T& rhs)
const noException {
507 if (this->m_rbool_query) {
508 return this->m_rbool_query->less(m_key, rhs);
510 return detach() < rhs;
512 rbool 操作符>=(
const T& rhs)
const noException {
513 if (this->m_rbool_query) {
514 return this->m_rbool_query->greater_equal(m_key, rhs);
516 return detach() >= rhs;
518 rbool 操作符<=(
const T& rhs)
const noException {
519 if (this->m_rbool_query) {
520 return this->m_rbool_query->less_equal(m_key, rhs);
522 return detach() <= rhs;
527 托管 (
const 托管 &) =
delete ;
528 托管 (
托管 &&) =
delete ;
529 托管 & 操作符=(
const 托管 &) =
delete ;
530 托管 & 操作符=(
托管 &&) =
delete ;
531 template <
typename ,
typename >