Lightweight 0.20260303.0
Loading...
Searching...
No Matches
Lightweight::SqlFixedString< N, T, Mode > Class Template Reference

#include <SqlFixedString.hpp>

Public Types

using value_type = T
 The element type of the string.
 
using iterator = T *
 Iterator type for the string.
 
using const_iterator = T const *
 Const iterator type for the string.
 
using pointer_type = T *
 Pointer type for the string.
 
using const_pointer_type = T const *
 Const pointer type for the string.
 

Public Member Functions

template<std::size_t SourceSize>
constexpr LIGHTWEIGHT_FORCE_INLINE SqlFixedString (T const (&text)[SourceSize])
 Constructs a fixed-size string from a string literal.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedString () noexcept=default
 Defaulted default constructor.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedString (SqlFixedString const &) noexcept=default
 Defaulted copy constructor.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedStringoperator= (SqlFixedString const &) noexcept=default
 Defaulted copy assignment operator.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedString (SqlFixedString &&) noexcept=default
 Defaulted move constructor.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedStringoperator= (SqlFixedString &&) noexcept=default
 Defaulted move assignment operator.
 
LIGHTWEIGHT_FORCE_INLINE constexpr ~SqlFixedString () noexcept=default
 Defaulted destructor.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedString (std::basic_string_view< T > s) noexcept
 Constructs a fixed-size string from a string view.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedString (std::basic_string< T > const &s) noexcept
 Constructs a fixed-size string from a string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedString (T const *s, std::size_t len) noexcept
 Constructs a fixed-size string from a string pointer and length.
 
LIGHTWEIGHT_FORCE_INLINE constexpr SqlFixedString (T const *s, T const *e) noexcept
 Constructs a fixed-size string from a string pointer and end pointer.
 
LIGHTWEIGHT_FORCE_INLINE void reserve (std::size_t capacity)
 Reserves capacity for the string. Throws if capacity exceeds the maximum.
 
LIGHTWEIGHT_FORCE_INLINE constexpr bool empty () const noexcept
 Tests if the string is empty.
 
LIGHTWEIGHT_FORCE_INLINE constexpr std::size_t size () const noexcept
 Returns the size of the string.
 
LIGHTWEIGHT_FORCE_INLINE void setsize (std::size_t n) noexcept
 Sets the size of the string, capped at the maximum capacity.
 
LIGHTWEIGHT_FORCE_INLINE constexpr void resize (std::size_t n) noexcept
 
LIGHTWEIGHT_FORCE_INLINE constexpr std::size_t capacity () const noexcept
 Returns the maximum capacity of the string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr void clear () noexcept
 Clears the string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr void push_back (T c) noexcept
 Appends a character to the string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr void pop_back () noexcept
 Removes the last character from the string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string_view< T > substr (std::size_t offset=0, std::size_t count=(std::numeric_limits< std::size_t >::max)()) const noexcept
 Returns a sub string of the string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string_view< T > str () const noexcept
 Returns a string view of the string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr pointer_type data () noexcept
 Returns a pointer to the underlying mutable data.
 
LIGHTWEIGHT_FORCE_INLINE constexpr iterator begin () noexcept
 Returns a mutable iterator to the beginning.
 
LIGHTWEIGHT_FORCE_INLINE constexpr iterator end () noexcept
 Returns a mutable iterator to the end.
 
LIGHTWEIGHT_FORCE_INLINE constexpr T & operator[] (std::size_t i) noexcept
 Returns a mutable reference to the element at the given index.
 
LIGHTWEIGHT_FORCE_INLINE constexpr const_pointer_type c_str () const noexcept
 Returns a pointer to the null-terminated C string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr const_pointer_type data () const noexcept
 Returns a const pointer to the underlying data.
 
LIGHTWEIGHT_FORCE_INLINE constexpr const_iterator begin () const noexcept
 Returns a const iterator to the beginning.
 
LIGHTWEIGHT_FORCE_INLINE constexpr const_iterator end () const noexcept
 Returns a const iterator to the end.
 
LIGHTWEIGHT_FORCE_INLINE constexpr T const & operator[] (std::size_t i) const noexcept
 Returns a const reference to the element at the given index.
 
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string< T > ToString () const noexcept
 Returns a std::basic_string<T> from the string.
 
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string_view< T > ToStringView () const noexcept
 Returns a std::basic_string_view<T> from the string.
 
