mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
mal_toolkit Namespace Reference

Contains a collection of tools and utilities provided by the MAL Toolkit library. More...

Namespaces

namespace  _template_detail
 
namespace  endianness
 
namespace  uuid
 

Classes

struct  ByteArray
 A dynamically resizable array of bytes. More...
 
struct  ByteView
 A lightweight view over a sequence of bytes. More...
 
class  CallbackSystem
 A system for managing and invoking callback functions. More...
 
class  enableable
 A class that can be enabled or disabled. More...
 
class  ExponentialBackoff
 A utility class for implementing exponential backoff strategies. More...
 
class  LinearBackoff
 A utility class for implementing linear backoff strategies. More...
 
struct  Measurer
 A class for measuring and logging the execution time of functions. More...
 
class  namable
 A class that contains a name and can be named and unnamed. More...
 
class  namable_once
 A class that contains a name and can be named only once at construction. More...
 
class  namable_protected
 A class that contains a name and can be named and unnamed, but you cant set the name from outside. More...
 
class  non_copyable
 A class that can't be copied. More...
 
class  non_copyable_non_movable
 A class that can't be copied neither moved. More...
 
class  non_movable
 A class that can't be moved. More...
 
struct  parameter_pack_info
 Provides information about a parameter pack. More...
 
struct  return_type
 Extracts the return type of a function or function pointer. More...
 
struct  return_type< R(*)(Args...)>
 
struct  return_type< R(Args...)>
 
struct  return_type< R(C::*)(Args...) & >
 
struct  return_type< R(C::*)(Args...) && >
 
struct  return_type< R(C::*)(Args...) const & >
 
struct  return_type< R(C::*)(Args...) const && >
 
struct  return_type< R(C::*)(Args...) const >
 
struct  return_type< R(C::*)(Args...) const volatile & >
 
struct  return_type< R(C::*)(Args...) const volatile && >
 
struct  return_type< R(C::*)(Args...) const volatile >
 
struct  return_type< R(C::*)(Args...) volatile & >
 
struct  return_type< R(C::*)(Args...) volatile && >
 
struct  return_type< R(C::*)(Args...) volatile >
 
struct  return_type< R(C::*)(Args...)>
 
class  Timer
 A simple timer class for measuring elapsed time using various clock types. More...
 

Concepts

concept  EnumClassConcept
 Concept to check if a type is an enumeration class.
 

Typedefs

using ExponentialBackoffNs = ExponentialBackoff<std::chrono::nanoseconds>
 
using ExponentialBackoffUs = ExponentialBackoff<std::chrono::microseconds>
 
using ExponentialBackoffMs = ExponentialBackoff<std::chrono::milliseconds>
 
using ExponentialBackoffSec = ExponentialBackoff<std::chrono::seconds>
 
using LinearBackoffNs = LinearBackoff<std::chrono::nanoseconds>
 
using LinearBackoffUs = LinearBackoff<std::chrono::microseconds>
 
using LinearBackoffMs = LinearBackoff<std::chrono::milliseconds>
 
using LinearBackoffSec = LinearBackoff<std::chrono::seconds>
 
template<typename T >
using return_type_t = typename return_type<T>::type
 
using SteadyTimer = Timer<std::chrono::steady_clock>
 Alias for Timer using std::chrono::steady_clock as the clock type.
 
using HighResolutionTimer = Timer<std::chrono::high_resolution_clock>
 Alias for Timer using std::chrono::high_resolution_clock as the clock type.
 

Functions

uint16_t bytes_to_uint16 (const ByteView byte_view)
 Convert a byte array to a uint16_t value using little-endian byte order.
 
ByteArray uint16_to_bytes (const uint16_t value)
 Convert a uint16_t value to a ByteArray using little-endian byte order.
 
uint32_t bytes_to_uint32 (const ByteView byte_view)
 Convert a byte array to a uint32_t value using little-endian byte order.
 
ByteArray uint32_to_bytes (const uint32_t value)
 Convert a uint32_t value to a ByteArray using little-endian byte order.
 
