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

#include <SqlNumeric.hpp>

Public Member Functions

constexpr SqlNumeric (SqlNumeric &&) noexcept=default
 
constexpr SqlNumericoperator= (SqlNumeric &&) noexcept=default
 
constexpr SqlNumeric (SqlNumeric const &) noexcept=default
 
constexpr SqlNumericoperator= (SqlNumeric const &) noexcept=default
 
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 value) 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
 
template<std::size_t OtherPrecision, std::size_t OtherScale>
constexpr LIGHTWEIGHT_FORCE_INLINE bool operator== (SqlNumeric< OtherPrecision, OtherScale > const &other) const noexcept
 

Public Attributes

SQL_NUMERIC_STRUCT sqlValue {}
 The value is stored as a string to avoid floating point precision issues.
 

Static Public Attributes

static constexpr auto ColumnType = SqlColumnTypeDefinitions::Decimal { .precision = ThePrecision, .scale = TheScale }
 
static constexpr auto Precision = ThePrecision
 Number of total digits.
 
static constexpr auto Scale = TheScale
 Number of digits after the decimal point.
 

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 37 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 61 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 67 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  value)
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 93 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 129 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 135 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 141 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

Definition at line 152 of file SqlNumeric.hpp.

◆ 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

Definition at line 158 of file SqlNumeric.hpp.

Member Data Documentation

◆ ColumnType

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

Definition at line 39 of file SqlNumeric.hpp.

◆ 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 42 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

◆ sqlValue

template<std::size_t ThePrecision, std::size_t TheScale>
SQL_NUMERIC_STRUCT Lightweight::SqlNumeric< ThePrecision, TheScale >::sqlValue {}

The value is stored as a string to avoid floating point precision issues.

Definition at line 51 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: