Realm C++ SDK版本 v 2.2.0

timestamp.hpp

1
2//
3// 版权所有 2024 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_BRIDGE_TIMESTAMP_HPP
20#define CPPREALM_BRIDGE_TIMESTAMP_HPP
21
22#include <chrono>
23#include <cpprealm/internal/bridge/utils.hpp>
24
25命名空间域 {
26 class Timestamp;
27 }
28
29命名空间realm::internal::bridge {
30 struct 时间戳{
31 timestamp () = 默认 ;
32 timestamp ( const timestamp & other) = 默认 ;
33 timestamp & Operator=( const timestamp & other) = default ;
34 timestamp ( timestamp && other) = default ;
35 timestamp & 操作符=( timestamp && other) = 默认 ;
36 ~timestamp () = 默认 ;
37 timestamp ( const Timestamp&); //NOLINT(google-explicit-constructor)
38 操作符 Timestamp() const ; //NOLINT(google-explicit-constructor)
39 操作符 std::chrono::time_point<std::chrono::system_clock>() const ; //NOLINT(google-explicit-constructor)
40 timestamp (int 64 _t 秒, int 32 _t 纳秒);
41 timestamp ( const std::chrono::time_point<std::chrono::system_clock>& tp); //NOLINT(google-explicit-constructor)
42 [[nodiscard]] int 64 _t get_seconds() const noException ;
43 [[nodiscard]] int 32 _t get_nanoseconds() const noException ;
44 [[nodiscard]] std::chrono::time_point<std::chrono::system_clock, std::chrono::system_clock::duration>
45 get_time_point() const {
46 int 64 _t Native_nano = get_seconds() *anoseconds_per_second + get_nanoseconds();
47 auto duration = std::chrono::duration_cast<std::chrono::system_clock::duration>(std::chrono::duration<int64_t, std::nano>{native_nano});
48 return std::chrono::time_point<std::chrono::system_clock,
49 std::chrono::system_clock::duration>(duration);
50 }
51 private :
52 静态 constexpr int 32 _t Nanoseconds_per_second = 1000000000 ;
53 int 64 _t m_seconds = 0 ;
54 int 32 _t m_nanoseconds = 0 ;
55 朋友 bool 操作符 ==( const timestamp &, const timestamp &);
56 朋友 bool 操作符 !=( const timestamp &, const timestamp &);
57 朋友 bool Operator >( const timestamp &, const timestamp &);
58 朋友 bool 操作符 <( const timestamp &, const timestamp &);
59 朋友 bool 操作符 >=( const timestamp &, const timestamp &);
60 朋友 bool 操作符 <=( const timestamp &, const timestamp &);
61 };
62
63 bool 操作符 ==( const timestamp &, const timestamp &);
64 bool 操作符 !=( const timestamp &, const timestamp &);
65 bool Operator >( const timestamp &, const timestamp &);
66 bool 操作符 <( const timestamp &, const timestamp &);
67 bool 操作符 >=( const timestamp &, const timestamp &);
68 bool 操作符 <=( const timestamp &, const timestamp &);
69 }
70
71#endif //CPREALM_BRIDGE_TIMESTAMP_HPP
定义: timestamp.hpp: 30