uint64_t bytes_to_uint64 (const ByteView byte_view)
 Convert a byte array to a uint64_t value using little-endian byte order.
 
ByteArray uint64_to_bytes (const uint64_t value)
 Convert a uint64_t value to a ByteArray using little-endian byte order.
 
int16_t bytes_to_int16 (const ByteView byte_view)
 Convert a byte array to an int16_t value using little-endian byte order.
 
ByteArray int16_to_bytes (const int16_t value)
 Convert an int16_t value to a ByteArray using little-endian byte order.
 
int32_t bytes_to_int32 (const ByteView byte_view)
 Convert a byte array to an int32_t value using little-endian byte order.
 
ByteArray int32_to_bytes (const int32_t value)
 Convert an int32_t value to a ByteArray using little-endian byte order.
 
int64_t bytes_to_int64 (const ByteView byte_view)
 Convert a byte array to an int64_t value using little-endian byte order.
 
ByteArray int64_to_bytes (const int64_t value)
 Convert an int64_t value to a ByteArray using little-endian byte order.
 
template<typename T , typename... U>
size_t GetFunctionAddress (std::function< T(U...)> f)
 Get the address of a callable function.
 
std::optional< int64_t > to_int64 (std::string_view str)
 Convert a string_view to an optional int64_t.
 
std::optional< uint64_t > to_uint64 (std::string_view str)
 Convert a string_view to an optional uint64_t.
 
std::optional< long double > to_long_double (std::string_view str)
 Convert a string_view to an optional long double.
 
std::string CurrentSourceLocation (std::source_location location=std::source_location::current())
 Generates a string representation of the current source location.
 
void Assert (bool value, std::string_view message="Assert failed", std::source_location location=std::source_location::current())
 Asserts a condition with customizable behavior based on debug mode.
 
void AlwaysAssert (bool value, std::string_view message="Assert failed", std::source_location location=std::source_location::current())
 Always asserts a condition with customizable behavior.
 
std::string CurrentSourceLocation ()
 Returns an empty string representing the current source location.
 
void Assert (bool value, std::string_view message="Assert failed")
 Asserts a condition with customizable behavior based on debug mode.
 
void AlwaysAssert (bool value, std::string_view message="Assert failed")
 Always asserts a condition with customizable behavior.
 
template<typename T >
void SortedInsert (std::vector< T > &range, T &&value)
 Inserts a value into a sorted vector while maintaining the sorted order.
 
template<typename T >
void SortedInsert (std::vector< T > &range, T &&value, std::function< bool(T const &, T const &)> const &comparator)
 Inserts a value into a sorted vector while maintaining the sorted order using a custom comparator.
 
template<typename T >
void SortedErase (std::vector< T > &range, T &&value)
 Efficiently erases elements equal to a given value from a sorted vector.
 
template<typename T >
void SortedErase (std::vector< T > &range, T &&value, std::function< bool(T const &, T const &)> const &comparator)
 Efficiently erases elements equal to a given value from a sorted vector using a custom comparator.
 
template<typename T >
void hash_combine (size_t &seed, T const &hash)
 Combines a hash value into an existing hash using bitwise operations.
 
std::string as_lowercase (std::string_view const s) noexcept
 Converts a string to lowercase.
 
std::string as_uppercase (std::string_view const s) noexcept
 Converts a string to uppercase.
 
constexpr std::string_view ltrimview (std::string_view const s) noexcept
 Trims leading whitespace from a string view.
 
constexpr std::string_view rtrimview (std::string_view const s) noexcept
 Trims trailing whitespace from a string view.
 
constexpr std::string_view trimview (std::string_view const s) noexcept
 Trims leading and trailing whitespace from a string view.
 
std::string ltrim (std::string const &s) noexcept
 Trims leading whitespace from a string.
 
std::string rtrim (std::string const &s) noexcept
 Trims trailing whitespace from a string.
 
std::string trim (std::string const &s) noexcept
 Trims leading and trailing whitespace from a string.
 
