StormByte-Database 2.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 noexcept
 Equality of the stored alternatives.
 
bool operator!= (const Value &other) const noexcept
 Inequality.
 
virtual ~Value () noexcept
 Destructor.
 
template<typename T >
requires StormByte::Type::VariantHasType<ValuesVariant, std::decay_t<T>>
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 () noexcept
 Default constructor.
 
 Value (int value) noexcept
 From a signed int.
 
 Value (unsigned int value) noexcept
 From an unsigned int.
 
 Value (long int value) noexcept
 From a signed long int, stored as long long int.
 
 Value (unsigned long int value) noexcept
 From an unsigned long int, stored as unsigned long long int.
 
 Value (long long int value) noexcept
 From a signed long long int.
 
 Value (unsigned long long int value) noexcept
 From an unsigned long long int.
 
 Value (double value) noexcept
 From a double.
 
 Value (std::string_view value) noexcept
 Copy UTF-8 text into a String-owned value.
 
 Value (const StormByte::BinaryData &value)
 Copy a blob into Base-owned storage.
 
 Value (StormByte::BinaryData &&value) noexcept
 Move a blob into this value.
 
template<typename T >
requires StormByte::Type::SameAs<std::remove_cvref_t<T>, bool>
 Value (T &&value) noexcept
 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::String::String.

Blob 

StormByte::BinaryData.

Boolean 

bool

Constructor & Destructor Documentation

◆ Value() [1/14]

StormByte::Database::Value::Value ( )
inlinenoexcept

Default constructor.

Stores SQL NULL.

◆ Value() [2/14]

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

From a signed int.

Parameters
valueStored value.

◆ Value() [3/14]

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

From an unsigned int.

Parameters
valueStored value.

◆ Value() [4/14]

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

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

Parameters
valueStored value.

◆ Value() [5/14]

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

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)
inlinenoexcept

From a signed long long int.

Parameters
valueStored value.

◆ Value() [7/14]

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

From an unsigned long long int.

Parameters
valueStored value.

◆ Value() [8/14]

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

From a double.

Parameters
valueStored value.

◆ Value() [9/14]

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

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

Parameters
valueText to store.

◆ Value() [10/14]

StormByte::Database::Value::Value ( const StormByte::BinaryData &  value)

Copy a blob into Base-owned storage.

Parameters
valueStored bytes.

◆ Value() [11/14]

StormByte::Database::Value::Value ( StormByte::BinaryData &&  value)
noexcept

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)
inlinenoexcept

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 StormByte::Type::VariantHasType<ValuesVariant, std::decay_t<T>>
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
inlinenoexcept

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
inlinenoexcept

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: