Lightweight 0.20250627.0
Loading...
Searching...
No Matches
Field< T, P1, P2 > Struct Template Reference

Represents a single column in a table. More...

#include <Field.hpp>

Public Types

using ValueType = T
 

Public Member Functions

constexpr Field (Field const &) noexcept=default
 
constexpr Fieldoperator= (Field const &) noexcept=default
 
constexpr Field (Field &&) noexcept=default
 
constexpr Fieldoperator= (Field &&) noexcept=default
 
template<typename... S>
requires std::constructible_from<T, S...>
constexpr Field (S &&... value) noexcept
 Constructs a new field with the given value.
 
template<typename S >
requires std::constructible_from<T, S> && (!std::same_as<std::remove_cvref_t<S>, Field<T, P1, P2>>)
constexpr Fieldoperator= (S &&value) noexcept
 Assigns a new value to the field.
 
constexpr std::weak_ordering operator<=> (Field const &other) const noexcept
 Compares two fields for equality.
 
bool operator== (Field const &value) const noexcept=default
 Compares the field value with the given value for equality.
 
bool operator!= (Field const &value) const noexcept=default
 Compares the field value with the given value for inequality.
 
template<typename S >
requires std::convertible_to<S, T>
bool operator== (S const &value) const noexcept
 Compares the field value with the given value for equality.
 
template<typename S >
requires std::convertible_to<S, T>
bool operator!= (S const &value) const noexcept
 Compares the field value with the given value for inequality.
 
std::string InspectValue () const
 Returns a string representation of the value, suitable for use in debugging and logging.
 
constexpr void SetModified (bool value) noexcept
 Sets the modified state of the field.
 
constexpr bool IsModified () const noexcept
 Checks if the field has been modified.
 
constexpr T const & Value () const noexcept
 Returns the value of the field.
 
constexpr T & MutableValue () noexcept
 
template<typename... S>
requires std::constructible_from<T, S...>
constexpr LIGHTWEIGHT_FORCE_INLINE Field (S &&... value) noexcept
 
template<typename S >
requires std::constructible_from<T, S> && (!std::same_as<std::remove_cvref_t<S>, Field<T, P1, P2>>)
constexpr LIGHTWEIGHT_FORCE_INLINE Field< T, P1, P2 > & operator= (S &&value) noexcept
 
template<typename S >
requires std::convertible_to<S, T>
LIGHTWEIGHT_FORCE_INLINE bool operator== (S const &value) const noexcept
 
template<typename S >
requires std::convertible_to<S, T>
LIGHTWEIGHT_FORCE_INLINE bool operator!= (S const &value) const noexcept
 

Static Public Attributes

static constexpr auto IsPrimaryKeyValue = detail::Choose<PrimaryKey>(PrimaryKey::No, P1, P2)
 
static constexpr auto ColumnNameOverride = detail::Choose<std::string_view>({}, P1, P2)
 
static constexpr auto IsOptional = detail::IsStdOptional<T>
 Indicates if the field is optional, i.e., it can be NULL.
 
static constexpr auto IsMandatory = !IsOptional
 Indicates if the field is mandatory, i.e., it cannot be NULL.
 
static constexpr auto IsPrimaryKey = IsPrimaryKeyValue != PrimaryKey::No
 Indicates if the field is a primary key.
 
static constexpr auto IsAutoAssignPrimaryKey = IsPrimaryKeyValue == PrimaryKey::AutoAssign
 Indicates if this is a primary key, it also is auto-assigned by the client.
 
static constexpr auto IsAutoIncrementPrimaryKey = IsPrimaryKeyValue == PrimaryKey::ServerSideAutoIncrement
 Indicates if this is a primary key, it also is auto-incremented by the database.
 

Detailed Description

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
struct Field< T, P1, P2 >

Represents a single column in a table.

This class is used to represent a single column in a table. It also keeps track of modified-state of the field.

The column name, index, nullability, and type are known at compile time.

See also
DataMapper ,

Definition at line 79 of file Field.hpp.

Member Typedef Documentation

◆ ValueType

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
using Field< T, P1, P2 >::ValueType = T

Definition at line 81 of file Field.hpp.

Constructor & Destructor Documentation

◆ Field()

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
template<typename... S>
requires std::constructible_from<T, S...>
constexpr LIGHTWEIGHT_FORCE_INLINE Field< T, P1, P2 >::Field ( S &&...  value)
constexprnoexcept

Definition at line 208 of file Field.hpp.

Member Function Documentation

◆ operator<=>()

template<detail::FieldElementType T, auto P1, auto P2>
constexpr std::weak_ordering LIGHTWEIGHT_FORCE_INLINE Field< T, P1, P2 >::operator<=> ( Field< T, P1, P2 > const &  other) const
constexprnoexcept

Compares two fields for equality.

