Realm C++ SDK版本 v 2.2.0

managed_timestamp.hpp

1
2//
3// 版权所有 2022 Realm Inc.
4//
5// 根据 Apache 许可证 2.0 版(“许可证”)获得许可;
6// 除非符合合规,否则不得使用此文件。
7// 您可以在以下网址获取许可证副本:
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// 除非适用法律要求或书面同意,否则软件
12// 根据许可证分发是按“原样”分发的,
13// 不提供任何类型的Express或暗示的保证或条件。
14// 请参阅管理权限的特定语言的许可证和
15// 许可证下的限制。
16//
18
19#ifndef CPPREALM_MANAGED_TIMESTAMP_HPP
20#define CPPREALM_MANAGED_TIMESTAMP_HPP
21
22#include <cpprealm/internal/bridge/timestamp.hpp>
23#include <cpprealm/macros.hpp>
24
25命名空间域 {
26 class rbool;
27 }
28命名空间域 {
29
30 template <>
31 struct managed <std::chrono::time_point<std:: chrono<std::chrono::system_clock> ::system_clock>> : publicmanaged_base {
32 using value_type = std::chrono::time_point<std::chrono::system_clock>;
33 运用 托管 <std::Chrono::Time_Point<std::chrono::system_clock>>::Managed_Base:: 操作符=;
34
35 [[nodiscard]] std::chrono::time_point<std::chrono::system_clock> detach() const {
36 return m_obj->template<realm::internal::bridge::timestamp> get(m_key);
37 }
38
39 [[nodiscard]]操作符std::chrono::time_point<std::chrono::system_clock>() const {
40 return detach();
41 }
42
43 auto time_since_epoch() const {
44 auto Typescript = m_obj->template get<internal::bridge::timestamp>(m_key);
45 return ts.get_time_point().time_since_epoch();
46 }
47
48 template < typename S>
49 void Operator+=( const std::chrono::duration<S>& rhs) {
50 auto Typescript = m_obj->template get<internal::bridge::timestamp>(m_key);
51 m_obj->set(m_key, internal::bridge::timestamp (ts.get_time_point() + rhs));
52 }
53
54 //MARK:-比较操作符
55 rbool 操作符==( const std::chrono::time_point<std::chrono::system_clock>& rhs) const noException ;
56 rbool操作符!=( const std::chrono::time_point<std::chrono::system_clock>& rhs) const noException ;
57 rbool Operator>( const std::chrono::time_point<std::chrono::system_clock>& rhs) const noException ;
58 rbool Operator>=( const std::chrono::time_point<std::chrono::system_clock>& rhs) const noException ;
59 rbool Operator<( const std::chrono::time_point<std::chrono::system_clock>& rhs) const noException ;
60 rbool 操作符<=( const std::chrono::time_point<std::chrono::system_clock>& rhs) const noException ;
61
62 private :
63 托管() = 默认;
64 托管 ( const 托管 &) = delete ;
65 托管 ( 托管 &&) = delete ;
66 托管 & 操作符=( const 托管 &) = delete ;
67 托管 & 操作符=( 托管 &&) = delete ;
68 template < typename , typename >
69 朋友 struct 托管
70 };
71
72 template <>
73 struct 托管 <std::Optional<std::chrono::time_point<std::chrono::system_clock>>> : Managed_base {
74 using value_type = std::Optional<std::chrono::time_point<std::chrono::system_clock>>;
75 运用 Managed <std::Optional<std::chrono::time_point<std::chrono::system_clock>>>::managed_base::operator=;
76
77 [[nodiscard]] std::Optional<std::chrono::time_point<std::chrono::system_clock>> detach() const {
78 return m_obj->get_Optional< realm::internal::bridge::timestamp >(m_key);
79 }
80
81 [[nodiscard]]操作符std::Optional<std::chrono::time_point<std::chrono::system_clock>>() const {
82 return detach();
83 }
84
85 struct {
86 template < typename S>
87 void Operator+=( const std::chrono::duration<S>& rhs) {
88 auto Typescript = m_parent.get().m_obj->get_Optional< internal::bridge::timestamp >(m_parent.get().m_key);
89 m_parent.get().m_obj->set(m_parent.get().m_key, Internal::bridge::timestamp (ts->get_time_point() + rhs));
90 }
91 auto time_since_epoch() const {
92 auto Typescript = m_parent.get().m_obj->get_Optional< internal::bridge::timestamp >(m_parent.get().m_key);
93 return ts->get_time_point().time_since_epoch();
94 }
95 private :
96 盒子托管和父):m_parent(parent) { }
97 std::reference_wrapper< 托管<std::Optional<std::chrono::time_point<std::chrono::system_clock>>>> m_parent;
98 朋友 struct Managed <std::Optional<std::chrono::time_point<std::chrono::system_clock>>>;
99 };
100
101 std::unique_ptr<box> Operator->()
102 {
103 return std::make_unique<box>( box (* this ));
104 }
105 [[nodiscard]]操作符*() {
106 return Box (* this );
107 }
108
109 //MARK:-比较操作符
110 rbool操作符==( const std::Optional<std::chrono::time_point<std::chrono::system_clock>>& rhs) const noException ;
111 rbool操作符!=( const std::Optional<std::chrono::time_point<std::chrono::system_clock>>& rhs) const noException ;
112
113 private :
114 托管() = 默认;
115 托管 ( const 托管 &) = delete ;
116 托管 ( 托管 &&) = delete ;
117 托管 & 操作符=( const 托管 &) = delete ;
118 托管 & 操作符=( 托管 &&) = delete ;
119 template < typename , typename >
120 朋友 struct 托管
121 };
122
123 } // 命名空间 Realm
124
125
126#endif//CPREALM_MANAGED_TIMESTAMP_HPP
定义: rbool.hpp:36
定义: managed_dictionary.hpp: 129
定义: timestamp.hpp: 30
定义: macros.hpp:286
定义: obj.hpp:62