template<typename T , typename... Types>
consteval size_t index_of_type ()
 Function to find the index of a type in a parameter pack.
 
template<typename T , typename Func >
consteval std::size_t index_of_function_arg (Func const &func={})
 Function to find the index of a type within a function's argument list.
 
template<auto begin, auto end, auto inc, class F >
constexpr void constexpr_for (F &&f)
 A constexpr loop for compile-time iteration.
 
template<auto begin, auto end, auto inc, class F >
constexpr void constexpr_for_break (F &&f)
 
template<class iterator , class F >
constexpr bool for_each_true (iterator begin, iterator const &end, F &&f)
 Applies a function to each element in a range and returns true if all return true.
 
template<EnumClassConcept Enumeration>
constexpr auto as_integer (Enumeration const value) -> typename std::underlying_type< Enumeration >::type
 Converts an enumeration class value to its underlying integer value.
 
std::string wstring_to_string (std::wstring_view const wstr)
 Converts a wide string (UTF16) to a UTF-8 string.
 
std::wstring string_to_wstring (std::string_view const str)
 Converts a UTF-8 string to a wide string (UTF16).
 
std::string FormatErrorAsString (DWORD errorMessageID)
 Formats a Win32 error code as a string.
 

Detailed Description

Contains a collection of tools and utilities provided by the MAL Toolkit library.

Typedef Documentation

◆ ExponentialBackoffMs

using mal_toolkit::ExponentialBackoffMs = ExponentialBackoff<std::chrono::milliseconds>

Definition at line 166 of file backoffs.hpp.

◆ ExponentialBackoffNs

using mal_toolkit::ExponentialBackoffNs = ExponentialBackoff<std::chrono::nanoseconds>

Definition at line 164 of file backoffs.hpp.

◆ ExponentialBackoffSec

Definition at line 167 of file backoffs.hpp.

◆ ExponentialBackoffUs

using mal_toolkit::ExponentialBackoffUs = ExponentialBackoff<std::chrono::microseconds>

Definition at line 165 of file backoffs.hpp.

◆ HighResolutionTimer

using mal_toolkit::HighResolutionTimer = Timer<std::chrono::high_resolution_clock>

Alias for Timer using std::chrono::high_resolution_clock as the clock type.

Definition at line 62 of file timer.hpp.

◆ LinearBackoffMs

using mal_toolkit::LinearBackoffMs = LinearBackoff<std::chrono::milliseconds>

Definition at line 171 of file backoffs.hpp.

◆ LinearBackoffNs

using mal_toolkit::LinearBackoffNs = LinearBackoff<std::chrono::nanoseconds>

Definition at line 169 of file backoffs.hpp.

◆ LinearBackoffSec

using mal_toolkit::LinearBackoffSec = LinearBackoff<std::chrono::seconds>

Definition at line 172 of file backoffs.hpp.

◆ LinearBackoffUs

using mal_toolkit::LinearBackoffUs = LinearBackoff<std::chrono::microseconds>

Definition at line 170 of file backoffs.hpp.

◆ return_type_t

template<typename T >
using mal_toolkit::return_type_t = typename return_type<T>::type

Definition at line 351 of file template.hpp.

◆ SteadyTimer

using mal_toolkit::SteadyTimer = Timer<std::chrono::steady_clock>

Alias for Timer using std::chrono::steady_clock as the clock type.

Definition at line 57 of file timer.hpp.

Function Documentation

◆ AlwaysAssert() [1/2]

void mal_toolkit::AlwaysAssert ( bool value,
std::string_view message = "Assert failed" )
inline

Always asserts a condition with customizable behavior.

This function is used to assert a given condition, irrespective of the current debugging mode. If the condition evaluates to true, the function has no effect. However, if the condition is false, the behavior of the assertion depends on the configuration settings.

