Loading...
Searching...
No Matches
decimal128.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <bsoncxx/decimal128-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/decimal128.hpp> // IWYU pragma: export
#include <bsoncxx/v1/detail/type_traits.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <cstdint>
#include <string>
#include <bsoncxx/stdx/string_view.hpp>
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
class decimal128 {
private:
v1::decimal128 _d128;
public:
decimal128() = default;
/* explicit(false) */ decimal128(v1::decimal128 const& d128) noexcept : _d128{d128} {}
decimal128(std::uint64_t high, std::uint64_t low) : _d128{high, low} {}
explicit BSONCXX_ABI_EXPORT_CDECL_UNSTABLE() decimal128(v1::stdx::string_view str);
explicit operator v1::decimal128() const noexcept {
return _d128;
}
std::string to_string() const {
return _d128.to_string();
}
std::uint64_t high() const {
return _d128.high();
}
std::uint64_t low() const {
return _d128.low();
}
friend bool operator==(decimal128 const& lhs, decimal128 const& rhs) {
return lhs._d128 == rhs._d128;
}
friend bool operator!=(decimal128 const& lhs, decimal128 const& rhs) {
return lhs._d128 != rhs._d128;
}
};
inline v_noabi::decimal128 from_v1(v1::decimal128 const& v) {
return {v};
}
inline v1::decimal128 to_v1(v_noabi::decimal128 const& v) {
return v1::decimal128{v};
}
} // namespace v_noabi
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
#define BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to BSONCXX_ABI_EXPORT_UNSTABLE with BSONCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::decimal128::decimal128
decimal128()=default
Constructs a BSON Decimal128 value representing zero.
bsoncxx::v1::decimal128
A BSON Decimal128.
Definition decimal128.hpp:37
bsoncxx::v_noabi::decimal128
Represents a MongoDB BSON Decimal128.
Definition decimal128.hpp:45
bsoncxx::v_noabi::decimal128::decimal128
decimal128(std::uint64_t high, std::uint64_t low)
Constructs a BSON Decimal128 from high and low 64-bit big-endian parts.
Definition decimal128.hpp:68
bsoncxx::v_noabi::decimal128::operator!=
friend bool operator!=(decimal128 const &lhs, decimal128 const &rhs)
Equality comparison operator.
Definition decimal128.hpp:125
bsoncxx::v_noabi::decimal128::decimal128
decimal128()=default
Constructs a BSON Decimal128 value representing zero.
bsoncxx::v_noabi::decimal128::decimal128
decimal128(v1::decimal128 const &d128) noexcept
Construct with the bsoncxx::v1 equivalent.
Definition decimal128.hpp:58
bsoncxx::v_noabi::decimal128::to_string
std::string to_string() const
Converts this decimal128 value to a string representation.
Definition decimal128.hpp:93
bsoncxx::v_noabi::decimal128::operator==
friend bool operator==(decimal128 const &lhs, decimal128 const &rhs)
Equality comparison operator.
Definition decimal128.hpp:116
bsoncxx::v_noabi::decimal128::low
std::uint64_t low() const
Accessor for low 64 bits.
Definition decimal128.hpp:107
bsoncxx::v_noabi::decimal128::high
std::uint64_t high() const
Accessor for high 64 bits.
Definition decimal128.hpp:100
bsoncxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
bsoncxx::v_noabi::stdx
Declares C++17 standard library polyfills.
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx::v_noabi::to_v1
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
bsoncxx::v_noabi::from_v1
v_noabi::array::value from_v1(v1::array::value const &v)
Convert from the bsoncxx::v1 equivalent of v.
Definition value.hpp:263
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
decimal128.hpp
Provides bsoncxx::v1::decimal128.
type_traits.hpp
For internal use only!
decimal128-fwd.hpp
Declares bsoncxx::v_noabi::decimal128.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.