template<std::size_t OtherSize, SqlFixedStringMode OtherMode>
LIGHTWEIGHT_FORCE_INLINE std::weak_ordering operator<=> (SqlFixedString< OtherSize, T, OtherMode > const &other) const noexcept
 Three-way comparison operator.
 
template<std::size_t OtherSize, SqlFixedStringMode OtherMode>
LIGHTWEIGHT_FORCE_INLINE constexpr bool operator== (SqlFixedString< OtherSize, T, OtherMode > const &other) const noexcept
 Equality comparison operator.
 
template<std::size_t OtherSize, SqlFixedStringMode OtherMode>
LIGHTWEIGHT_FORCE_INLINE constexpr bool operator!= (SqlFixedString< OtherSize, T, OtherMode > const &other) const noexcept
 Inequality comparison operator.
 
LIGHTWEIGHT_FORCE_INLINE constexpr bool operator== (std::basic_string_view< T > other) const noexcept
 Equality comparison with a string view.
 
LIGHTWEIGHT_FORCE_INLINE constexpr bool operator!= (std::basic_string_view< T > other) const noexcept
 Inequality comparison with a string view.
 

Static Public Attributes

static constexpr std::size_t Capacity = N
 The specified width of the string, which is also the maximum size of the string.
 
static constexpr SqlFixedStringMode PostRetrieveOperation = Mode
 

Detailed Description

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
class Lightweight::SqlFixedString< N, T, Mode >

SQL fixed-capacity string that mimmicks standard library string/string_view with a fixed-size underlying buffer.

The underlying storage will not be guaranteed to be \0-terminated unless a call to mutable/const c_str() has been performed.

Definition at line 40 of file SqlFixedString.hpp.

Member Typedef Documentation

◆ value_type

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
using Lightweight::SqlFixedString< N, T, Mode >::value_type = T

The element type of the string.

Definition at line 48 of file SqlFixedString.hpp.

◆ iterator

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
using Lightweight::SqlFixedString< N, T, Mode >::iterator = T*

Iterator type for the string.

Definition at line 51 of file SqlFixedString.hpp.

◆ const_iterator

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
using Lightweight::SqlFixedString< N, T, Mode >::const_iterator = T const*

Const iterator type for the string.

Definition at line 54 of file SqlFixedString.hpp.

◆ pointer_type

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
using Lightweight::SqlFixedString< N, T, Mode >::pointer_type = T*

Pointer type for the string.

Definition at line 57 of file SqlFixedString.hpp.

◆ const_pointer_type

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
using Lightweight::SqlFixedString< N, T, Mode >::const_pointer_type = T const*

Const pointer type for the string.

Definition at line 60 of file SqlFixedString.hpp.

Constructor & Destructor Documentation

◆ SqlFixedString() [1/5]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
template<std::size_t SourceSize>
constexpr LIGHTWEIGHT_FORCE_INLINE Lightweight::SqlFixedString< N, T, Mode >::SqlFixedString ( T const (&)  text[SourceSize])
inlineconstexpr

Constructs a fixed-size string from a string literal.

Definition at line 71 of file SqlFixedString.hpp.

◆ SqlFixedString() [2/5]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlFixedString< N, T, Mode >::SqlFixedString ( std::basic_string_view< T >  s)
inlineconstexprnoexcept

Constructs a fixed-size string from a string view.

Definition at line 97 of file SqlFixedString.hpp.

◆ SqlFixedString() [3/5]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlFixedString< N, T, Mode >::SqlFixedString ( std::basic_string< T > const &  s)
inlineconstexprnoexcept

Constructs a fixed-size string from a string.

Definition at line 104 of file SqlFixedString.hpp.

◆ SqlFixedString() [4/5]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlFixedString< N, T, Mode >::SqlFixedString ( T const *  s,
std::size_t  len 
)
inlineconstexprnoexcept

Constructs a fixed-size string from a string pointer and length.

Definition at line 111 of file SqlFixedString.hpp.

◆ SqlFixedString() [5/5]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr Lightweight::SqlFixedString< N, T, Mode >::SqlFixedString ( T const *  s,
T const *  e 
)
inlineconstexprnoexcept

Constructs a fixed-size string from a string pointer and end pointer.

Definition at line 118 of file SqlFixedString.hpp.

