StormByte 2.0.0
C++26 foundation of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte Namespace Reference

Root namespace of the StormByte suite. More...

Namespaces

namespace  Detail
 Private specialization point for non-trivial types.
 
namespace  Error
 Error-code domains and the StormByte::Error::Fault value type.
 
namespace  Safe
 Types that are safe to pass across a DLL boundary: owners and polymorphic clones on Base's heap.
 
namespace  String
 
namespace  Test
 
namespace  Type
 Named concepts and small type utilities used across the suite.
 

Classes

class  Base64Error
 Thrown when Base64 encode or decode fails. More...
 
class  BinaryData
 DLL-boundary-safe owned contiguous sequence of std::byte. More...
 
class  Bitmask
 CRTP wrapper that stores an unsigned enum as a flag set. More...
 
class  ByteSize
 Count of octets (uint64_t storage). More...
 
class  Clock
 Stopwatch for measuring execution time of operations. More...
 
class  CString
 Owned NUL-terminated buffer, safe to use across a DLL boundary. More...
 
class  DeserializeError
 Thrown when deserialization fails. More...
 
class  Exception
 Base exception type for the suite. More...
 
class  Iterable
 Wrapper that adds a uniform iteration and mutation API around a standard container. More...
 
class  OutOfBoundsError
 Thrown when an index or range is out of bounds. More...
 
class  Serializable
 Encodes and decodes one value of type T. More...
 
class  Size
 Count of abstract units (uint64_t storage). More...
 
class  Telemetry
 Abstract session telemetry base with a protected clock drawer. More...
 
class  ThreadLock
 Mutex with owner-thread reentry. More...
 
class  WCString
 Owned NUL-terminated wide buffer, safe to use across a DLL boundary. More...
 

Typedefs

template<typename T , class E >
using Expected = std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, Safe::Shared< E > >, std::expected< T, Safe::Shared< E > > >
 std::expected alias with reference and shared-error handling.
 

Functions

BinaryData Base64Decode (std::string_view input)
 Decodes Base64 text into bytes.
 
CString Base64Encode (const BinaryData &input)
 Encodes bytes as Base64 with = padding.
 
CString Base64Encode (std::span< const std::byte > input)
 Encodes a contiguous byte span as Base64 with = padding.
 
void swap (BinaryData &lhs, BinaryData &rhs) noexcept
 Exchange two sequences.
 
bool operator== (std::span< const std::byte > bytes, const BinaryData &data) noexcept
 Equality of a span against a sequence.
 
bool operator!= (std::span< const std::byte > bytes, const BinaryData &data) noexcept
 Inequality of a span against a sequence.
 
std::strong_ordering operator<=> (std::span< const std::byte > bytes, const BinaryData &data) noexcept
 Three-way comparison of a span against a sequence.
 
template<Type::Integral T>
constexpr bool operator== (ByteSize lhs, T rhs) noexcept
 Mixed equality.
 
template<Type::Integral T>
constexpr bool operator== (T lhs, ByteSize rhs) noexcept
 Mixed equality.
 
template<Type::Integral T>
constexpr std::strong_ordering operator<=> (ByteSize lhs, T rhs) noexcept
 Mixed order.
 
template<Type::Integral T>
constexpr std::strong_ordering operator<=> (T lhs, ByteSize rhs) noexcept
 Mixed order.
 
template<Type::Integral T>
constexpr ByteSize operator+ (ByteSize lhs, T rhs) noexcept
 Mixed sum.
 
template<Type::Integral T>
constexpr ByteSize operator+ (T lhs, ByteSize rhs) noexcept
 Mixed sum.
 
template<Type::Integral T>
constexpr ByteSize operator- (ByteSize lhs, T rhs) noexcept
 Mixed difference.
 
template<Type::Integral T>
constexpr ByteSize operator- (T lhs, ByteSize rhs) noexcept
 Mixed difference.
 
template<Type::Integral T>
constexpr ByteSize operator* (ByteSize lhs, T rhs) noexcept
 Mixed product.
 
template<Type::Integral T>
constexpr ByteSize operator* (T lhs, ByteSize rhs) noexcept
 Mixed product.
 
template<Type::Integral T>
constexpr ByteSize operator/ (ByteSize lhs, T rhs) noexcept
 Mixed quotient.
 
template<Type::Integral T>
constexpr ByteSize operator% (ByteSize lhs, T rhs) noexcept
 Mixed remainder.
 
