StormByte C++ Library 1.2.0
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Namespaces | Classes | Concepts | Typedefs | Functions
StormByte Namespace Reference

Root namespace of the StormByte suite. More...

Namespaces

namespace  Detail
 Private specialization point for non-trivial types.
 
namespace  Error
 std::error_code integration for suite-wide codes.
 
namespace  String
 String helpers (case, split, UTF-8, human-readable numbers).
 
namespace  System
 Path and timing helpers that hide OS differences.
 
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  Bitmask
 CRTP wrapper that stores an unsigned enum as a flag set. More...
 
class  Clonable
 Polymorphic clone/move into a smart pointer of type T. More...
 
struct  Component
 Wraps a module name for the component-prefixed Exception constructor. 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  SystemError
 Thrown when a System helper cannot obtain a path or create a temporary file. More...
 
class  ThreadLock
 Mutex with owner-thread reentry. More...
 
class  UTF8Error
 Thrown when UTF-8 or wide-string input contains invalid Unicode. More...
 

Concepts

concept  ValidSmartPointer
 true when SmartPointer is shared_ptr<T> or unique_ptr<T>.
 

Typedefs

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

Functions

std::vector< std::byte > Base64Decode (std::string_view input)
 Decodes Base64 text into bytes.
 
std::string Base64Encode (const std::vector< std::byte > &input)
 Encodes bytes as Base64 with = padding.
 
std::string Base64Encode (std::span< const std::byte > input)
 Encodes a contiguous byte span as Base64 with = padding.
 
std::error_code make_error_code (Error::Code e)
 Builds an std::error_code from Error::Code.
 
template<typename E >
auto Unexpected (std::shared_ptr< E > error_ptr)
 Builds std::unexpected from an existing error pointer.
 
template<typename E >
auto Unexpected (E &&error)
 Builds std::unexpected by constructing E.
 
template<typename Base , typename Derived >
requires std::is_base_of_v<Base, std::decay_t<Derived>> && (!std::same_as<Base, std::decay_t<Derived>>)
auto Unexpected (Derived &&error) -> std::unexpected< std::shared_ptr< 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) constructor.
 
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.
 
std::string GenerateUUIDv4 () noexcept
 RFC 4122 UUID version 4 (lowercase).
 

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> >, std::shared_ptr<E> >, std::expected<T, std::shared_ptr<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 std::shared_ptr<E>.

Function Documentation

◆ 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).

◆ 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
Reserves once, then uses append_range when the library has it.

◆ 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
Reserves once, then append_range(std::move(src)) when available.

◆ Base64Decode()

std::vector< std::byte > 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.
Exceptions
StormByte::Base64ErrorIf a character is outside the alphabet.

◆ Base64Encode() [1/2]

std::string StormByte::Base64Encode ( const std::vector< std::byte > &  input)

Encodes bytes as Base64 with = padding.

Parameters
inputBytes to encode.

◆ Base64Encode() [2/2]

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

Encodes a contiguous byte span as Base64 with = padding.

Parameters
inputBytes to encode.

◆ GenerateUUIDv4()

std::string StormByte::GenerateUUIDv4 ( )
noexcept

RFC 4122 UUID version 4 (lowercase).

Returns
36-character string 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.

◆ make_error_code()

std::error_code StormByte::make_error_code ( Error::Code  e)

Builds an std::error_code from Error::Code.

Parameters
eSuite error enumerator.
Returns
std::error_code in Error::category().

◆ Unexpected() [1/4]

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

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

Template Parameters
EError type.
ArgsFormat argument types.
Parameters
fmtFormat string (used as-is when Args is empty).
argsFormat arguments for std::vformat.
Returns
std::unexpected holding make_shared<E>(formatted).

◆ Unexpected() [2/4]

template<typename Base , typename Derived >
requires std::is_base_of_v<Base, std::decay_t<Derived>> && (!std::same_as<Base, std::decay_t<Derived>>)
auto StormByte::Unexpected ( Derived &&  error) -> std::unexpected<std::shared_ptr<Base>>

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

Template Parameters
BaseError base type stored in the pointer.
DerivedConcrete error type (std::is_base_of_v<Base, Derived>).
Parameters
errorDerived instance to own.
Returns
std::unexpected with an upcast shared_ptr<Base>.

◆ Unexpected() [3/4]

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

Builds std::unexpected by constructing E.

Template Parameters
EError type.
Parameters
errorError instance (moved or copied into a shared_ptr).
Returns
std::unexpected holding shared_ptr<decay_t<E>>.

◆ Unexpected() [4/4]

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

Builds std::unexpected from an existing error pointer.

Template Parameters
EError type.
Parameters
error_ptrShared pointer to the error.
Returns
std::unexpected holding that pointer.