StormByte C++ Library 0.0.9999
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
Classes | Concepts | Typedefs | Functions
StormByte Namespace Reference

Main namespace for the StormByte library. More...

Classes

class  Clonable
 A class that can be cloned. More...
 
class  DeserializeError
 Exception thrown during deserialization errors. More...
 
class  Exception
 Base class for exceptions in the StormByte library. More...
 
class  Iterable
 A generic iterable container wrapper. More...
 
class  OutOfBoundsError
 Exception thrown when an out-of-bounds access is attempted. More...
 
class  Serializable
 The class to serialize and deserialize data. More...
 
class  ThreadLock
 

Concepts

concept  ValidSmartPointer
 Concept to check if a type is a valid smart pointer.
 

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 > > >
 Expected type with support for reference types.
 

Functions

STORMBYTE_PUBLIC std::error_code make_error_code (Error::Code e)
 
template<typename E >
auto Unexpected (std::shared_ptr< E > error_ptr)
 Creates an std::unexpected with a shared pointer to the error.
 
template<typename E >
auto Unexpected (E &&error)
 Creates an std::unexpected with a new error instance.
 
template<typename Base , typename Derived >
requires std::is_base_of_v<Base, std::decay_t<Derived>>
auto Unexpected (Derived &&error) -> std::unexpected< std::shared_ptr< Base > >
 Construct an Unexpected<Base> from a Derived instance.
 
template<typename E , typename... Args>
auto Unexpected (const std::string &fmt, Args &&... args)
 Creates an std::unexpected with a formatted error message.
 
template<typename T , typename U >
requires Type::ConvertibleTo<T, U>
void append_vector (std::vector< T > &dest, std::span< U > src) noexcept
 
template<typename T >
void append_vector (std::vector< T > &dest, const std::vector< T > &src) noexcept
 Appends the contents of one vector to another.
 
template<typename T >
void append_vector (std::vector< T > &dest, std::vector< T > &&src) noexcept
 Move the contents of one vector to another.
 
STORMBYTE_PUBLIC std::string GenerateUUIDv4 () noexcept
 Generate a RFC4122-compliant UUID version 4 string.
 

Detailed Description

Main namespace for the StormByte library.

The StormByte namespace serves as the root for all components and utilities in the StormByte library. It provides foundational classes and tools for building robust, thread-safe, and efficient applications.

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

Expected type with support for reference types.

Template Parameters
TExpected type
EError type

Defines an alias for std::expected, with special handling for reference types. For reference types, the std::reference_wrapper ensures safe and efficient storage, while the error type is managed using std::shared_ptr to support dynamic allocation.

Function Documentation

◆ append_vector() [1/2]

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

Appends the contents of one vector to another.

Template Parameters
TThe type of elements in the vectors.
Parameters
destThe destination vector to which elements will be appended.
srcThe source vector from which elements will be taken.
Note
This function reserves enough space in the destination vector to accommodate the new elements before appending, to avoid multiple reallocations.

This function appends all elements from the source vector src to the end of the destination vector dest. It supports both lvalue and rvalue source vectors for efficient appending.

◆ append_vector() [2/2]

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

Move the contents of one vector to another.

Template Parameters
TThe type of elements in the vectors.
Parameters
destThe destination vector to which elements will be appended.
srcThe source vector from which elements will be taken.
Note
This function reserves enough space in the destination vector to accommodate the new elements before appending, to avoid multiple reallocations.

This function appends all elements from the source vector src to the end of the destination vector dest. It supports both lvalue and rvalue source vectors for efficient appending.

◆ GenerateUUIDv4()

STORMBYTE_PUBLIC std::string StormByte::GenerateUUIDv4 ( )
noexcept

Generate a RFC4122-compliant UUID version 4 string.

See uuid.cxx for details and implementation notes about randomness source selection (OS CSPRNG preferred, fallback to PRNG).

Returns
A 36-character lowercase UUID string in the form "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" where y is one of 8, 9, a, or b.

◆ Unexpected() [1/4]

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

Creates an std::unexpected with a formatted error message.

Template Parameters
EError type
ArgsTypes of arguments to format the error message
Parameters
fmtThe format string
argsArguments to format the string
Returns
An std::unexpected object containing a shared pointer to the error

Dynamically formats the error message using std::vformat and constructs the error instance with the formatted message. If no arguments are provided, it directly uses the format string as the error message.

◆ Unexpected() [2/4]

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

Construct an Unexpected<Base> from a Derived instance.

Allows calling Unexpected<Base>(Derived(...)) to create a std::unexpected<std::shared_ptr<Base>> that holds a Derived instance inside the shared_ptr and upcasts it to Base.

◆ Unexpected() [3/4]

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

Creates an std::unexpected with a new error instance.

Template Parameters
EError type
Parameters
errorError instance to store
Returns
An std::unexpected object containing a shared pointer to the new error instance

This overload constructs a new error instance by forwarding the provided argument.

◆ Unexpected() [4/4]

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

Creates an std::unexpected with a shared pointer to the error.

Template Parameters
EError type
Parameters
error_ptrA shared pointer to the error
Returns
An std::unexpected object containing the shared pointer to the error

This overload is used when an existing std::shared_ptr to the error instance is available.