If logging is enabled (MAL_TOOLKIT_ASSERT_LOGS is set to true), the function generates a critical log message using the SPDLog library to indicate the assertion failure. Additionally, the assertion behavior in different contexts (debug or release mode) is determined by the following macros:

  • MAL_TOOLKIT_DEBUG_ENABLED: Indicates whether debug mode is enabled. In debug mode, an assertion is triggered using the assert macro. The program halts, and debugging tools can be used to inspect the error.
  • MAL_TOOLKIT_ASSERT_ABORTS: Determines whether an assertion failure should result in program abortion. If set to true, the program is immediately terminated upon an assertion failure. If set to false, a runtime_error exception is thrown, allowing for more controlled error handling, especially in release mode.

It is important to configure these macros according to the desired behavior for your application's debugging and error-handling strategy.

Parameters
valueThe condition to assert.
messageAn optional message to include in the log and assertion.

Definition at line 94 of file debug_without_source_location.hpp.

◆ AlwaysAssert() [2/2]

void mal_toolkit::AlwaysAssert ( bool value,
std::string_view message = "Assert failed",
std::source_location location = std::source_location::current() )
inline

Always asserts a condition with customizable behavior.

This function is used to assert a given condition, irrespective of the current debugging mode. If the condition evaluates to true, the function has no effect. However, if the condition is false, the behavior of the assertion depends on the configuration settings.

If logging is enabled (MAL_TOOLKIT_ASSERT_LOGS is set to true), the function generates a critical log message using the SPDLog library to indicate the assertion failure. Additionally, the assertion behavior in different contexts (debug or release mode) is determined by the following macros:

  • MAL_TOOLKIT_DEBUG_ENABLED: Indicates whether debug mode is enabled. In debug mode, an assertion is triggered using the assert macro. The program halts, and debugging tools can be used to inspect the error.
  • MAL_TOOLKIT_ASSERT_ABORTS: Determines whether an assertion failure should result in program abortion. If set to true, the program is immediately terminated upon an assertion failure. If set to false, a runtime_error exception is thrown, allowing for more controlled error handling, especially in release mode.

It is important to configure these macros according to the desired behavior for your application's debugging and error-handling strategy.

Parameters
valueThe condition to assert.
messageAn optional message to include in the log and assertion.
locationThe source location where the assertion occurred.

Definition at line 116 of file debug_with_source_location.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ as_integer()

template<EnumClassConcept Enumeration>
auto mal_toolkit::as_integer ( Enumeration const value) -> typename std::underlying_type<Enumeration>::type
constexpr

Converts an enumeration class value to its underlying integer value.

Definition at line 255 of file template.hpp.

◆ as_lowercase()

std::string mal_toolkit::as_lowercase ( std::string_view const s)
inlinenoexcept

Converts a string to lowercase.

Parameters
sThe input string view.
Returns
A new string containing the lowercase characters.

Definition at line 14 of file string.hpp.

◆ as_uppercase()

std::string mal_toolkit::as_uppercase ( std::string_view const s)
inlinenoexcept

Converts a string to uppercase.

Parameters
sThe input string view.
Returns
A new string containing the uppercase characters.

Definition at line 27 of file string.hpp.

◆ Assert() [1/2]

void mal_toolkit::Assert ( bool value,
std::string_view message = "Assert failed" )
inline

Asserts a condition with customizable behavior based on debug mode.

This function is used to assert a given condition in debug mode. If the condition is true, the function has no effect. If the condition is false, the assertion behavior depends on the configuration settings and the current debug mode.

In debug mode (MAL_TOOLKIT_DEBUG_ENABLED set to true), an assertion is triggered using the assert macro. The program halts, and debugging tools can be used to inspect the error.

In release mode, the behavior of the assertion is determined by the following macros:

  • MAL_TOOLKIT_ASSERT_ABORTS: Determines whether an assertion failure should result in program abortion. If set to true, the program is immediately terminated upon an assertion failure. If set to false, a runtime_error exception is thrown, allowing for more controlled error handling, especially in release mode.
  • MAL_TOOLKIT_ASSERT_LOGS: Indicates whether logging is enabled for assertion failures. If set to true, a critical log message is generated using the SPDLog library to indicate the assertion failure.

It is important to configure these macros according to the desired behavior for your application's debugging and error-handling strategy.