std::ostream & operator<< (std::ostream &stream, ByteSize size)
 Writes the IEC human-readable length.
 
std::ostream & operator<< (std::ostream &stream, const CString &text)
 Writes text to stream.
 
bool operator== (const char *str, const CString &text) noexcept
 Content equality.
 
bool operator!= (const char *str, const CString &text) noexcept
 Content inequality.
 
void swap (CString &left, CString &right) noexcept
 Swaps two buffers.
 
template<typename E >
auto Unexpected (Safe::Shared< E > error)
 Forwards an error already stored by Expected.
 
template<typename E >
auto Unexpected (std::shared_ptr< E >)=delete
 Rejects a std::shared_ptr.
 
template<typename E >
requires ( !requires { typename std::remove_cvref_t<E>::element_type; } || !Type::SameAs<std::remove_cvref_t<E>, Safe::Shared<typename std::remove_cvref_t<E>::element_type>> )
auto Unexpected (E &&error)
 Builds std::unexpected by constructing E.
 
template<typename Base , typename Derived >
requires Type::DerivedFrom<std::decay_t<Derived>, Base> && (!Type::SameAs<Base, std::decay_t<Derived>>)
auto Unexpected (Derived &&error) -> std::unexpected< Safe::Shared< Base > >
 Builds std::unexpected<shared_ptr<Base>> from a Derived instance.
 
template<typename E , typename... Args>
auto Unexpected (const std::string &fmt, Args &&... args)
 Builds std::unexpected from a format string and E(string).
 
void append_bytes (BinaryData &dest, std::span< const std::byte > src) noexcept
 Appends a span of bytes onto a BinaryData.
 
void append_bytes (BinaryData &dest, const BinaryData &src) noexcept
 Appends a BinaryData by copy.
 
void append_bytes (BinaryData &dest, BinaryData &&src) noexcept
 Appends a BinaryData by move on Base's heap.
 
template<typename T , typename U >
requires Type::ConvertibleTo<T, U>
void append_vector (std::vector< T > &dest, std::span< U > src) noexcept
 Appends a span of convertible elements onto a vector.
 
template<typename T >
void append_vector (std::vector< T > &dest, const std::vector< T > &src) noexcept
 Appends a vector by copy.
 
template<typename T >
void append_vector (std::vector< T > &dest, std::vector< T > &&src) noexcept
 Appends a vector by move.
 
template<Type::Integral T>
constexpr bool operator== (Size lhs, T rhs) noexcept
 Mixed equality.
 
template<Type::Integral T>
constexpr bool operator== (T lhs, Size rhs) noexcept
 Mixed equality.
 
template<Type::Integral T>
constexpr std::strong_ordering operator<=> (Size lhs, T rhs) noexcept
 Mixed order.
 
template<Type::Integral T>
constexpr std::strong_ordering operator<=> (T lhs, Size rhs) noexcept
 Mixed order.
 
template<Type::Integral T>
constexpr Size operator+ (Size lhs, T rhs) noexcept
 Mixed sum.
 
template<Type::Integral T>
constexpr Size operator+ (T lhs, Size rhs) noexcept
 Mixed sum.
 
template<Type::Integral T>
constexpr Size operator- (Size lhs, T rhs) noexcept
 Mixed difference.
 
template<Type::Integral T>
constexpr Size operator- (T lhs, Size rhs) noexcept
 Mixed difference.
 
template<Type::Integral T>
constexpr Size operator* (Size lhs, T rhs) noexcept
 Mixed product.
 
template<Type::Integral T>
constexpr Size operator* (T lhs, Size rhs) noexcept
 Mixed product.
 
template<Type::Integral T>
constexpr Size operator/ (Size lhs, T rhs) noexcept
 Mixed quotient.
 
template<Type::Integral T>
constexpr Size operator/ (T lhs, Size rhs) noexcept
 Mixed quotient.
 
template<Type::Integral T>
constexpr Size operator% (Size lhs, T rhs) noexcept
 Mixed remainder.
 
template<Type::Integral T>
constexpr Size operator% (T lhs, Size rhs) noexcept
 Mixed remainder.
 
std::ostream & operator<< (std::ostream &stream, Size size)
 Writes the decimal count.
 
CString GenerateUUIDv4 () noexcept
 RFC 4122 UUID version 4 (lowercase).
 