Member Function Documentation

◆ reserve()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE void Lightweight::SqlFixedString< N, T, Mode >::reserve ( std::size_t  capacity)
inline

Reserves capacity for the string. Throws if capacity exceeds the maximum.

Definition at line 125 of file SqlFixedString.hpp.

References Lightweight::SqlFixedString< N, T, Mode >::capacity().

◆ empty()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr bool Lightweight::SqlFixedString< N, T, Mode >::empty ( ) const
inlineconstexprnoexcept

Tests if the string is empty.

Definition at line 132 of file SqlFixedString.hpp.

◆ size()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr std::size_t Lightweight::SqlFixedString< N, T, Mode >::size ( ) const
inlineconstexprnoexcept

◆ setsize()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE void Lightweight::SqlFixedString< N, T, Mode >::setsize ( std::size_t  n)
inlinenoexcept

Sets the size of the string, capped at the maximum capacity.

Definition at line 145 of file SqlFixedString.hpp.

◆ resize()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr void Lightweight::SqlFixedString< N, T, Mode >::resize ( std::size_t  n)
inlineconstexprnoexcept

Resizes the string.

This sets the size of the string to n. If n is greater than the current size, capped at the maximum capacity.

Definition at line 156 of file SqlFixedString.hpp.

◆ capacity()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr std::size_t Lightweight::SqlFixedString< N, T, Mode >::capacity ( ) const
inlineconstexprnoexcept

Returns the maximum capacity of the string.

Definition at line 164 of file SqlFixedString.hpp.

Referenced by Lightweight::SqlFixedString< N, T, Mode >::reserve().

◆ clear()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr void Lightweight::SqlFixedString< N, T, Mode >::clear ( )
inlineconstexprnoexcept

Clears the string.

Definition at line 170 of file SqlFixedString.hpp.

◆ push_back()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr void Lightweight::SqlFixedString< N, T, Mode >::push_back ( c)
inlineconstexprnoexcept

Appends a character to the string.

Definition at line 192 of file SqlFixedString.hpp.

◆ pop_back()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr void Lightweight::SqlFixedString< N, T, Mode >::pop_back ( )
inlineconstexprnoexcept

Removes the last character from the string.

Definition at line 202 of file SqlFixedString.hpp.

◆ substr()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string_view< T > Lightweight::SqlFixedString< N, T, Mode >::substr ( std::size_t  offset = 0,
std::size_t  count = (std::numeric_limits<std::size_t>::max)() 
) const
inlineconstexprnoexcept

Returns a sub string of the string.

Definition at line 209 of file SqlFixedString.hpp.

Referenced by Lightweight::SqlFixedString< N, T, Mode >::operator==().

◆ str()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string_view< T > Lightweight::SqlFixedString< N, T, Mode >::str ( ) const
inlineconstexprnoexcept

Returns a string view of the string.

Definition at line 222 of file SqlFixedString.hpp.