Parameters
valueThe condition to assert.
messageAn optional message to include in the log and assertion.

Definition at line 46 of file debug_without_source_location.hpp.

◆ Assert() [2/2]

void mal_toolkit::Assert ( bool value,
std::string_view message = "Assert failed",
std::source_location location = std::source_location::current() )
inline

Asserts a condition with customizable behavior based on debug mode.

This function is used to assert a given condition in debug mode. If the condition is true, the function has no effect. If the condition is false, the assertion behavior depends on the configuration settings and the current debug mode.

In debug mode (MAL_TOOLKIT_DEBUG_ENABLED set to true), an assertion is triggered using the assert macro. The program halts, and debugging tools can be used to inspect the error.

In release mode, the behavior of the assertion is determined by the following macros:

  • MAL_TOOLKIT_ASSERT_ABORTS: Determines whether an assertion failure should result in program abortion. If set to true, the program is immediately terminated upon an assertion failure. If set to false, a runtime_error exception is thrown, allowing for more controlled error handling, especially in release mode.
  • MAL_TOOLKIT_ASSERT_LOGS: Indicates whether logging is enabled for assertion failures. If set to true, a critical log message is generated using the SPDLog library to indicate the assertion failure.

It is important to configure these macros according to the desired behavior for your application's debugging and error-handling strategy.

Parameters
valueThe condition to assert.
messageAn optional message to include in the log and assertion.
locationThe source location where the assertion occurred.

Definition at line 53 of file debug_with_source_location.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bytes_to_int16()

int16_t mal_toolkit::bytes_to_int16 ( const ByteView byte_view)
inlinenodiscard

Convert a byte array to an int16_t value using little-endian byte order.

This function converts a byte array to an int16_t value, assuming little-endian byte order.

Parameters
byte_viewThe ByteView containing the byte representation of the int16_t value.
Returns
The converted int16_t value.

Definition at line 480 of file byte-helper.hpp.

◆ bytes_to_int32()

int32_t mal_toolkit::bytes_to_int32 ( const ByteView byte_view)
inlinenodiscard

Convert a byte array to an int32_t value using little-endian byte order.

This function converts a byte array to an int32_t value, assuming little-endian byte order.

Parameters
byte_viewThe ByteView containing the byte representation of the int32_t value.
Returns
The converted int32_t value.

Definition at line 504 of file byte-helper.hpp.

◆ bytes_to_int64()

int64_t mal_toolkit::bytes_to_int64 ( const ByteView byte_view)
inlinenodiscard

Convert a byte array to an int64_t value using little-endian byte order.

This function converts a byte array to an int64_t value, assuming little-endian byte order.

Parameters
byte_viewThe ByteView containing the byte representation of the int64_t value.
Returns
The converted int64_t value.

Definition at line 528 of file byte-helper.hpp.

◆ bytes_to_uint16()

uint16_t mal_toolkit::bytes_to_uint16 ( const ByteView byte_view)
inlinenodiscard

Convert a byte array to a uint16_t value using little-endian byte order.

This function converts a byte array to a uint16_t value, assuming little-endian byte order.

Parameters
byte_viewThe ByteView containing the byte representation of the uint16_t value.
Returns
The converted uint16_t value.

Definition at line 408 of file byte-helper.hpp.

◆ bytes_to_uint32()

uint32_t mal_toolkit::bytes_to_uint32 ( const ByteView byte_view)
inlinenodiscard

Convert a byte array to a uint32_t value using little-endian byte order.

This function converts a byte array to a uint32_t value, assuming little-endian byte order.

Parameters
byte_viewThe ByteView containing the byte representation of the uint32_t value.
Returns
The converted uint32_t value.

Definition at line 432 of file byte-helper.hpp.

Here is the caller graph for this function:

◆ bytes_to_uint64()

uint64_t mal_toolkit::bytes_to_uint64 ( const ByteView byte_view)
inlinenodiscard

Convert a byte array to a uint64_t value using little-endian byte order.

This function converts a byte array to a uint64_t value, assuming little-endian byte order.