std::wostream & operator<< (std::wostream &stream, const WCString &text)
 Writes text to stream.
 
bool operator== (const wchar_t *str, const WCString &text) noexcept
 Content equality.
 
bool operator!= (const wchar_t *str, const WCString &text) noexcept
 Content inequality.
 
void swap (WCString &left, WCString &right) noexcept
 Swaps two buffers.
 

Variables

constexpr ByteSize B {1ull}
 One octet.
 
constexpr ByteSize KiB {1024ull}
 2^10 octets.
 
constexpr ByteSize MiB {1024ull * 1024}
 2^20 octets.
 
constexpr ByteSize GiB {1024ull * 1024 * 1024}
 2^30 octets.
 
constexpr ByteSize TiB {1024ull * 1024 * 1024 * 1024}
 2^40 octets.
 
constexpr ByteSize PiB {1024ull * 1024 * 1024 * 1024 * 1024}
 2^50 octets.
 
constexpr ByteSize EiB {1024ull * 1024 * 1024 * 1024 * 1024 * 1024}
 2^60 octets.
 
constexpr ByteSize KB {1000ull}
 10^3 octets.
 
constexpr ByteSize MB {1000ull * 1000}
 10^6 octets.
 
constexpr ByteSize GB {1000ull * 1000 * 1000}
 10^9 octets.
 
constexpr ByteSize TB {1000ull * 1000 * 1000 * 1000}
 10^12 octets.
 
constexpr ByteSize PB {1000ull * 1000 * 1000 * 1000 * 1000}
 10^15 octets.
 
constexpr ByteSize EB {1000ull * 1000 * 1000 * 1000 * 1000 * 1000}
 10^18 octets.
 

Detailed Description

Root namespace of the StormByte suite.

Typedef Documentation

◆ Expected

template<typename T , class E >
using StormByte::Expected = typedef std::conditional_t< Type::Reference<T>, std::expected<std::reference_wrapper<std::remove_reference_t<T> >, Safe::Shared<E> >, std::expected<T, Safe::Shared<E> > >

std::expected alias with reference and shared-error handling.

Template Parameters
TValue type. References are stored as std::reference_wrapper.
EError type. Always stored as Safe::Shared. Converts to std::shared_ptr<E>.

Function Documentation

◆ append_bytes() [1/3]

void StormByte::append_bytes ( BinaryData &  dest,
BinaryData &&  src 
)
inlinenoexcept

Appends a BinaryData by move on Base's heap.

Parameters
destDestination owned by Base.
srcSource sequence; emptied after a successful append.

◆ append_bytes() [2/3]

void StormByte::append_bytes ( BinaryData &  dest,
const BinaryData &  src 
)
inlinenoexcept

Appends a BinaryData by copy.

Parameters
destDestination owned by Base.
srcSource sequence (read-only).

◆ append_bytes() [3/3]

void StormByte::append_bytes ( BinaryData &  dest,
std::span< const std::byte >  src 
)
inlinenoexcept

Appends a span of bytes onto a BinaryData.

Parameters
destDestination owned by Base.
srcView over the bytes to copy.

◆ append_vector() [1/3]

template<typename T >
void StormByte::append_vector ( std::vector< T > &  dest,
const std::vector< T > &  src 
)
noexcept

Appends a vector by copy.

Template Parameters
TElement type.
Parameters
destVector that receives the elements.
srcSource vector (read-only).
Note
Local STL helper. Do not use this for public byte blobs; use append_bytes.

◆ append_vector() [2/3]

template<typename T , typename U >
requires Type::ConvertibleTo<T, U>
void StormByte::append_vector ( std::vector< T > &  dest,
std::span< U >  src 
)
noexcept

Appends a span of convertible elements onto a vector.

Template Parameters
TDestination element type.
USource element type (Type::ConvertibleTo<T, U>).
Parameters
destVector that receives the elements.
srcView over the elements to copy.
Note
Local STL helper. Do not use this for public byte blobs; use append_bytes.

◆ append_vector() [3/3]

template<typename T >
void StormByte::append_vector ( std::vector< T > &  dest,
std::vector< T > &&  src 
)
noexcept

Appends a vector by move.

Template Parameters
TElement type.
Parameters
destVector that receives the elements.
srcSource vector; elements are moved out.
Note
Local STL helper. Do not use this for public byte blobs; use append_bytes.

◆ Base64Decode()

BinaryData StormByte::Base64Decode ( std::string_view  input)

