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:: 배열<uint8_t, 16>&);
39 [[nodiscard]] std::string to_string()
const;
40 [[nodiscard]] std::string to_base64()
const;
41 [[nodiscard]] std::array<uint8_t, 16> to_bytes()
const;
45 템플릿 <
typename mapping_type>
49 인라인 bool 연산자 ==(
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 연산자 <(
const uuid& lhs,
const uuid& rhs) {
return lhs.m_uuid < rhs.m_uuid; }
54 인라인 bool 연산자 <=(
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 템플릿 <
typename mapping_type>
68 인라인 bool 연산자 ==(
const object_id& lhs,
const object_id& rhs) {
return lhs.m_object_id == rhs.m_object_id; }
69 인라인 bool 연산자 !=(
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 템플릿 <
typename mapping_type>
98 인라인 bool 연산자 >(
const decimal128& lhs,
const decimal128& rhs) {
return lhs.m_decimal > rhs.m_decimal; }
99 인라인 bool 연산자 >=(
const decimal128& lhs,
const decimal128& rhs) {
return lhs.m_decimal >= rhs.m_decimal; }
100 인라인 bool 연산자 <(
const decimal128& lhs,
const decimal128& rhs) {
return lhs.m_decimal < rhs.m_decimal; }
101 인라인 bool 연산자 <=(
const decimal128& lhs,
const decimal128& rhs) {
return lhs.m_decimal <= rhs.m_decimal; }
102 인라인 bool 연산자 ==(
const decimal128& lhs,
const decimal128& rhs) {
return lhs.m_decimal == rhs.m_decimal; }
103 인라인 bool 연산자 !=(
const decimal128& lhs,
const decimal128& rhs) {
return lhs.m_decimal != rhs.m_decimal; }
108 static 인라인 int64_t serialize(int64_t v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
111 static 인라인 int64_t deserialize(int64_t v) {
115 static inline std::optional<int64_t> serialize(
const std::optional<int64_t>& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
118 static inline std::optional<int64_t> deserialize(
const std::optional<int64_t>& v) {
122 static 인라인 double serialize(
const double& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
125 static 인라인 double deserialize(
const double& v) {
129 static inline std::optional<double> serialize(
const std::optional<double>& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
132 static 인라인 std::optional<double> deserialize(
const std::optional<double>& v) {
136 static 인라인 bool serialize(
bool v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
139 static 인라인 bool deserialize(
bool v) {
143 static 인라인 std::optional<bool> serialize(std::optional<bool> v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
146 static 인라인 std::optional<bool> deserialize(std::optional<bool> v) {
151 static 인라인 typename std::enable_if_t<std::is_enum_v,<T> int64_t> serialize(
const T& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
152 반환 static_cast<int64_t
>(v);
154 템플릿<
typename T, std::enable_if_t<std::is_enum_v<T>>>
155 static 인라인 T deserialize(int64_t v) {
156 반환 static_cast<T
>(v);
160 static 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 반환 static_cast<int64_t
>(*v);
167 템플릿<
typename T, std::enable_if_t<std::is_enum_v<
typename T::value_type>>>
168 static 인라인 std::optional<int64_t> deserialize(std::optional<int64_t> v) {
170 반환 static_cast<T
>(*v);
176 static inline std::string serialize(
const std::string& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
179 static 인라인 std::string deserialize(
const std::string& v) {
183 static inline std::optional<std::string> serialize(
const std::optional<std::string>& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
186 static 인라인 std::optional<std::string> deserialize(
const std::optional<std::string>& v) {
190 static inline internal::bridge::uuid serialize(
const uuid& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
193 static 인라인 uuid deserialize(
const internal::bridge::uuid& v) {
194 return v. 연산자 :: 영역::uuid();
197 static inline std::optional<internal::bridge::uuid> serialize(
const std::optional<uuid>& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
200 static 인라인 std::optional<uuid> deserialize(
const std::optional<internal::bridge::uuid>& v) {
202 v->연산자
반환 ::realm::uuid();
208 static inline internal::bridge::binary serialize(
const std::vector<uint8_t>& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
211 static 인라인 std::vector<uint8_t> deserialize(
const internal::bridge::binary& v) {
212 return v.operator std::vector<uint8_t>();
215 static inline std::optional<internal::bridge::binary> serialize(
const std::optional<std::vector<uint8_t>>& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
218 static inline std::optional<std::vector<uint8_t>> deserialize(
const std::optional<internal::bridge::binary>& v) {
220 return v->operator std::vector<uint8_t>();
226 static inline internal::bridge::timestamp serialize(
const std::chrono::time_point<std::chrono::system_clock>& v,
const std::optional<internal::bridge::realm>& = std::nullopt ) {
229 static 인라인 std::chrono::time_point<std::chrono::system_clock> deserialize(
const internal::bridge::timestamp& v) {
230 return 대 연산자 std::chrono::time_point<std::chrono::system_clock>();
233 static 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 static 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 static inline internal::bridge::object_id serialize(
const 영역::object_id& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
247 static 인라인 realm::object_id deserialize(
const internal::bridge::object_id& v) {
248 return v. 연산자 :: 영역::object_id();
251 static inline std::optional<internal::bridge::object_id> serialize(
const std::optional<realm::object_id>& v,
const std::optional<internal::bridge::realm>& = std::nullopt ) {
254 static inline std::optional<realm::object_id> deserialize(
const std::optional<internal::bridge::object_id>& v) {
256 return v->연산자::Realm 객체;
262 static inline internal::bridge::decimal128 serialize(
const realm::decimal128& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
265 static 인라인 realm::decimal128 deserialize(
const internal::bridge::decimal128& v) {
266 return v.operator ::realm::decimal128();
269 static inline std::optional<internal::bridge::decimal128> serialize(
const std::optional< 영역::decimal128>& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
272 static inline std::optional< 영역::decimal128> deserialize(
const std::optional<internal::bridge::decimal128>& v) {
274 return v-> 연산자 :: 영역::decimal128();
281 static 인라인 typename std::enable_if_t<internal::type_info::MixedPersistableConcept::value,<T> internal::bridge::mixed> serialize(
const T& v,
const std::optional<internal::bridge::realm>& = std::nullopt) {
282 return std::visit([&](
auto&& arg) {
283 using StoredType = std::decay_t<
decltype(arg)>;
284 using M =
typename internal::type_info::type_info<StoredType>::internal_type;
285 return internal::bridge::mixed(M(arg));
290 static 인라인 typename std::enable_if_t<!internal::type_info::MixedPersistableConcept<T>::value, T>
291 deserialize(
const internal::bridge::mixed& value) {
292 만약 constexpr (internal::type_info::is_optional<T>::value) {
294 }
else if constexpr (std::is_same_v<T, int64_t>) {
296 }
다른 경우 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 반환 static_cast<std::string
>(value);
300 }
else if constexpr (std::is_same_v<T, std::vector<uint8_t>>) {
301 반환 static_cast<std::vector<uint8_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 반환 static_cast<internal::bridge::timestamp
>(value);
304 }
다른 경우 if constexpr (std::dis Junction_v<std::is_same<T, double>, std::is_same<T, float>>) {
305 반환 static_cast<double>(값);
306 }
else if constexpr (std::is_same_v<T, realm::uuid>) {
307 반환 값. 연산자 internal::bridge::uuid(). 연산자 :: 영역::uuid();
308 }
else if constexpr (std::is_same_v<T, realm::object_id>) {
309 반환 값. 연산자 internal::bridge::object_id(). 연산자 :: 영역::object_id();
310 }
other if constexpr ( std::is_same_v<T, realm::decimal128>) {
311 반환 값. 연산자 internal::bridge::decimal128() . 연산자 :: 영역::decimal128();
312 }
else if constexpr (std::is_enum_v<T>) {
313 반환 static_cast<T
>(value. 연산자 int64_t());
320 static 인라인 typename std::enable_if_t<internal::type_info::MixedPersistableConcept<T>::value, T>
321 deserialize(
const internal::bridge::mixed& value) {
322 if (value.is_null()) {
323 return std::monostate();
326 switch (value.type()) {
327 case internal::bridge::data_type::Int:
329 case internal::bridge::data_type::Bool:
330 return value.operator bool();
331 case internal::bridge::data_type::String:
332 반환 static_cast<std::string
>(value);
333 case internal::bridge::data_type::Binary:
334 반환 static_cast<std::vector<uint8_t>
>(
static_cast<internal::bridge::binary
>(value));
335 case internal::bridge::data_type::Timestamp:
336 반환 static_cast<internal::bridge::timestamp
>(value);
337 case internal::bridge::data_type::Float:
338 case internal::bridge::data_type::Double:
339 반환 static_cast<double>(값);
340 case internal::bridge::data_type::UUID:
341 반환 값. 연산자 internal::bridge::uuid(). 연산자 :: 영역::uuid();
342 case internal::bridge::data_type::ObjectId:
343 반환 값. 연산자 internal::bridge::object_id(). 연산자 :: 영역::object_id();
344 case internal::bridge::data_type::Decimal:
345 반환 값. 연산자 internal::bridge::decimal128(). 연산자 :: 영역::decimal128();
346 case internal::bridge::data_type::TypedLink:
347 throw std::runtime_error(
"혼합 속성에 저장된 객체는 `get_object_value()`를 통해 액세스해야 합니다.");
349 throw std::runtime_error(
"혼합 속성을 역직렬화하는 동안 알 수 없는 데이터 유형입니다.");
정의: managed_dictionary.hpp:31