Parameters
byte_viewThe ByteView containing the byte representation of the uint64_t value.
Returns
The converted uint64_t value.

Definition at line 456 of file byte-helper.hpp.

◆ constexpr_for()

template<auto begin, auto end, auto inc, class F >
void mal_toolkit::constexpr_for ( F && f)
constexpr

A constexpr loop for compile-time iteration.

Definition at line 202 of file template.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ constexpr_for_break()

template<auto begin, auto end, auto inc, class F >
void mal_toolkit::constexpr_for_break ( F && f)
constexpr

Definition at line 215 of file template.hpp.

Here is the call graph for this function:

◆ CurrentSourceLocation() [1/2]

std::string mal_toolkit::CurrentSourceLocation ( )
inline

Returns an empty string representing the current source location.

This function is provided for compatibility when source location is not available. It always returns an empty string.

Returns
An empty string.

Definition at line 17 of file debug_without_source_location.hpp.

Here is the caller graph for this function:

◆ CurrentSourceLocation() [2/2]

std::string mal_toolkit::CurrentSourceLocation ( std::source_location location = std::source_location::current())
inline

Generates a string representation of the current source location.

Parameters
locationThe source location information (default: current location).
Returns
A string containing file name, function name, line, and column information.

Definition at line 18 of file debug_with_source_location.hpp.

◆ for_each_true()

template<class iterator , class F >
bool mal_toolkit::for_each_true ( iterator begin,
iterator const & end,
F && f )
constexpr

Applies a function to each element in a range and returns true if all return true.

Definition at line 235 of file template.hpp.

◆ FormatErrorAsString()

std::string mal_toolkit::FormatErrorAsString ( DWORD errorMessageID)
inline

Formats a Win32 error code as a string.

This function converts a Win32 error code into a human-readable error message. If the error message ID is 0, an empty string is returned.

Parameters
errorMessageIDThe Win32 error code.
Returns
The formatted error message as a string.

Definition at line 53 of file win-utils.hpp.

◆ GetFunctionAddress()

template<typename T , typename... U>
size_t mal_toolkit::GetFunctionAddress ( std::function< T(U...)> f)

Get the address of a callable function.

Template Parameters
TReturn type of the function.
UArgument types of the function.
Parameters
fThe function to get the address of.
Returns
size_t The address of the function.

Definition at line 18 of file callback-system.hpp.

Here is the caller graph for this function:

◆ hash_combine()

template<typename T >
void mal_toolkit::hash_combine ( size_t & seed,
T const & hash )

Combines a hash value into an existing hash using bitwise operations.

Parameters
seedThe existing hash value, which will be updated.
hashThe hash value to combine.

Definition at line 68 of file stl-helpers.hpp.

◆ index_of_function_arg()

template<typename T , typename Func >
std::size_t mal_toolkit::index_of_function_arg ( Func const & func = {})
consteval

Function to find the index of a type within a function's argument list.

This template function determines the index of a specified type T within the argument list of a provided function Func. The function is evaluated at compile time and returns the index of the first occurrence of the specified type in the argument list of the function.

Template Parameters
TThe type whose index is to be found within the function's argument list.
FuncThe function type whose argument list is to be searched.
Parameters
funcAn instance of the function for which the argument list type index is sought.
Returns
The index of the first occurrence of type T in the function's argument list.

Definition at line 191 of file template.hpp.

◆ index_of_type()

template<typename T , typename... Types>
size_t mal_toolkit::index_of_type ( )
consteval

Function to find the index of a type in a parameter pack.

This template function determines the index of a specified type T within a parameter pack Types. The function is evaluated at compile time and returns the index of the first occurrence of the specified type in the parameter pack.

Template Parameters
TThe type whose index is to be found within the parameter pack.
TypesThe parameter pack in which the type index is searched.
Returns
The index of the first occurrence of type T in the parameter pack.

Definition at line 173 of file template.hpp.

Here is the call graph for this function:

◆ int16_to_bytes()

ByteArray mal_toolkit::int16_to_bytes ( const int16_t value)
inlinenodiscard

