Common utilities and macros for the Uniot Core.
More...
|
| #define | COUNT_OF(arr) |
| | Calculates the number of elements in a statically allocated array.
|
| |
| #define | ARRAY_ELEMENT_SAFE(arr, index) |
| | Provides safe array access with bounds checking.
|
| |
| #define | FOURCC(name) |
| | Creates a FourCC constant from a string literal.
|
| |
| #define | ALIAS_IMPLICIT_FUNCTION(high, low) |
| | Creates an alias for a function that forwards all arguments implicitly.
|
| |
| #define | ALIAS_EXPLICIT_FUNCTION(high, low) |
| | Creates an alias for a template function that forwards all arguments explicitly.
|
| |
|
| template<typename... Args> |
| void | UNUSED (Args &&...args) |
| | Utility function to mark function parameters as intentionally unused.
|
| |
| uint32_t | CRC32 (const void *data, size_t length, uint32_t crc=0) |
| | Calculates CRC32-C (Castagnoli) checksum for data integrity verification.
|
| |
| template<typename T> |
| using | uniot::UniquePointer = std::unique_ptr<T> |
| | Type alias for std::unique_ptr with cleaner syntax.
|
| |
| template<typename T> |
| using | uniot::SharedPointer = std::shared_ptr<T> |
| | Type alias for std::shared_ptr with cleaner syntax.
|
| |
| template<typename T_First, typename T_Second> |
| using | uniot::Pair = std::pair<T_First, T_Second> |
| | Type alias for std::pair with cleaner syntax.
|
| |
| template<typename T, typename... Args> |
| auto | uniot::MakeShared (Args &&...args) -> decltype(std::make_shared< T >(std::forward< Args >(args)...)) |
| | Creates a shared pointer instance, alias for std::make_shared.
|
| |
| template<typename T, typename... Args> |
| auto | uniot::MakeUnique (Args &&...args) -> decltype(std::make_unique< T >(std::forward< Args >(args)...)) |
| | Creates a unique pointer instance, alias for std::make_unique.
|
| |
| template<typename... Args> |
| auto | uniot::MakePair (Args &&...args) -> decltype(std::make_pair(std::forward< Args >(args)...)) |
| | Creates a pair instance, alias for std::make_pair.
|
| |
Common utilities and macros for the Uniot Core.
◆ ALIAS_EXPLICIT_FUNCTION
| #define ALIAS_EXPLICIT_FUNCTION |
( |
| high, |
|
|
| low ) |
Value: template <typename T, typename... Args> \
inline auto high(Args &&...args) -> decltype(low<T>(std::forward<Args>(args)...)) { \
return low<T>(std::forward<Args>(args)...); \
}
Creates an alias for a template function that forwards all arguments explicitly.
Similar to ALIAS_IMPLICIT_FUNCTION but maintains the explicit template parameter.
- Parameters
-
| high | New function name |
| low | Original function being aliased |
◆ ALIAS_IMPLICIT_FUNCTION
| #define ALIAS_IMPLICIT_FUNCTION |
( |
| high, |
|
|
| low ) |
Value: template <typename... Args> \
inline auto high(Args &&...args) -> decltype(low(std::forward<Args>(args)...)) { \
return low(std::forward<Args>(args)...); \
}
Creates an alias for a function that forwards all arguments implicitly.
Used to expose standard library functions through a custom namespace with the same parameter forwarding behavior.
- Parameters
-
| high | New function name |
| low | Original function being aliased |
◆ ARRAY_ELEMENT_SAFE
| #define ARRAY_ELEMENT_SAFE |
( |
| arr, |
|
|
| index ) |
Value:
#define COUNT_OF(arr)
Calculates the number of elements in a statically allocated array.
Definition Common.h:88
Provides safe array access with bounds checking.
Returns the element at the specified index if within bounds, otherwise returns the last element.
◆ COUNT_OF
Value:(sizeof(arr) / sizeof(arr[0]))
Calculates the number of elements in a statically allocated array.
◆ FOURCC
Value:
#define ARRAY_ELEMENT_SAFE(arr, index)
Provides safe array access with bounds checking.
Definition Common.h:97
Creates a four-character code (FourCC) value from template parameters.
Definition Common.h:43
Creates a FourCC constant from a string literal.
Uses up to the first four characters of the string to create a unique identifier. If the string has fewer than 4 characters, the remaining positions will be filled with the last character.
◆ Pair
template<typename T_First, typename T_Second>
Type alias for std::pair with cleaner syntax.
- Template Parameters
-
| T_First | Type of the first element |
| T_Second | Type of the second element |
◆ SharedPointer
Type alias for std::shared_ptr with cleaner syntax.
- Template Parameters
-
| T | Type of the managed object |
◆ UniquePointer
Type alias for std::unique_ptr with cleaner syntax.
- Template Parameters
-
| T | Type of the managed object |
◆ CRC32()
| uint32_t CRC32 |
( |
const void * | data, |
|
|
size_t | length, |
|
|
uint32_t | crc = 0 ) |
|
inline |
Calculates CRC32-C (Castagnoli) checksum for data integrity verification.
This function implements the CRC-32C polynomial used in iSCSI standard.
- Parameters
-
| data | Pointer to data buffer |
| length | Size of data buffer in bytes |
| crc | Initial CRC value (defaults to 0) |
- Return values
-
| uint32_t | CRC32 checksum value |
◆ MakePair()
template<typename... Args>
| auto uniot::MakePair |
( |
Args &&... | args | ) |
-> decltype(std::make_pair(std::forward<Args>(args)...)) |
|
inline |
Creates a pair instance, alias for std::make_pair.
◆ MakeShared()
template<typename T, typename... Args>
| auto uniot::MakeShared |
( |
Args &&... | args | ) |
-> decltype(std::make_shared<T>(std::forward<Args>(args)...)) |
|
inline |
Creates a shared pointer instance, alias for std::make_shared.
◆ MakeUnique()
template<typename T, typename... Args>
| auto uniot::MakeUnique |
( |
Args &&... | args | ) |
-> decltype(std::make_unique<T>(std::forward<Args>(args)...)) |
|
inline |
Creates a unique pointer instance, alias for std::make_unique.
◆ UNUSED()
template<typename... Args>
| void UNUSED |
( |
Args &&... | args | ) |
|
|
inline |
Utility function to mark function parameters as intentionally unused.
Prevents compiler warnings about unused parameters by explicitly consuming them.
- Template Parameters
-
| Args | Variadic template parameter types |
- Parameters
-
| args | Parameters to mark as used |