Decodes Base64 text into bytes.

Alphabet A–Z a–z 0–9 + / and padding =. Space, tab, newline and CR are ignored. Decoding stops at the first =. Padding is accepted but not strictly checked.

Parameters
inputBase64 text (std::string_view, std::string or a string literal).
Returns
Decoded bytes owned by Base.
Exceptions
StormByte::Base64ErrorIf a character is outside the alphabet.

◆ Base64Encode() [1/2]

CString StormByte::Base64Encode ( const BinaryData &  input)

Encodes bytes as Base64 with = padding.

Parameters
inputBytes to encode.
Returns
Base64 text as a CString.

◆ Base64Encode() [2/2]

CString StormByte::Base64Encode ( std::span< const std::byte >  input)

Encodes a contiguous byte span as Base64 with = padding.

Parameters
inputBytes to encode.
Returns
Base64 text as a CString.

◆ GenerateUUIDv4()

CString StormByte::GenerateUUIDv4 ( )
noexcept

RFC 4122 UUID version 4 (lowercase).

Returns
36-character CString xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where y is 8, 9, a or b.
Note
Prefers the OS CSPRNG; falls back to a PRNG. Details in uuid.cxx.

◆ operator!=() [1/3]

bool StormByte::operator!= ( const char *  str,
const CString &  text 
)
inlinenoexcept

Content inequality.

Parameters
strC string; may be null.
textBuffer.
Returns
Whether the texts differ.

◆ operator!=() [2/3]

bool StormByte::operator!= ( const wchar_t *  str,
const WCString &  text 
)
inlinenoexcept

Content inequality.

Parameters
strC wide string; may be null.
textBuffer.
Returns
Whether the texts differ.

◆ operator!=() [3/3]

bool StormByte::operator!= ( std::span< const std::byte >  bytes,
const BinaryData &  data 
)
inlinenoexcept

Inequality of a span against a sequence.

Parameters
bytesLeft view.
dataRight sequence.
Returns
Same as data != bytes.

◆ operator%() [1/3]

template<Type::Integral T>
constexpr ByteSize StormByte::operator% ( ByteSize  lhs,
T  rhs 
)
constexprnoexcept

Mixed remainder.

Template Parameters
TIntegral type.
Parameters
lhsDividend.
rhsDivisor.
Returns
Remainder as ByteSize.

◆ operator%() [2/3]

template<Type::Integral T>
constexpr Size StormByte::operator% ( Size  lhs,
T  rhs 
)
constexprnoexcept

Mixed remainder.

Template Parameters
TIntegral type.
Parameters
lhsDividend.
rhsDivisor.
Returns
Remainder as Size.

◆ operator%() [3/3]

template<Type::Integral T>
constexpr Size StormByte::operator% ( T  lhs,
Size  rhs 
)
constexprnoexcept

Mixed remainder.

Template Parameters
TIntegral type.
Parameters
lhsDividend.
rhsDivisor.
Returns
Remainder as Size.

◆ operator*() [1/4]

template<Type::Integral T>
constexpr ByteSize StormByte::operator* ( ByteSize  lhs,
T  rhs 
)
constexprnoexcept

Mixed product.

Template Parameters
TIntegral type.
Parameters
lhsLeft factor.
rhsRight factor.
Returns
Product as ByteSize.

◆ operator*() [2/4]

template<Type::Integral T>
constexpr Size StormByte::operator* ( Size  lhs,
T  rhs 
)
constexprnoexcept

Mixed product.

Template Parameters
TIntegral type.
Parameters
lhsLeft factor.
rhsRight factor.
Returns
Product as Size.

◆ operator*() [3/4]

template<Type::Integral T>
constexpr ByteSize StormByte::operator* ( T  lhs,
ByteSize  rhs 
)
constexprnoexcept

Mixed product.

Template Parameters
TIntegral type.
Parameters
lhsLeft factor.
rhsRight factor.
Returns
Product as ByteSize.

◆ operator*() [4/4]

template<Type::Integral T>
constexpr Size StormByte::operator* ( T  lhs,
Size  rhs 
)
constexprnoexcept

Mixed product.

Template Parameters
TIntegral type.
Parameters
lhsLeft factor.
rhsRight factor.
Returns
Product as Size.

◆ operator+() [1/4]

template<Type::Integral T>
constexpr ByteSize StormByte::operator+ ( ByteSize  lhs,
T  rhs 
)
constexprnoexcept