Convert an int16_t value to a ByteArray using little-endian byte order.

This function converts an int16_t value to a ByteArray of appropriate size, using little-endian byte order.

Parameters
valueThe int16_t value to convert.
Returns
A ByteArray containing the byte representation of the int16_t value.

Definition at line 494 of file byte-helper.hpp.

◆ int32_to_bytes()

ByteArray mal_toolkit::int32_to_bytes ( const int32_t value)
inlinenodiscard

Convert an int32_t value to a ByteArray using little-endian byte order.

This function converts an int32_t value to a ByteArray of appropriate size, using little-endian byte order.

Parameters
valueThe int32_t value to convert.
Returns
A ByteArray containing the byte representation of the int32_t value.

Definition at line 518 of file byte-helper.hpp.

◆ int64_to_bytes()

ByteArray mal_toolkit::int64_to_bytes ( const int64_t value)
inlinenodiscard

Convert an int64_t value to a ByteArray using little-endian byte order.

This function converts an int64_t value to a ByteArray of appropriate size, using little-endian byte order.

Parameters
valueThe int64_t value to convert.
Returns
A ByteArray containing the byte representation of the int64_t value.

Definition at line 542 of file byte-helper.hpp.

◆ ltrim()

std::string mal_toolkit::ltrim ( std::string const & s)
inlinenoexcept

Trims leading whitespace from a string.

Parameters
sThe input string.
Returns
A new string with leading whitespace removed.

Definition at line 68 of file string.hpp.

Here is the call graph for this function:

◆ ltrimview()

std::string_view mal_toolkit::ltrimview ( std::string_view const s)
constexprnoexcept

Trims leading whitespace from a string view.

Parameters
sThe input string view.
Returns
A new string view with leading whitespace removed.

Definition at line 40 of file string.hpp.

Here is the caller graph for this function:

◆ rtrim()

std::string mal_toolkit::rtrim ( std::string const & s)
inlinenoexcept

Trims trailing whitespace from a string.

Parameters
sThe input string.
Returns
A new string with trailing whitespace removed.

Definition at line 74 of file string.hpp.

Here is the call graph for this function:

◆ rtrimview()

std::string_view mal_toolkit::rtrimview ( std::string_view const s)
constexprnoexcept

Trims trailing whitespace from a string view.

Parameters
sThe input string view.
Returns
A new string view with trailing whitespace removed.

Definition at line 50 of file string.hpp.

Here is the caller graph for this function:

◆ SortedErase() [1/2]

template<typename T >
void mal_toolkit::SortedErase ( std::vector< T > & range,
T && value )

Efficiently erases elements equal to a given value from a sorted vector.

Parameters
rangeThe sorted vector to erase from.
valueThe value to erase.

Definition at line 42 of file stl-helpers.hpp.

◆ SortedErase() [2/2]

template<typename T >
void mal_toolkit::SortedErase ( std::vector< T > & range,
T && value,
std::function< bool(T const &, T const &)> const & comparator )

Efficiently erases elements equal to a given value from a sorted vector using a custom comparator.

Parameters
rangeThe sorted vector to erase from.
valueThe value to erase.
comparatorA function that compares two values.

Definition at line 56 of file stl-helpers.hpp.

◆ SortedInsert() [1/2]

template<typename T >
void mal_toolkit::SortedInsert ( std::vector< T > & range,
T && value )

Inserts a value into a sorted vector while maintaining the sorted order.

Parameters
rangeThe sorted vector to insert into.
valueThe value to insert.

Definition at line 16 of file stl-helpers.hpp.

◆ SortedInsert() [2/2]

template<typename T >
void mal_toolkit::SortedInsert ( std::vector< T > & range,
T && value,
std::function< bool(T const &, T const &)> const & comparator )

Inserts a value into a sorted vector while maintaining the sorted order using a custom comparator.

Parameters
rangeThe sorted vector to insert into.
valueThe value to insert.
comparatorA function that compares two values.

Definition at line 30 of file stl-helpers.hpp.

