Realm C++ SDK Version v2.2.0

decimal128.hpp

1
2//
3// Copyright 2024 Realm Inc.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef CPPREALM_BRIDGE_DECIMAL128_HPP
20#define CPPREALM_BRIDGE_DECIMAL128_HPP
21
22#include <cpprealm/internal/bridge/utils.hpp>
23
24namespace realm {
25 struct decimal128;
26 class Decimal128;
27}
28
29namespace realm::internal::bridge {
30 struct decimal128 {
31 decimal128() = default;
32 decimal128(const decimal128& other) ;
33 decimal128& operator=(const decimal128& other) ;
34 decimal128(decimal128&& other);
35 decimal128& operator=(decimal128&& other);
36 ~decimal128() = default;
37 decimal128(const Decimal128&); //NOLINT(google-explicit-constructor);
38 explicit decimal128(const std::string&);
39 decimal128(const double&);
40 decimal128(const struct ::realm::decimal128&); //NOLINT(google-explicit-constructor);
41 operator Decimal128() const; //NOLINT(google-explicit-constructor);
42 operator ::realm::decimal128() const; //NOLINT(google-explicit-constructor);
43 std::string to_string() const;
44 bool is_NaN() const;
45
46 decimal128 operator+(const decimal128& o);
47 decimal128 operator*(const decimal128& o);
48 decimal128 operator/(const decimal128& o);
49 decimal128 operator-(const decimal128& o);
50
51 decimal128& operator+=(const decimal128& o);
52 decimal128& operator*=(const decimal128& o);
53 decimal128& operator/=(const decimal128& o);
54 decimal128& operator-=(const decimal128& o);
55 private:
56 uint64_t m_decimal[2];
57
58 friend bool operator ==(const decimal128&, const decimal128&);
59 friend bool operator !=(const decimal128&, const decimal128&);
60 friend bool operator >(const decimal128&, const decimal128&);
61 friend bool operator <(const decimal128&, const decimal128&);
62 friend bool operator >=(const decimal128&, const decimal128&);
63 friend bool operator <=(const decimal128&, const decimal128&);
64 };
65
66 bool operator ==(const decimal128&, const decimal128&);
67 bool operator !=(const decimal128&, const decimal128&);
68 bool operator >(const decimal128&, const decimal128&);
69 bool operator <(const decimal128&, const decimal128&);
70 bool operator >=(const decimal128&, const decimal128&);
71 bool operator <=(const decimal128&, const decimal128&);
72}
73
74#endif //CPPREALM_BRIDGE_DECIMAL128_HPP
Definition: decimal128.hpp:30