Mixed sum.

Template Parameters
TIntegral type.
Parameters
lhsLeft addend.
rhsRight addend.
Returns
Sum as ByteSize.

◆ operator+() [2/4]

template<Type::Integral T>
constexpr Size StormByte::operator+ ( Size  lhs,
T  rhs 
)
constexprnoexcept

Mixed sum.

Template Parameters
TIntegral type.
Parameters
lhsLeft addend.
rhsRight addend.
Returns
Sum as Size.

◆ operator+() [3/4]

template<Type::Integral T>
constexpr ByteSize StormByte::operator+ ( T  lhs,
ByteSize  rhs 
)
constexprnoexcept

Mixed sum.

Template Parameters
TIntegral type.
Parameters
lhsLeft addend.
rhsRight addend.
Returns
Sum as ByteSize.

◆ operator+() [4/4]

template<Type::Integral T>
constexpr Size StormByte::operator+ ( T  lhs,
Size  rhs 
)
constexprnoexcept

Mixed sum.

Template Parameters
TIntegral type.
Parameters
lhsLeft addend.
rhsRight addend.
Returns
Sum as Size.

◆ operator-() [1/4]

template<Type::Integral T>
constexpr ByteSize StormByte::operator- ( ByteSize  lhs,
T  rhs 
)
constexprnoexcept

Mixed difference.

Template Parameters
TIntegral type.
Parameters
lhsMinuend.
rhsSubtrahend.
Returns
Difference as ByteSize.

◆ operator-() [2/4]

template<Type::Integral T>
constexpr Size StormByte::operator- ( Size  lhs,
T  rhs 
)
constexprnoexcept

Mixed difference.

Template Parameters
TIntegral type.
Parameters
lhsMinuend.
rhsSubtrahend.
Returns
Difference as Size.

◆ operator-() [3/4]

template<Type::Integral T>
constexpr ByteSize StormByte::operator- ( T  lhs,
ByteSize  rhs 
)
constexprnoexcept

Mixed difference.

Template Parameters
TIntegral type.
Parameters
lhsMinuend.
rhsSubtrahend.
Returns
Difference as ByteSize.

◆ operator-() [4/4]

template<Type::Integral T>
constexpr Size StormByte::operator- ( T  lhs,
Size  rhs 
)
constexprnoexcept

Mixed difference.

Template Parameters
TIntegral type.
Parameters
lhsMinuend.
rhsSubtrahend.
Returns
Difference as Size.

◆ operator/() [1/3]

template<Type::Integral T>
constexpr ByteSize StormByte::operator/ ( ByteSize  lhs,
T  rhs 
)
constexprnoexcept

Mixed quotient.

Template Parameters
TIntegral type.
Parameters
lhsDividend.
rhsDivisor.
Returns
Quotient as ByteSize.

◆ operator/() [2/3]

template<Type::Integral T>
constexpr Size StormByte::operator/ ( Size  lhs,
T  rhs 
)
constexprnoexcept

Mixed quotient.

Template Parameters
TIntegral type.
Parameters
lhsDividend.
rhsDivisor.
Returns
Quotient as Size.

◆ operator/() [3/3]

template<Type::Integral T>
constexpr Size StormByte::operator/ ( T  lhs,
Size  rhs 
)
constexprnoexcept

Mixed quotient.

Template Parameters
TIntegral type.
Parameters
lhsDividend.
rhsDivisor.
Returns
Quotient as Size.

◆ operator<<() [1/4]

std::ostream & StormByte::operator<< ( std::ostream &  stream,
ByteSize  size 
)
inline

Writes the IEC human-readable length.

Parameters
streamDestination.
sizeLength.
Returns
stream.

◆ operator<<() [2/4]

std::ostream & StormByte::operator<< ( std::ostream &  stream,
const CString &  text 
)
inline

Writes text to stream.

Parameters
streamDestination.
textSource.
Returns
stream.

◆ operator<<() [3/4]

std::ostream & StormByte::operator<< ( std::ostream &  stream,
Size  size 
)
inline

Writes the decimal count.

Parameters
streamDestination.
sizeCount.
Returns
stream.

◆ operator<<() [4/4]

std::wostream & StormByte::operator<< ( std::wostream &  stream,
const WCString &  text 
)
inline

Writes text to stream.

Parameters
streamDestination.
textSource.
Returns
stream.