◆ string_to_wstring()

std::wstring mal_toolkit::string_to_wstring ( std::string_view const str)
inline

Converts a UTF-8 string to a wide string (UTF16).

Parameters
strThe input UTF-8 string.
Returns
The wide string equivalent of the input UTF-8 string.

Definition at line 34 of file win-utils.hpp.

◆ to_int64()

std::optional< int64_t > mal_toolkit::to_int64 ( std::string_view str)
inline

Convert a string_view to an optional int64_t.

Converts the given string_view to an int64_t using the strtoll function. If the conversion is successful, returns an optional containing the result, otherwise returns an empty optional.

Parameters
strThe string_view to convert.
Returns
An optional containing the converted int64_t or an empty optional if conversion fails.

Definition at line 21 of file converter.hpp.

◆ to_long_double()

std::optional< long double > mal_toolkit::to_long_double ( std::string_view str)
inline

Convert a string_view to an optional long double.

Converts the given string_view to a long double using the strtold function. If the conversion is successful, returns an optional containing the result, otherwise returns an empty optional.

Parameters
strThe string_view to convert.
Returns
An optional containing the converted long double or an empty optional if conversion fails.

Definition at line 65 of file converter.hpp.

◆ to_uint64()

std::optional< uint64_t > mal_toolkit::to_uint64 ( std::string_view str)
inline

Convert a string_view to an optional uint64_t.

Converts the given string_view to a uint64_t using the strtoull function. If the conversion is successful, returns an optional containing the result, otherwise returns an empty optional.

Parameters
strThe string_view to convert.
Returns
An optional containing the converted uint64_t or an empty optional if conversion fails.

Definition at line 43 of file converter.hpp.

◆ trim()

std::string mal_toolkit::trim ( std::string const & s)
inlinenoexcept

Trims leading and trailing whitespace from a string.

Parameters
sThe input string.
Returns
A new string with leading and trailing whitespace removed.

Definition at line 81 of file string.hpp.

Here is the call graph for this function:

◆ trimview()

std::string_view mal_toolkit::trimview ( std::string_view const s)
constexprnoexcept

Trims leading and trailing whitespace from a string view.

Parameters
sThe input string view.
Returns
A new string view with leading and trailing whitespace removed.

Definition at line 61 of file string.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uint16_to_bytes()

ByteArray mal_toolkit::uint16_to_bytes ( const uint16_t value)
inlinenodiscard

Convert a uint16_t value to a ByteArray using little-endian byte order.

This function converts a uint16_t value to a ByteArray of appropriate size, using little-endian byte order.

Parameters
valueThe uint16_t value to convert.
Returns
A ByteArray containing the byte representation of the uint16_t value.

Definition at line 422 of file byte-helper.hpp.

◆ uint32_to_bytes()

ByteArray mal_toolkit::uint32_to_bytes ( const uint32_t value)
inlinenodiscard

Convert a uint32_t value to a ByteArray using little-endian byte order.

This function converts a uint32_t value to a ByteArray of appropriate size, using little-endian byte order.

Parameters
valueThe uint32_t value to convert.
Returns
A ByteArray containing the byte representation of the uint32_t value.

Definition at line 446 of file byte-helper.hpp.

Here is the caller graph for this function:

◆ uint64_to_bytes()

ByteArray mal_toolkit::uint64_to_bytes ( const uint64_t value)
inlinenodiscard

Convert a uint64_t value to a ByteArray using little-endian byte order.

This function converts a uint64_t value to a ByteArray of appropriate size, using little-endian byte order.

Parameters
valueThe uint64_t value to convert.
Returns
A ByteArray containing the byte representation of the uint64_t value.

Definition at line 470 of file byte-helper.hpp.

◆ wstring_to_string()

std::string mal_toolkit::wstring_to_string ( std::wstring_view const wstr)
inline

Converts a wide string (UTF16) to a UTF-8 string.

Parameters
wstrThe input wide string.
Returns
The UTF-8 string equivalent of the input wide string.

Definition at line 18 of file win-utils.hpp.