MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
decimal128.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <cstdint>
18#include <string>
19
21
23
25
26namespace bsoncxx {
27namespace v_noabi {
28
33 public:
37 decimal128() = default;
38
47 decimal128(uint64_t high, uint64_t low) noexcept : _high(high), _low(low) {}
48
58 explicit BSONCXX_ABI_EXPORT_CDECL() decimal128(stdx::string_view str);
59
66
73 friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const decimal128& lhs, const decimal128& rhs);
74 friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const decimal128& lhs, const decimal128& rhs);
77
81 uint64_t high() const {
82 return _high;
83 }
84
88 uint64_t low() const {
89 return _low;
90 }
91
92 private:
93 uint64_t _high = 0;
94 uint64_t _low = 0;
95};
96
97} // namespace v_noabi
98} // namespace bsoncxx
99
101
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
Represents an IEEE 754-2008 BSON Decimal128 value in a platform-independent way.
Definition decimal128.hpp:32
decimal128(uint64_t high, uint64_t low) noexcept
Constructs a BSON Decimal128 from high and low 64-bit big-endian parts.
Definition decimal128.hpp:47
uint64_t high() const
Accessor for high 64 bits.
Definition decimal128.hpp:81
decimal128()=default
Constructs a BSON Decimal128 value representing zero.
std::string to_string() const
Converts this decimal128 value to a string representation.
uint64_t low() const
Accessor for low 64 bits.
Definition decimal128.hpp:88
Declares bsoncxx::v_noabi::decimal128.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition fwd.hpp:225
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace reserved for the C++ standard library.
Provides std::string_view-related polyfills for library API usage.