◆ operator<=>() [1/5]

template<Type::Integral T>
constexpr std::strong_ordering StormByte::operator<=> ( ByteSize  lhs,
T  rhs 
)
constexprnoexcept

Mixed order.

Mixed order with an integer.

Template Parameters
TIntegral type.
Parameters
lhsLeft length.
rhsRight integer.
Returns
Ordering.

◆ operator<=>() [2/5]

template<Type::Integral T>
constexpr std::strong_ordering StormByte::operator<=> ( Size  lhs,
T  rhs 
)
constexprnoexcept

Mixed order.

Template Parameters
TIntegral type.
Parameters
lhsLeft count.
rhsRight integer.
Returns
Ordering.

◆ operator<=>() [3/5]

std::strong_ordering StormByte::operator<=> ( std::span< const std::byte >  bytes,
const BinaryData &  data 
)
inlinenoexcept

Three-way comparison of a span against a sequence.

Parameters
bytesLeft view.
dataRight sequence.
Returns
Reverse of data <=> bytes.

◆ operator<=>() [4/5]

template<Type::Integral T>
constexpr std::strong_ordering StormByte::operator<=> ( T  lhs,
ByteSize  rhs 
)
constexprnoexcept

Mixed order.

Mixed order with an integer.

Template Parameters
TIntegral type.
Parameters
lhsLeft integer.
rhsRight length.
Returns
Ordering.

◆ operator<=>() [5/5]

template<Type::Integral T>
constexpr std::strong_ordering StormByte::operator<=> ( T  lhs,
Size  rhs 
)
constexprnoexcept

Mixed order.

Template Parameters
TIntegral type.
Parameters
lhsLeft integer.
rhsRight count.
Returns
Ordering.

◆ operator==() [1/7]

template<Type::Integral T>
constexpr bool StormByte::operator== ( ByteSize  lhs,
T  rhs 
)
constexprnoexcept

Mixed equality.

Mixed equality with an integer.

Template Parameters
TIntegral type.
Parameters
lhsLeft length.
rhsRight integer.
Returns
Whether the numeric values match.

◆ operator==() [2/7]

bool StormByte::operator== ( const char *  str,
const CString &  text 
)
inlinenoexcept

Content equality.

Parameters
strC string; may be null.
textBuffer.
Returns
Whether the texts are equal.

◆ operator==() [3/7]

bool StormByte::operator== ( const wchar_t *  str,
const WCString &  text 
)
inlinenoexcept

Content equality.

Parameters
strC wide string; may be null.
textBuffer.
Returns
Whether the texts are equal.

◆ operator==() [4/7]

template<Type::Integral T>
constexpr bool StormByte::operator== ( Size  lhs,
T  rhs 
)
constexprnoexcept

Mixed equality.

Template Parameters
TIntegral type.
Parameters
lhsLeft count.
rhsRight integer.
Returns
Whether the numeric values match.

◆ operator==() [5/7]

bool StormByte::operator== ( std::span< const std::byte >  bytes,
const BinaryData &  data 
)
inlinenoexcept

Equality of a span against a sequence.

Parameters
bytesLeft view.
dataRight sequence.
Returns
Same as data == bytes.

◆ operator==() [6/7]

template<Type::Integral T>
constexpr bool StormByte::operator== ( T  lhs,
ByteSize  rhs 
)
constexprnoexcept

Mixed equality.

Mixed equality with an integer.

Template Parameters
TIntegral type.
Parameters
lhsLeft integer.
rhsRight length.
Returns
Whether the numeric values match.

◆ operator==() [7/7]

template<Type::Integral T>
constexpr bool StormByte::operator== ( T  lhs,
Size  rhs 
)
constexprnoexcept

Mixed equality.

Template Parameters
TIntegral type.
Parameters
lhsLeft integer.
rhsRight count.
Returns
Whether the numeric values match.

◆ swap() [1/3]

void StormByte::swap ( BinaryData &  lhs,
BinaryData &  rhs 
)
noexcept

Exchange two sequences.

Parameters
lhsFirst sequence.
rhsSecond sequence.

◆ swap() [2/3]

void StormByte::swap ( CString &  left,
CString &  right 
)
inlinenoexcept

Swaps two buffers.

Parameters
leftFirst buffer.
rightSecond buffer.

◆ swap() [3/3]

void StormByte::swap ( WCString &  left,
WCString &  right 
)
inlinenoexcept

