|
Lightweight 0.20260625.0
|
#include <SqlNumeric.hpp>
Public Member Functions | |
| constexpr | SqlNumeric () noexcept=default |
| Default constructor. | |
| constexpr | SqlNumeric (SqlNumeric &&) noexcept=default |
| Move constructor. | |
| constexpr SqlNumeric & | operator= (SqlNumeric &&) noexcept=default |
| Move assignment operator. | |
| constexpr | SqlNumeric (SqlNumeric const &) noexcept=default |
| Copy constructor. | |
| constexpr SqlNumeric & | operator= (SqlNumeric const &) noexcept=default |
| Copy assignment operator. | |
| constexpr | SqlNumeric (std::floating_point auto value) noexcept |
| Constructs a numeric from a floating point value. | |
| constexpr | SqlNumeric (SQL_NUMERIC_STRUCT const &value) noexcept |
| Constructs a numeric from a SQL_NUMERIC_STRUCT. | |
| LIGHTWEIGHT_FORCE_INLINE constexpr void | assign (std::floating_point auto inputValue) noexcept |
| Assigns a value to the numeric. | |
| LIGHTWEIGHT_FORCE_INLINE constexpr SqlNumeric & | operator= (std::floating_point auto value) noexcept |
| Assigns a floating point value to the numeric. | |
| LIGHTWEIGHT_FORCE_INLINE Int128 | ToUnscaledValue () const noexcept |
| LIGHTWEIGHT_FORCE_INLINE float | ToFloat () const noexcept |
| Converts the numeric to a floating point value. | |
| LIGHTWEIGHT_FORCE_INLINE double | ToDouble () const noexcept |
| Converts the numeric to a double precision floating point value. | |
| LIGHTWEIGHT_FORCE_INLINE long double | ToLongDouble () const noexcept |
| Converts the numeric to a long double precision floating point value. | |
| LIGHTWEIGHT_FORCE_INLINE | operator float () const noexcept |
| Converts the numeric to a floating point value. | |
| LIGHTWEIGHT_FORCE_INLINE | operator double () const noexcept |
| Converts the numeric to a double precision floating point value. | |
| LIGHTWEIGHT_FORCE_INLINE | operator long double () const noexcept |
| Converts the numeric to a long double precision floating point value. | |
| LIGHTWEIGHT_FORCE_INLINE std::string | ToString () const |
| LIGHTWEIGHT_FORCE_INLINE std::partial_ordering | operator<=> (SqlNumeric const &other) const noexcept |
| template<std::size_t OtherPrecision, std::size_t OtherScale> | |
| LIGHTWEIGHT_FORCE_INLINE bool | operator== (SqlNumeric< OtherPrecision, OtherScale > const &other) const noexcept |
| Equality comparison operator. | |
Public Attributes | |
| SQL_NUMERIC_STRUCT | sqlValue {} |
| The SQL numeric struct for ODBC binding. | |
| double | nativeValue {} |
| Cached native value for drivers without SQL_NUMERIC_STRUCT support. | |
Static Public Attributes | |
| static constexpr auto | Precision = ThePrecision |
| Number of total digits. | |
| static constexpr auto | Scale = TheScale |
| Number of digits after the decimal point. | |
| static constexpr auto | ColumnType = SqlColumnTypeDefinitions::Decimal { .precision = Precision, .scale = TheScale } |
| The SQL column type definition for this numeric type. | |
Represents a fixed-point number with a given precision and scale.
Precision is exactly the total number of digits in the number, including the digits after the decimal point.
Scale is the number of digits after the decimal point, and may be anywhere in [0, Precision]. Scale == Precision denotes a purely fractional number, e.g. SqlNumeric<4, 4> covers [0.0000, 0.9999] — the C++ equivalent of SQL's DECIMAL(4, 4).
Definition at line 94 of file SqlNumeric.hpp.
|
inlineconstexprnoexcept |
Constructs a numeric from a floating point value.
Definition at line 138 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::assign().
|
inlineexplicitconstexprnoexcept |
Constructs a numeric from a SQL_NUMERIC_STRUCT.
Definition at line 144 of file SqlNumeric.hpp.
|
inlineconstexprnoexcept |
Assigns a value to the numeric.
Definition at line 153 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::nativeValue, Lightweight::SqlNumeric< ThePrecision, TheScale >::Precision, Lightweight::SqlNumeric< ThePrecision, TheScale >::Scale, and Lightweight::SqlNumeric< ThePrecision, TheScale >::sqlValue.
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::operator=(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::SqlNumeric().
|
inlineconstexprnoexcept |
Assigns a floating point value to the numeric.
Definition at line 172 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::assign().
|
inlinenoexcept |
Converts the numeric to an unscaled integer value.
Along with ToString(), which renders from this value, it is one of the two accessors that do not divide through a floating-point type, and therefore carries every digit up to SqlMaxNumericPrecision on every toolchain. The floating-point accessors do not.
value * 10^Scale as a signed 128-bit integer. Definition at line 185 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::nativeValue, Lightweight::SqlNumeric< ThePrecision, TheScale >::Scale, and Lightweight::SqlNumeric< ThePrecision, TheScale >::sqlValue.
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::ToDouble(), Lightweight::SqlNumeric< ThePrecision, TheScale >::ToFloat(), Lightweight::SqlNumeric< ThePrecision, TheScale >::ToLongDouble(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToString().
|
inlinenoexcept |
Converts the numeric to a floating point value.
Definition at line 200 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::sqlValue, and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::operator float(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::operator==().
|
inlinenoexcept |
Converts the numeric to a double precision floating point value.
Definition at line 206 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::sqlValue, and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::operator double(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::operator<=>().
|
inlinenoexcept |
Converts the numeric to a long double precision floating point value.
Definition at line 212 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::sqlValue, and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::operator long double().
|
inlineexplicitnoexcept |
Converts the numeric to a floating point value.
Definition at line 218 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToFloat().
|
inlineexplicitnoexcept |
Converts the numeric to a double precision floating point value.
Definition at line 224 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToDouble().
|
inlineexplicitnoexcept |
Converts the numeric to a long double precision floating point value.
Definition at line 230 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToLongDouble().
|
inline |
Converts the numeric to a string, exactly.
Rendered from the unscaled integer rather than by formatting ToLongDouble(), so every digit the carrier holds survives on every toolchain. Formatting through long double would drop the low digits wherever that type is narrow (53 bits on MSVC and on Clang for Apple Silicon) or wherever the standard library's formatter narrows to double regardless.
Scale fractional digits. Definition at line 243 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::Scale, and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().
|
inlinenoexcept |
Three-way comparison operator.
Comparing two SqlNumeric values yields std::partial_ordering because the underlying conversion to double admits NaN inputs. In practice every value produced by this type is finite, so the result is totally ordered.
Definition at line 270 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToDouble().
|
inlinenoexcept |
Equality comparison operator.
Definition at line 277 of file SqlNumeric.hpp.
References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToFloat().
|
staticconstexpr |
Number of total digits.
Definition at line 97 of file SqlNumeric.hpp.
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::assign().
|
staticconstexpr |
Number of digits after the decimal point.
Definition at line 100 of file SqlNumeric.hpp.
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::assign(), Lightweight::SqlNumeric< ThePrecision, TheScale >::ToString(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().
|
staticconstexpr |
The SQL column type definition for this numeric type.
Definition at line 103 of file SqlNumeric.hpp.
| SQL_NUMERIC_STRUCT Lightweight::SqlNumeric< ThePrecision, TheScale >::sqlValue {} |
The SQL numeric struct for ODBC binding.
Definition at line 120 of file SqlNumeric.hpp.
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::assign(), Lightweight::SqlNumeric< ThePrecision, TheScale >::ToDouble(), Lightweight::SqlNumeric< ThePrecision, TheScale >::ToFloat(), Lightweight::SqlNumeric< ThePrecision, TheScale >::ToLongDouble(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().
| double Lightweight::SqlNumeric< ThePrecision, TheScale >::nativeValue {} |
Cached native value for drivers without SQL_NUMERIC_STRUCT support.
Definition at line 123 of file SqlNumeric.hpp.
Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::assign(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().