StormByte-Database 3.0.0
C++26 database module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Database::Value Class Reference

Type-erased SQL value (NULL, integers, double, text, blob, bool). More...

#include <StormByte/database/value.hxx>

Inheritance diagram for StormByte::Database::Value:

Public Types

enum class  Type : unsigned short {
  Null = 0 , Integer , UnsignedInteger , LongInteger ,
  UnsignedLongInteger , Double , Text , Blob ,
  Boolean
}
 Discriminator for the stored alternative. More...

Public Member Functions

 Value (const Value &other)
 Copy constructor.
 Value (Value &&other) noexcept
 Move constructor.
Value & operator= (const Value &other)
 Copy assignment.
Value & operator= (Value &&other) noexcept
 Move assignment.
bool operator== (const Value &other) const
 Equality of the stored alternatives.
bool operator!= (const Value &other) const
 Inequality.
virtual ~Value () noexcept
 Destructor.
template<typename T>
requires (ValuesVariant::AlternativeIndex<std::decay_t<T>>() != ValuesVariant::npos)
std::decay_t< T > Get () const
 Stored value as T, with safe numeric conversions.
Type Type () const noexcept
 Discriminator of the stored alternative.
bool IsNull () const noexcept
 Whether the value is SQL NULL.
Construction
 Value ()
 Default constructor.
 Value (int value)
 From a signed int.
 Value (unsigned int value)
 From an unsigned int.
 Value (long int value)
 From a signed long int, stored as long long int.
 Value (unsigned long int value)
 From an unsigned long int, stored as unsigned long long int.
 Value (long long int value)
 From a signed long long int.
 Value (unsigned long long int value)
 From an unsigned long long int.
 Value (double value)
 From a double.
 Value (std::string_view value)
 Copy UTF-8 text into a String-owned value.
 Value (const StormByte::Safe::Binary &value)
 Copy a blob into Base-owned storage.
 Value (StormByte::Safe::Binary &&value)
 Move a blob into this value.
template<typename T>
requires StormByte::Type::SameAs<std::remove_cvref_t<T>, bool>
 Value (T &&value)
 From a bool.

Detailed Description

Type-erased SQL value (NULL, integers, double, text, blob, bool).

Member Enumeration Documentation

◆ Type

enum class StormByte::Database::Value::Type : unsigned short
strong

Discriminator for the stored alternative.

Enumerator
Null 

SQL NULL.

Integer 

int

UnsignedInteger 

unsigned int

LongInteger 

long long int (64-bit on every platform)

UnsignedLongInteger 

unsigned long long int (64-bit on every platform)

Double 

double

Text 

StormByte::Safe::String.

Blob 

StormByte::Safe::Binary.

Boolean 

bool

Constructor & Destructor Documentation

◆ Value() [1/14]

StormByte::Database::Value::Value ( )
inline

Default constructor.

Stores SQL NULL.

◆ Value() [2/14]

StormByte::Database::Value::Value ( int value)
inline

From a signed int.

Parameters
valueStored value.

◆ Value() [3/14]

StormByte::Database::Value::Value ( unsigned int value)
inline

From an unsigned int.

Parameters
valueStored value.

◆ Value() [4/14]

StormByte::Database::Value::Value ( long int value)
inline

From a signed long int, stored as long long int.

Parameters
valueStored value.

◆ Value() [5/14]

StormByte::Database::Value::Value ( unsigned long int value)
inline

From an unsigned long int, stored as unsigned long long int.

Parameters
valueStored value.

◆ Value() [6/14]

StormByte::Database::Value::Value ( long long int value)
inline

From a signed long long int.

Parameters
valueStored value.

◆ Value() [7/14]

StormByte::Database::Value::Value ( unsigned long long int value)
inline

From an unsigned long long int.

Parameters
valueStored value.

◆ Value() [8/14]

StormByte::Database::Value::Value ( double value)
inline

From a double.

Parameters
valueStored value.

◆ Value() [9/14]

StormByte::Database::Value::Value ( std::string_view value)

Copy UTF-8 text into a String-owned value.

Parameters
valueText to store.

◆ Value() [10/14]

StormByte::Database::Value::Value ( const StormByte::Safe::Binary & value)

Copy a blob into Base-owned storage.

Parameters
valueStored bytes.

◆ Value() [11/14]

StormByte::Database::Value::Value ( StormByte::Safe::Binary && value)

Move a blob into this value.

Parameters
valueStored bytes.

◆ Value() [12/14]

template<typename T>
requires StormByte::Type::SameAs<std::remove_cvref_t<T>, bool>
StormByte::Database::Value::Value ( T && value)
inline

From a bool.

Parameters
valueStored value.

◆ Value() [13/14]

StormByte::Database::Value::Value ( const Value & other)

Copy constructor.

◆ Value() [14/14]

StormByte::Database::Value::Value ( Value && other)
noexcept

Move constructor.

◆ ~Value()

virtual StormByte::Database::Value::~Value ( )
virtualnoexcept

Destructor.

Member Function Documentation

◆ Get()

template<typename T>
requires (ValuesVariant::AlternativeIndex<std::decay_t<T>>() != ValuesVariant::npos)
std::decay_t< T > StormByte::Database::Value::Get ( ) const
inline

Stored value as T, with safe numeric conversions.

Template Parameters
TRequested type (must be a ValuesVariant alternative).
Returns
Converted value.
Exceptions
WrongValueTypeon mismatch or unsafe conversion.

◆ IsNull()

bool StormByte::Database::Value::IsNull ( ) const
inlinenoexcept

Whether the value is SQL NULL.

Returns
true if NULL.

◆ operator!=()

bool StormByte::Database::Value::operator!= ( const Value & other) const
inline

Inequality.

Parameters
otherOther value.
Returns
true if not equal.

◆ operator=() [1/2]

Value & StormByte::Database::Value::operator= ( const Value & other)

Copy assignment.

◆ operator=() [2/2]

Value & StormByte::Database::Value::operator= ( Value && other)
noexcept

Move assignment.

◆ operator==()

bool StormByte::Database::Value::operator== ( const Value & other) const
inline

Equality of the stored alternatives.

Parameters
otherOther value.
Returns
true if equal.

◆ Type()

Type StormByte::Database::Value::Type ( ) const
inlinenoexcept

Discriminator of the stored alternative.

Returns
Type.

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