Swaps two buffers.

Parameters
leftFirst buffer.
rightSecond buffer.

◆ Unexpected() [1/5]

template<typename E , typename... Args>
auto StormByte::Unexpected ( const std::string &  fmt,
Args &&...  args 
)

Builds std::unexpected from a format string and E(string).

Template Parameters
EError type. Constructed as E(formatted).
ArgsFormat argument types.
Parameters
fmtFormat string. Used as-is when Args is empty.
argsFormat arguments for std::vformat.
Returns
std::unexpected holding the error on Base's heap.

Formatting runs in the caller. E is then constructed on Base's heap, so ‘Unexpected<VaultException>("Password &rsquo;{}' not found", name)` stays valid.

◆ Unexpected() [2/5]

template<typename Base , typename Derived >
requires Type::DerivedFrom<std::decay_t<Derived>, Base> && (!Type::SameAs<Base, std::decay_t<Derived>>)
auto StormByte::Unexpected ( Derived &&  error) -> std::unexpected<Safe::Shared<Base>>

Builds std::unexpected<shared_ptr<Base>> from a Derived instance.

Template Parameters
BaseError base type stored in the pointer.
DerivedConcrete error type, derived from Base and not the same type.
Parameters
errorDerived instance to own.
Returns
std::unexpected with an upcast Safe::Shared. The deleter still destroys Derived.

◆ Unexpected() [3/5]

template<typename E >
requires ( !requires { typename std::remove_cvref_t<E>::element_type; } || !Type::SameAs<std::remove_cvref_t<E>, Safe::Shared<typename std::remove_cvref_t<E>::element_type>> )
auto StormByte::Unexpected ( E &&  error)

Builds std::unexpected by constructing E.

Template Parameters
EError type.
Parameters
errorError instance, moved or copied onto Base's heap.
Returns
std::unexpected holding Safe::Shared of decay_t<E>.

◆ Unexpected() [4/5]

template<typename E >
auto StormByte::Unexpected ( Safe::Shared< E >  error)

Forwards an error already stored by Expected.

Template Parameters
EError type.
Parameters
errorPointer previously built by Unexpected. Not reallocated.
Returns
std::unexpected holding that Safe::Shared.

◆ Unexpected() [5/5]

template<typename E >
auto StormByte::Unexpected ( std::shared_ptr< E >  )
delete

Rejects a std::shared_ptr.

It is not on Base's heap, and Safe::Shared does not adopt it.

Template Parameters
EError type.

Variable Documentation

◆ B

constexpr ByteSize StormByte::B {1ull}
inlineconstexpr

One octet.

◆ EB

constexpr ByteSize StormByte::EB {1000ull * 1000 * 1000 * 1000 * 1000 * 1000}
inlineconstexpr

10^18 octets.

◆ EiB

constexpr ByteSize StormByte::EiB {1024ull * 1024 * 1024 * 1024 * 1024 * 1024}
inlineconstexpr

2^60 octets.

◆ GB

constexpr ByteSize StormByte::GB {1000ull * 1000 * 1000}
inlineconstexpr

10^9 octets.

◆ GiB

constexpr ByteSize StormByte::GiB {1024ull * 1024 * 1024}
inlineconstexpr

2^30 octets.

◆ KB

constexpr ByteSize StormByte::KB {1000ull}
inlineconstexpr

10^3 octets.

◆ KiB

constexpr ByteSize StormByte::KiB {1024ull}
inlineconstexpr

2^10 octets.

1 * KiB is 1024.

◆ MB

constexpr ByteSize StormByte::MB {1000ull * 1000}
inlineconstexpr

10^6 octets.

◆ MiB

constexpr ByteSize StormByte::MiB {1024ull * 1024}
inlineconstexpr

2^20 octets.

◆ PB

constexpr ByteSize StormByte::PB {1000ull * 1000 * 1000 * 1000 * 1000}
inlineconstexpr

10^15 octets.

◆ PiB

constexpr ByteSize StormByte::PiB {1024ull * 1024 * 1024 * 1024 * 1024}
inlineconstexpr

2^50 octets.

◆ TB

constexpr ByteSize StormByte::TB {1000ull * 1000 * 1000 * 1000}
inlineconstexpr

10^12 octets.

◆ TiB

constexpr ByteSize StormByte::TiB {1024ull * 1024 * 1024 * 1024}
inlineconstexpr

2^40 octets.