Definition at line 224 of file Field.hpp.

◆ InspectValue()

template<detail::FieldElementType T, auto P1, auto P2>
LIGHTWEIGHT_FORCE_INLINE std::string Field< T, P1, P2 >::InspectValue ( ) const
inline

Returns a string representation of the value, suitable for use in debugging and logging.

Definition at line 246 of file Field.hpp.

◆ SetModified()

template<detail::FieldElementType T, auto P1, auto P2>
constexpr LIGHTWEIGHT_FORCE_INLINE void Field< T, P1, P2 >::SetModified ( bool  value)
constexprnoexcept

Sets the modified state of the field.

Definition at line 282 of file Field.hpp.

◆ IsModified()

template<detail::FieldElementType T, auto P1, auto P2>
constexpr LIGHTWEIGHT_FORCE_INLINE bool Field< T, P1, P2 >::IsModified ( ) const
constexprnoexcept

Checks if the field has been modified.

Definition at line 288 of file Field.hpp.

Referenced by DataMapper::IsModified().

◆ Value()

template<detail::FieldElementType T, auto P1, auto P2>
constexpr LIGHTWEIGHT_FORCE_INLINE T const & Field< T, P1, P2 >::Value ( ) const
constexprnoexcept

Returns the value of the field.

Definition at line 294 of file Field.hpp.

Referenced by DataMapper::Delete().

◆ MutableValue()

template<detail::FieldElementType T, auto P1, auto P2>
constexpr LIGHTWEIGHT_FORCE_INLINE T & Field< T, P1, P2 >::MutableValue ( )
constexprnoexcept

Returns a mutable reference to the value of the field.

Note
If the field value is changed through this method, it will not be automatically marked as modified.

Definition at line 300 of file Field.hpp.

◆ operator=()

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
template<typename S >
requires std::constructible_from<T, S> && (!std::same_as<std::remove_cvref_t<S>, Field<T, P1, P2>>)
constexpr LIGHTWEIGHT_FORCE_INLINE Field< T, P1, P2 > & Field< T, P1, P2 >::operator= ( S &&  value)
constexprnoexcept

Definition at line 216 of file Field.hpp.

◆ operator==()

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
template<typename S >
requires std::convertible_to<S, T>
LIGHTWEIGHT_FORCE_INLINE bool Field< T, P1, P2 >::operator== ( S const &  value) const
inlinenoexcept

Definition at line 232 of file Field.hpp.

◆ operator!=()

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
template<typename S >
requires std::convertible_to<S, T>
LIGHTWEIGHT_FORCE_INLINE bool Field< T, P1, P2 >::operator!= ( S const &  value) const
inlinenoexcept

Definition at line 240 of file Field.hpp.

Member Data Documentation

◆ IsPrimaryKeyValue

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
constexpr auto Field< T, P1, P2 >::IsPrimaryKeyValue = detail::Choose<PrimaryKey>(PrimaryKey::No, P1, P2)
staticconstexpr

Definition at line 83 of file Field.hpp.

◆ ColumnNameOverride

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
constexpr auto Field< T, P1, P2 >::ColumnNameOverride = detail::Choose<std::string_view>({}, P1, P2)
staticconstexpr

Definition at line 84 of file Field.hpp.

◆ IsOptional

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
constexpr auto Field< T, P1, P2 >::IsOptional = detail::IsStdOptional<T>
staticconstexpr

Indicates if the field is optional, i.e., it can be NULL.

Definition at line 107 of file Field.hpp.

◆ IsMandatory

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
constexpr auto Field< T, P1, P2 >::IsMandatory = !IsOptional
staticconstexpr

Indicates if the field is mandatory, i.e., it cannot be NULL.

Definition at line 110 of file Field.hpp.

◆ IsPrimaryKey

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
constexpr auto Field< T, P1, P2 >::IsPrimaryKey = IsPrimaryKeyValue != PrimaryKey::No
staticconstexpr

Indicates if the field is a primary key.

Definition at line 113 of file Field.hpp.

◆ IsAutoAssignPrimaryKey

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
constexpr auto Field< T, P1, P2 >::IsAutoAssignPrimaryKey = IsPrimaryKeyValue == PrimaryKey::AutoAssign
staticconstexpr

Indicates if this is a primary key, it also is auto-assigned by the client.

Definition at line 116 of file Field.hpp.

◆ IsAutoIncrementPrimaryKey

template<detail::FieldElementType T, auto P1 = std::nullopt, auto P2 = std::nullopt>
constexpr auto Field< T, P1, P2 >::IsAutoIncrementPrimaryKey = IsPrimaryKeyValue == PrimaryKey::ServerSideAutoIncrement
staticconstexpr

Indicates if this is a primary key, it also is auto-incremented by the database.

Definition at line 119 of file Field.hpp.


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