◆ data() [1/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr pointer_type Lightweight::SqlFixedString< N, T, Mode >::data ( )
inlineconstexprnoexcept

Returns a pointer to the underlying mutable data.

Definition at line 229 of file SqlFixedString.hpp.

◆ begin() [1/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr iterator Lightweight::SqlFixedString< N, T, Mode >::begin ( )
inlineconstexprnoexcept

Returns a mutable iterator to the beginning.

Definition at line 231 of file SqlFixedString.hpp.

◆ end() [1/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr iterator Lightweight::SqlFixedString< N, T, Mode >::end ( )
inlineconstexprnoexcept

Returns a mutable iterator to the end.

Definition at line 233 of file SqlFixedString.hpp.

References Lightweight::SqlFixedString< N, T, Mode >::size().

◆ operator[]() [1/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr T & Lightweight::SqlFixedString< N, T, Mode >::operator[] ( std::size_t  i)
inlineconstexprnoexcept

Returns a mutable reference to the element at the given index.

Definition at line 235 of file SqlFixedString.hpp.

◆ c_str()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr const_pointer_type Lightweight::SqlFixedString< N, T, Mode >::c_str ( ) const
inlineconstexprnoexcept

Returns a pointer to the null-terminated C string.

Definition at line 238 of file SqlFixedString.hpp.

◆ data() [2/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr const_pointer_type Lightweight::SqlFixedString< N, T, Mode >::data ( ) const
inlineconstexprnoexcept

Returns a const pointer to the underlying data.

Definition at line 240 of file SqlFixedString.hpp.

◆ begin() [2/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr const_iterator Lightweight::SqlFixedString< N, T, Mode >::begin ( ) const
inlineconstexprnoexcept

Returns a const iterator to the beginning.

Definition at line 242 of file SqlFixedString.hpp.

◆ end() [2/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr const_iterator Lightweight::SqlFixedString< N, T, Mode >::end ( ) const
inlineconstexprnoexcept

Returns a const iterator to the end.

Definition at line 244 of file SqlFixedString.hpp.

References Lightweight::SqlFixedString< N, T, Mode >::size().

◆ operator[]() [2/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr T const & Lightweight::SqlFixedString< N, T, Mode >::operator[] ( std::size_t  i) const
inlineconstexprnoexcept

Returns a const reference to the element at the given index.

Definition at line 246 of file SqlFixedString.hpp.

◆ ToString()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string< T > Lightweight::SqlFixedString< N, T, Mode >::ToString ( ) const
inlineconstexprnoexcept

Returns a std::basic_string<T> from the string.

Definition at line 250 of file SqlFixedString.hpp.

◆ ToStringView()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr std::basic_string_view< T > Lightweight::SqlFixedString< N, T, Mode >::ToStringView ( ) const
inlineconstexprnoexcept

Returns a std::basic_string_view<T> from the string.

Definition at line 262 of file SqlFixedString.hpp.

◆ operator<=>()

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
template<std::size_t OtherSize, SqlFixedStringMode OtherMode>
LIGHTWEIGHT_FORCE_INLINE std::weak_ordering Lightweight::SqlFixedString< N, T, Mode >::operator<=> ( SqlFixedString< OtherSize, T, OtherMode > const &  other) const
inlinenoexcept

Three-way comparison operator.

Definition at line 275 of file SqlFixedString.hpp.

References Lightweight::SqlFixedString< N, T, Mode >::size().

◆ operator==() [1/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
template<std::size_t OtherSize, SqlFixedStringMode OtherMode>
LIGHTWEIGHT_FORCE_INLINE constexpr bool Lightweight::SqlFixedString< N, T, Mode >::operator== ( SqlFixedString< OtherSize, T, OtherMode > const &  other) const
inlineconstexprnoexcept

Equality comparison operator.

Definition at line 289 of file SqlFixedString.hpp.

◆ operator!=() [1/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
template<std::size_t OtherSize, SqlFixedStringMode OtherMode>
LIGHTWEIGHT_FORCE_INLINE constexpr bool Lightweight::SqlFixedString< N, T, Mode >::operator!= ( SqlFixedString< OtherSize, T, OtherMode > const &  other) const
inlineconstexprnoexcept

Inequality comparison operator.

Definition at line 296 of file SqlFixedString.hpp.

◆ operator==() [2/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr bool Lightweight::SqlFixedString< N, T, Mode >::operator== ( std::basic_string_view< T >  other) const
inlineconstexprnoexcept

Equality comparison with a string view.

Definition at line 302 of file SqlFixedString.hpp.

References Lightweight::SqlFixedString< N, T, Mode >::substr().

◆ operator!=() [2/2]

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
LIGHTWEIGHT_FORCE_INLINE constexpr bool Lightweight::SqlFixedString< N, T, Mode >::operator!= ( std::basic_string_view< T >  other) const
inlineconstexprnoexcept

Inequality comparison with a string view.

Definition at line 308 of file SqlFixedString.hpp.

Member Data Documentation

◆ Capacity

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
constexpr std::size_t Lightweight::SqlFixedString< N, T, Mode >::Capacity = N
staticconstexpr

The specified width of the string, which is also the maximum size of the string.

Definition at line 63 of file SqlFixedString.hpp.

◆ PostRetrieveOperation

template<std::size_t N, typename T = char, SqlFixedStringMode Mode = SqlFixedStringMode::FIXED_SIZE>
constexpr SqlFixedStringMode Lightweight::SqlFixedString< N, T, Mode >::PostRetrieveOperation = Mode
staticconstexpr

Handling mode for the post-retrieval operation that defines how the string should be treated when it is retrieved from the database.

Definition at line 67 of file SqlFixedString.hpp.


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