19#ifndef CPPREALM_TYPES_HPP
20#define CPPREALM_TYPES_HPP
27#include <cpprealm/internal/bridge/realm.hpp>
28#include <cpprealm/internal/bridge/schema.hpp>
29#include <cpprealm/internal/type_info.hpp>
33 const size_t not_in_collection = - 1 ;
36 显式 uuid (
const std::string &);
37 uuid (
const std:: 大量<uint 8 _t, 16 >&);
39 [[nodiscard]] std::string to_string()
const ;
40 [[nodiscard]] std::string to_base 64 ()
const ;
41 [[nodiscard]] std::array<uint 8 _t, 16 > to_bytes()
const ;
45 template <
typenamemapped_type >
49 内联 bool Operator ==(
const uuid & lhs,
const uuid & rhs) {
return lhs.m_uuid == rhs.m_uuid; }
50 内联 bool 操作符 !=(
const uuid& lhs,
const uuid& rhs) {
return lhs.m_uuid != rhs.m_uuid; }
51 内联 bool 操作符 >(
const uuid& lhs,
const uuid& rhs) {
return lhs.m_uuid > rhs.m_uuid; }
52 内联 bool 操作符 >=(
const uuid& lhs,
const uuid& rhs) {
return lhs.m_uuid >= rhs.m_uuid; }
53 内联 bool Operator <(
const uuid& lhs,
const uuid& rhs) {
return lhs.m_uuid < rhs.m_uuid; }
54 内联 bool Operator <=(
const uuid& lhs,
const uuid& rhs) {
return lhs.m_uuid <= rhs.m_uuid; }
59 [[nodiscard]]
static object_id generate();
60 [[nodiscard]] std::string to_string()
const ;
64 template <
typenamemapped_type >
68 内联 bool 操作符 ==(
const object_id & lhs,
const object_id & rhs) {
return lhs.m_object_id == rhs.m_object_id; }
69 内联 bool Operator !=(
const object_id& lhs,
const object_id& rhs) {
return lhs.m_object_id != rhs.m_object_id; }
70 内联 bool 操作符 <(
const object_id& lhs,
const object_id& rhs) {
return lhs.m_object_id < rhs.m_object_id; }
71 内联 bool 操作符 >(
const object_id& lhs,
const object_id& rhs) {
return lhs.m_object_id > rhs.m_object_id; }
72 内联 bool 操作符 <=(
const object_id& lhs,
const object_id& rhs) {
return lhs.m_object_id <= rhs.m_object_id; }
73 内联 bool 操作符 >=(
const object_id& lhs,
const object_id& rhs) {
return lhs.m_object_id >= rhs.m_object_id; }
76 显式 十进制128 (
const std::string &);
79 [[nodiscard]] std::string to_string()
const ;
80 [[nodiscard]]
bool is_NaN()
const ;
84 template <
typenamemapped_type >
98 内联 bool 操作符 >(
const Decimal
128 & lhs,
const Decimal
128 & rhs) {
return lhs.m_decimal > rhs.m_decimal; }
99 内联 bool Operator >=(
const Decimal 128 & lhs,
const Decimal 128 & rhs) {
return lhs.m_decimal >= rhs.m_decimal; }
100 内联 bool Operator <(
const Decimal 128 & lhs,
const Decimal 128 & rhs) {
return lhs.m_decimal < rhs.m_decimal; }
101 内联 bool Operator <=(
const Decimal 128 & lhs,
const Decimal 128 & rhs) {
return lhs.m_decimal <= rhs.m_decimal; }
102 内联 bool Operator ==(
const Decimal 128 & lhs,
const Decimal 128 & rhs) {
return lhs.m_decimal == rhs.m_decimal; }
103 内联 bool 操作符 !=(
const Decimal 128 & lhs,
const Decimal 128 & rhs) {
return lhs.m_decimal != rhs.m_decimal; }
108 静态 inline int 64 _t Serialize(int 64 _t v,
const std::Optional<internal::bridge::realm>& = std::nullopt) {
111 静态 inline int 64 _t deserialize(int 64 _t v) {
115 静态 inline std::Optional<int64 _t> Serialize(
const std::Optional<int64 _t>& v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
118 静态 inline std::Optional<int 64 _t> deserialize(
const std::Optional<int 64 _t>& v) {
122 静态 内联 double不行
double<internal::bridge::realm>
125 静态 内联 double deserialize(
const double & v) {
129 静态 inline std::Optional<double> Serialize(
const std::Optional<double> & v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
132 静态 inline std::Optional<double> deserialize(
const std::Optional<double>& v) {
136 静态 内联 bool Serialize(
bool v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
139 静态 内联 bool deserialize(
bool v) {
143 静态 inline std::Optional<bool> Serialize(std::Optional<bool> v,
const std::Optional<internal::bridge::realm>& = std::nullopt) {
146 静态 inline std::Optional<bool> deserialize(std::Optional<bool> v) {
150 template <
typename T>
151 静态 内联 typename std:: enable_if_t <std:: is_enum_v,<T> int64 域>eria
<internal::bridge::realm>
152 return static_cast< int 64 _t
> (v);
154 template <
typename T, std::enable_if_t<std::is_enum_v<T>>>
155 静态 inline T deserialize(int 64 _t v) {
156 return static_cast< T
> (v);
159 template <
typename T>
160 静态 inline std::enable_if_t<std::is_enum_v,<typename T::value_type> std::Optional<int64 _t>> Serialize(
const T& v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
162 return static_cast< int 64 _t
> (*v);
167 template <
typename T, std::enable_if_t<std::is_enum_v<
typename T::value_type>>>
168 静态 inline std::Optional<int 64 _t> deserialize(std::Optional<int 64 _t> v) {
170 return static_cast< T
> (*v);
176 静态 inline std::string Serialize(
const std::string& v,
const std::Optional<internal::bridge::realm>& = std::nullopt) {
179 静态 inline std::string deserialize(
const std::string& v) {
183 静态 inline std::Optional<std::string> Serialize(
const std::Optional<std::string> & v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
186 静态 inline std::Optional<std::string> deserialize(
const std::Optional<std::string>& v) {
190 静态 inlineinternal::bridge:: uuidserialize (
const uuid& v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
193 静态 inline uuid deserialize(
const inside ::bridge::uuid& v) {
194 return 操作符 :: 域::uuid();
197 静态 inline std::Optional<internal::bridge::uuid> Serialize(
const std::Optional<uuid>& v,
const std::Optional<internal::bridge::realm>& = std::nullopt) {
200 静态 inline std::Optional<uuid> deserialize(
const std::Optional<internal::bridge::uuid>& v) {
202 return v->操作符::域::uuid();
208 静态 inlineInternal::bridge::
binaryserialize (
const std::vector<uint 8 _t>& v,
const std::Optional<internal::bridge::realm>& = std::nullopt) {
211 静态 inline std::vector<uint 8 _t> deserialize(
const inside::bridge::binary& v) {
212 return v.operator std::vector<uint 8 _t>();
215 静态 inline std::Optional<internal::bridge::binary> Serialize(
const std::Optional<std::vector<uint8 _t>>& v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
218 静态 inline std::Optional<std::vector<uint 8 _t>> deserialize(
const std::Optional<internal::bridge::binary>& v) {
220 return v->operator std::vector<uint 8 _t>();
226 静态 inlineinternal::bridge::timestampserialize(
const std:: chrono ::time_point<std::chrono::system_clock> & v,
const std::Optional<internal::bridge::realm> & = std::nullopt ) {
229 静态 inline std::chrono::time_point<std::chrono::system_clock> deserialize(
constinternal ::bridge::timestamp& v) {
230 return v. 操作符 std::chrono::time_point<std::chrono::system_clock>();
233 静态 inline std::Optional<internal::bridge::timestamp> Serialize(
const std::Optional<std::chrono::time_point<std::chrono::system_clock> >& v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
236 静态 inline std::Optional<std::chrono::time_point<std::chrono::system_clock>> deserialize(
const std::Optional<internal::bridge::timestamp>& v) {
238 return v->operator std::chrono::time_point<std::chrono::system_clock>();
244 静态 inlineinternal ::bridge::object_idserialize(
const 域::object_id & v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
248 return 操作符 :: 域::object_id();
251 静态 inline std::Optional<internal::bridge::object_id> Serialize(
const std::Optional<realm::object_id> & v,
const std::Optional<internal::bridge::realm> & = std::nullopt ) {
254 静态 inline std::Optional<realm::object_id> deserialize(
const std::Optional<internal::bridge::object_id>& v) {
256 return v->操作符::域::Realm 对象();
262 静态 inlineInternal ::bridge::decimal 128 serialize(
const realm::decimal 128 & v,
const std::Optional<internal::bridge::realm>& = std::nullopt) {
266 return v.operator::realm::decimal 128 ();
269 静态 inline std::Optional<internal::bridge::decimal128 > Serialize(
const std::Optional< 域::decimal128 >& v,
const std::Optional<internal::bridge::realm> & = std::nullopt) {
272 静态 inline std::Optional< 域::decimal 128 > deserialize(
const std::Optional<internal::bridge::decimal 128 >& v) {
274 return v-> 操作符 :: 域::decimal 128 ();
280 template <
typename T>
281 静态 内联 typename std::enable_if_t<internal::type_info:: MixedPersistableConcept::value,<T> inside::bridge:: 域> eria
<internal::bridge::realm>std::nullopt) {
282 return std::visit([&](
auto && arg) {
283 using StoredType = std::decay_t<
decltype (arg)>;
284 using M =
typenameInternal ::type_info::type_info<StoredType>::internal_type;
285 returninternal ::bridge::mixed(M(arg));
289 template <
typename T>
290 静态 内联 typename std::enable_if_t<!internal::type_info::MixedPersistableConcept<T>::value, T>
291 deserialize(
const inside ::bridge::mixed& value) {
292 if constexpr (internal::type_info::is_Optional<T>::value) {
294 }
else if constexpr (std::is_same_v<T, int64_t>) {
295 返回值。 操作符 int 64 _t();
296 }
else if constexpr (std::is_same_v<T, bool>) {
297 return value.operator bool();
298 }
else if constexpr (std::is_same_v<T, std::string>) {
299 return static_cast< std::string
> (value);
300 }
else if constexpr (std::is_same_v<T, std::vector<uint8_t>>) {
301 return static_cast< std::vector<uint 8 _t>
> (
static_cast< internal::bridge::binary
> (value));
302 }
else if constexpr (std::is_same_v<T, std::chrono::time_point<std::chrono::system_clock>>) {
303 return static_cast< internal::bridge::timestamp
> (value);
304 }
else if constexpr (std::disjunction_v<std::is_same<T, double>, std::is_same<T, float>>) {
305 return static_cast<double> (value);
306 }
else if constexpr (std::is_same_v<T, realm::uuid>) {
307 返回值。操作符内部::bridge::uuid()。操作符:: 域::uuid();
308 }
else if constexpr (std::is_same_v<T, realm::object_id>) {
309 返回值。操作符内部::bridge::object_id()。操作符 :: 域::object_id();
310 }
else if constexpr (std::is_same_v<T, realm::decimal 128 >) {
311 返回值。操作符内部::bridge::decimal 128 () 。操作符 :: 域::decimal 128 ();
312 }
else if constexpr (std::is_enum_v<T>) {
313 return static_cast< T
> (操作符 int 64 _t());
319 template <
typename T>
320 静态 内联 typename std::enable_if_t<internal::type_info::MixedPersistableConcept<T>::value, T>
321 deserialize(
const inside ::bridge::mixed& value) {
322 if (value.is_null()) {
323 return std::monostate();
326 switch (value.type()) {
327 caseInternal ::bridge::data_type::Int:
328 返回值。 操作符 int 64 _t();
329 caseInternal ::bridge::data_type::Bool:
330 return value.operator bool();
331 caseInternal ::bridge::data_type::String:
332 return static_cast< std::string
> (value);
333 caseInternal ::bridge::data_type::Binary:
334 return static_cast< std::vector<uint 8 _t>
> (
static_cast< internal::bridge::binary
> (value));
335 caseInternal ::bridge::data_type::Timestamp:
336 return static_cast< internal::bridge::timestamp
> (value);
337 caseInternal ::bridge::data_type::Float:
338 caseInternal ::bridge::data_type::Double:
339 return static_cast<double> (value);
340 caseInternal ::bridge::data_type::UUID:
341 返回值。操作符内部::bridge::uuid()。操作符:: 域::uuid();
342 caseInternal ::bridge::data_type::ObjectId:
343 返回值。操作符内部::bridge::object_id()。操作符 :: 域::object_id();
344 case inside::bridge::data_type::Decimal:
345 返回值。操作符internal::bridge::decimal 128 ()。操作符 :: 域::decimal 128 ();
346 caseInternal ::bridge::data_type::TypedLink:
347 throw std::runtime_error(
"存储在混合属性中的对象必须通过 `get_object_value()` 访问" );
349 throw std::runtime_error(
"反序列化混合属性时出现未知数据类型。" );
定义: managed_dictionary.hpp: 31