Lightweight 0.20260303.0
Loading...
Searching...
No Matches
Lightweight::SqlNumeric< ThePrecision, TheScale > Struct Template Reference

#include <SqlNumeric.hpp>

Public Member Functions

constexpr SqlNumeric () noexcept=default
 Default constructor.
 
constexpr SqlNumeric (SqlNumeric &&) noexcept=default
 Move constructor.
 
constexpr SqlNumericoperator= (SqlNumeric &&) noexcept=default
 Move assignment operator.
 
constexpr SqlNumeric (SqlNumeric const &) noexcept=default
 Copy constructor.
 
constexpr SqlNumericoperator= (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 SqlNumericoperator= (std::floating_point auto value) noexcept
 Assigns a floating point value to the numeric.
 
constexpr LIGHTWEIGHT_FORCE_INLINE auto ToUnscaledValue () const noexcept
 Converts the numeric to an unscaled integer value.
 
constexpr LIGHTWEIGHT_FORCE_INLINE float ToFloat () const noexcept
 Converts the numeric to a floating point value.
 
constexpr LIGHTWEIGHT_FORCE_INLINE double ToDouble () const noexcept
 Converts the numeric to a double precision floating point value.
 
constexpr LIGHTWEIGHT_FORCE_INLINE long double ToLongDouble () const noexcept
 Converts the numeric to a long double precision floating point value.
 
constexpr LIGHTWEIGHT_FORCE_INLINE operator float () const noexcept
 Converts the numeric to a floating point value.
 
constexpr LIGHTWEIGHT_FORCE_INLINE operator double () const noexcept
 Converts the numeric to a double precision floating point value.
 
constexpr 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
 Converts the numeric to a string.
 
constexpr LIGHTWEIGHT_FORCE_INLINE std::weak_ordering operator<=> (SqlNumeric const &other) const noexcept
 Three-way comparison operator.
 
template<std::size_t OtherPrecision, std::size_t OtherScale>
constexpr 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.
 

Detailed Description

template<std::size_t ThePrecision, std::size_t TheScale>
struct Lightweight::SqlNumeric< ThePrecision, TheScale >

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.

Definition at line 38 of file SqlNumeric.hpp.

Constructor & Destructor Documentation

◆ SqlNumeric() [1/2]

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr Lightweight::SqlNumeric< ThePrecision, TheScale >::SqlNumeric ( std::floating_point auto  value)
inlineconstexprnoexcept

Constructs a numeric from a floating point value.

Definition at line 71 of file SqlNumeric.hpp.

References Lightweight::SqlNumeric< ThePrecision, TheScale >::assign().

◆ SqlNumeric() [2/2]

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr Lightweight::SqlNumeric< ThePrecision, TheScale >::SqlNumeric ( SQL_NUMERIC_STRUCT const &  value)
inlineexplicitconstexprnoexcept

Constructs a numeric from a SQL_NUMERIC_STRUCT.

Definition at line 77 of file SqlNumeric.hpp.

Member Function Documentation

◆ assign()

template<std::size_t ThePrecision, std::size_t TheScale>
LIGHTWEIGHT_FORCE_INLINE constexpr void Lightweight::SqlNumeric< ThePrecision, TheScale >::assign ( std::floating_point auto  inputValue)
inlineconstexprnoexcept

◆ operator=()

template<std::size_t ThePrecision, std::size_t TheScale>
LIGHTWEIGHT_FORCE_INLINE constexpr SqlNumeric & Lightweight::SqlNumeric< ThePrecision, TheScale >::operator= ( std::floating_point auto  value)
inlineconstexprnoexcept

Assigns a floating point value to the numeric.

Definition at line 106 of file SqlNumeric.hpp.

References Lightweight::SqlNumeric< ThePrecision, TheScale >::assign().

◆ ToUnscaledValue()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE auto Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue ( ) const
inlineconstexprnoexcept

◆ ToFloat()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE float Lightweight::SqlNumeric< ThePrecision, TheScale >::ToFloat ( ) const
inlineconstexprnoexcept

◆ ToDouble()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE double Lightweight::SqlNumeric< ThePrecision, TheScale >::ToDouble ( ) const
inlineconstexprnoexcept

◆ ToLongDouble()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE long double Lightweight::SqlNumeric< ThePrecision, TheScale >::ToLongDouble ( ) const
inlineconstexprnoexcept

◆ operator float()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE Lightweight::SqlNumeric< ThePrecision, TheScale >::operator float ( ) const
inlineexplicitconstexprnoexcept

Converts the numeric to a floating point value.

Definition at line 152 of file SqlNumeric.hpp.

References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToFloat().

◆ operator double()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE Lightweight::SqlNumeric< ThePrecision, TheScale >::operator double ( ) const
inlineexplicitconstexprnoexcept

Converts the numeric to a double precision floating point value.

Definition at line 158 of file SqlNumeric.hpp.

References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToDouble().

◆ operator long double()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE Lightweight::SqlNumeric< ThePrecision, TheScale >::operator long double ( ) const
inlineexplicitconstexprnoexcept

Converts the numeric to a long double precision floating point value.

Definition at line 164 of file SqlNumeric.hpp.

References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToLongDouble().

◆ ToString()

template<std::size_t ThePrecision, std::size_t TheScale>
LIGHTWEIGHT_FORCE_INLINE std::string Lightweight::SqlNumeric< ThePrecision, TheScale >::ToString ( ) const
inline

◆ operator<=>()

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr LIGHTWEIGHT_FORCE_INLINE std::weak_ordering Lightweight::SqlNumeric< ThePrecision, TheScale >::operator<=> ( SqlNumeric< ThePrecision, TheScale > const &  other) const
inlineconstexprnoexcept

Three-way comparison operator.

Definition at line 176 of file SqlNumeric.hpp.

References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToDouble().

◆ operator==()

template<std::size_t ThePrecision, std::size_t TheScale>
template<std::size_t OtherPrecision, std::size_t OtherScale>
constexpr LIGHTWEIGHT_FORCE_INLINE bool Lightweight::SqlNumeric< ThePrecision, TheScale >::operator== ( SqlNumeric< OtherPrecision, OtherScale > const &  other) const
inlineconstexprnoexcept

Equality comparison operator.

Definition at line 183 of file SqlNumeric.hpp.

References Lightweight::SqlNumeric< ThePrecision, TheScale >::ToFloat().

Member Data Documentation

◆ Precision

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr auto Lightweight::SqlNumeric< ThePrecision, TheScale >::Precision = ThePrecision
staticconstexpr

Number of total digits.

Definition at line 41 of file SqlNumeric.hpp.

Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::assign().

◆ Scale

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr auto Lightweight::SqlNumeric< ThePrecision, TheScale >::Scale = TheScale
staticconstexpr

◆ ColumnType

template<std::size_t ThePrecision, std::size_t TheScale>
constexpr auto Lightweight::SqlNumeric< ThePrecision, TheScale >::ColumnType = SqlColumnTypeDefinitions::Decimal { .precision = Precision, .scale = TheScale }
staticconstexpr

The SQL column type definition for this numeric type.

Definition at line 47 of file SqlNumeric.hpp.

◆ sqlValue

◆ nativeValue

template<std::size_t ThePrecision, std::size_t TheScale>
double Lightweight::SqlNumeric< ThePrecision, TheScale >::nativeValue {}

Cached native value for drivers without SQL_NUMERIC_STRUCT support.

Definition at line 56 of file SqlNumeric.hpp.

Referenced by Lightweight::SqlNumeric< ThePrecision, TheScale >::assign(), and Lightweight::SqlNumeric< ThePrecision, TheScale >::ToUnscaledValue().


The documentation for this struct was generated from the following file: