Hyper API for C++
0.0.16638
Hyper client library for C++ applications
|
Go to the documentation of this file.
5 #ifndef TABLEAU_HYPER_NUMERIC_HPP
6 #define TABLEAU_HYPER_NUMERIC_HPP
12 #include <type_traits>
13 #include <hyperapi/hyperapi.h>
15 class BigNumeric_rawValue_Test;
16 class Numeric_rawValue_Test;
21 struct hash<hyper_data128_t> {
24 return hash<uint64_t>()(n.data[0]) ^ hash<uint64_t>()(n.data[1]);
31 inline bool operator==(
const hyper_data128_t& a,
const hyper_data128_t& b) noexcept {
return (a.data[0] == b.data[0]) && (a.data[1] == b.data[1]); }
33 inline bool operator>(
const hyper_data128_t& a,
const hyper_data128_t& b) noexcept {
34 if (a.data[1] != b.data[1])
return (static_cast<int64_t>(a.data[1]) > static_cast<int64_t>(b.data[1]));
35 if (a.data[0] != b.data[0])
return (a.data[0] > b.data[0]);
42 template <
unsigned precision_value,
unsigned scale_value>
45 static constexpr
unsigned precision = precision_value;
46 static constexpr
unsigned scale = scale_value;
47 static_assert(precision >= scale,
"The precision of a numeric must be greater or equal than the scale");
48 static_assert(precision <= 38,
"Precision must be at most 38");
49 using data_t =
typename std::conditional<precision <= 18, int64_t, hyper_data128_t>::type;
95 Numeric(
unsigned long long value);
116 template <
unsigned otherPrecision,
unsigned otherScale>
186 friend class ::Numeric_rawValue_Test;
187 friend class ::BigNumeric_rawValue_Test;
188 template <
unsigned otherPrecision,
unsigned otherScale>
191 template <
typename ReturnType>
192 friend struct internal::ValueAccess;
193 friend struct internal::ValueInserter;
194 template <
typename T>
195 friend struct std::hash;
204 explicit Numeric(data_t rawNumeric, raw_t) noexcept
205 : m_value(rawNumeric) {
216 explicit Numeric(int64_t rawNumeric,
unsigned otherPrecision,
unsigned otherScale, raw_t);
226 explicit Numeric(hyper_data128_t rawNumeric,
unsigned otherPrecision,
unsigned otherScale, raw_t);
237 template <
unsigned p,
unsigned s>
241 return std::hash<typename hyperapi::Numeric<p, s>::data_t>()(n.m_value);
246 #include <hyperapi/impl/Numeric.impl.hpp>
double doubleValue() const noexcept
Gets a double representation of this value; may lose accuracy.
friend bool operator!=(const Numeric &a, const Numeric &b) noexcept
Not equal operator.
friend std::ostream & operator<<(std::ostream &os, const Numeric &obj)
Stream output operator.
friend bool operator<=(const Numeric &a, const Numeric &b) noexcept
Less than or equal operator.
std::string stringValue() const
Gets an exact string representation, which is round-trip compatible with the constructor,...
Describes an object that can refer to a constant, contiguous sequence of char-like objects.
bool operator>(const DatabaseName &a, const DatabaseName &b) noexcept
Greater operator.
friend bool operator<(const Numeric &a, const Numeric &b) noexcept
Less than operator.
friend bool operator>(const Numeric &a, const Numeric &b) noexcept
Greater operator.
int64_t intValue() const
Gets an integer representation of this value; if the value has fraction digits, these will be truncat...
friend bool operator>=(const Numeric &a, const Numeric &b) noexcept
Greater or equal operator.
bool operator==(const DatabaseName &a, const DatabaseName &b) noexcept
Equality operator.
A fixed-point numeric data value with scale fraction digits and precision digits overall.
The primary namespace of the Hyper API for C++.
friend bool operator==(const Numeric &a, const Numeric &b) noexcept
Equality operator.
size_t operator()(hyperapi::Numeric< p, s > n) const noexcept
Calculates the hash value of the given numeric.
Numeric() noexcept
Default constructor.
size_t operator()(hyper_data128_t n) const noexcept
Calculates the hash value of the given hyper_data128_t.
std::string toString() const
Gets a string representation for debugging.