ADTF
|
Serves as component for memory access and management. More...
Classes | |
class | StackPtr |
A smart pointer allocating its memory only on the stack. More... | |
class | MemoryBuffer |
Memory buffer class to encapsulate and manage raw contiguously memory. More... | |
class | BitSerializer |
Bit Serializer Class. More... | |
Enumerations | |
enum | Endianess { bit_little_endian = 1 , bit_big_endian = 2 } |
Enum describing the endianess. | |
Functions | |
template<typename T , std::size_t StackSize, std::size_t Alignment> | |
void | swap (StackPtr< T, StackSize, Alignment > &lhs, StackPtr< T, StackSize, Alignment > &rhs) |
Swap storages of two objects of type StackPtr . More... | |
template<typename T , std::size_t StackSize, std::size_t Alignment> | |
bool | operator!= (const StackPtr< T, StackSize, Alignment > &lhs, const StackPtr< T, StackSize, Alignment > &rhs) |
Compare for inequality. More... | |
template<typename T , std::size_t StackSize = sizeof(T), std::size_t Alignment = alignof(std::size_t), typename... Args> | |
constexpr auto | makeStackPtr (Args &&... args) -> StackPtr< T, StackSize, Alignment > |
Create a new StackPtr . More... | |
template<typename T , std::size_t StackSize, std::size_t Alignment> | |
bool | operator== (const StackPtr< T, StackSize, Alignment > &lhs, const StackPtr< T, StackSize, Alignment > &rhs) |
bool | copy (void *dest, std::size_t dest_size, const void *source, std::size_t bytes_to_copy) |
Portable safe memcopy. More... | |
bool | copy (void *dest, const void *source, std::size_t bytes_to_copy) |
Portable memcopy. More... | |
bool | copy (MemoryBuffer &buffer, const void *source, std::size_t bytes_to_copy) |
Copies a buffer into a MemoryBuffer instance, allocating memory if neccessary. More... | |
bool | set (void *dest, std::size_t dest_size, std::uint8_t value, std::size_t bytes_to_set) |
Portable safe memset. More... | |
bool | set (void *dest, std::uint8_t value, std::size_t bytes_to_set) |
Portable memset. More... | |
bool | set (MemoryBuffer &buffer, std::uint8_t value, std::size_t bytes_to_set) |
memset for a MemoryBuffer instance, allocating memory if neccessary More... | |
bool | zero (void *dest, std::size_t dest_size, std::size_t bytes_to_zero) |
Portable safe memzero. More... | |
bool | zero (void *dest, std::size_t bytes_to_zero) |
Portable memzero. More... | |
bool | zero (MemoryBuffer &buffer, std::size_t bytes_to_zero) |
memzero for a MemoryBuffer instance, allocating memory if neccessary More... | |
int | compare (const void *buf1, std::size_t buf1_size, const void *buf2, std::size_t buf2_size) |
Portable safe memcmp. More... | |
bool | isZero (const void *buffer, std::size_t buffer_size) |
Check whether the given memory range is entirely zero-initialized. More... | |
bool | swapEndianess (bool value) |
Swap the byte order of parameter value . More... | |
std::int8_t | swapEndianess (std::int8_t value) |
Swap the byte order of parameter value . More... | |
std::uint8_t | swapEndianess (std::uint8_t value) |
Swap the byte order of parameter value . More... | |
std::int16_t | swapEndianess (std::int16_t value) |
Swap the byte order of parameter value . More... | |
std::uint16_t | swapEndianess (std::uint16_t value) |
Swap the byte order of parameter value . More... | |
std::int32_t | swapEndianess (std::int32_t value) |
Swap the byte order of parameter value . More... | |
std::uint32_t | swapEndianess (std::uint32_t value) |
Swap the byte order of parameter value . More... | |
std::int64_t | swapEndianess (std::int64_t value) |
Swap the byte order of parameter value . More... | |
std::uint64_t | swapEndianess (std::uint64_t value) |
Swap the byte order of parameter value . More... | |
bool | operator== (const MemoryBuffer &lhs, const MemoryBuffer &rhs) |
Compare content of the managed memory of two memory buffer objects for equality. More... | |
bool | operator!= (const MemoryBuffer &lhs, const MemoryBuffer &rhs) |
Compare content of the managed memory of two memory buffer objects for inequality. More... | |
template<class T , class... Args> | |
_Unique_if< T >::_Single_object | make_unique (Args &&... args) |
Compatibility to C++14 std::make_unique for non-array types. More... | |
template<class T > | |
_Unique_if< T >::_Unknown_bound | make_unique (size_t n) |
Compatibility to C++14 std::make_unique for array types. More... | |
template<class T , class... Args> | |
_Unique_if< T >::_Known_bound | make_unique (Args &&...)=delete |
Compatibility to C++14 std::make_unique to disallow construction of arrays of known bound. More... | |
Endianess | get_platform_endianess () |
Returns the endianess of the platform. More... | |
Serves as component for memory access and management.
int a_util::memory::compare | ( | const void * | buf1, |
std::size_t | buf1_size, | ||
const void * | buf2, | ||
std::size_t | buf2_size | ||
) |
Portable safe memcmp.
[in] | buf1 | First buffer to compare |
[in] | buf1_size | Available bytes in the first memory buffer |
[in] | buf2 | Second buffer to compare |
[in] | buf2_size | Available bytes in the second memory buffer |
<0 | buf1 is less than buf2 |
>0 | buf1 is greater than buf2 |
0 | both buffers are equal |
std::invalid_argument | if either of the buffers is a nullptr or the sizes are different |
bool a_util::memory::copy | ( | MemoryBuffer & | buffer, |
const void * | source, | ||
std::size_t | bytes_to_copy | ||
) |
Copies a buffer into a MemoryBuffer instance, allocating memory if neccessary.
[out] | buffer | Destination memory buffer |
[in] | source | Pointer to source buffer |
[in] | bytes_to_copy | Number of bytes to copy from the source buffer |
true | if successful, false if source is nullptr or allocation fails |
bool a_util::memory::copy | ( | void * | dest, |
const void * | source, | ||
std::size_t | bytes_to_copy | ||
) |
Portable memcopy.
[out] | dest | Pointer to destination buffer |
[in] | source | Pointer to source buffer |
[in] | bytes_to_copy | Number of bytes to copy from source buffer to dest buffer |
true | if copying is sucessful, false if either of the pointer arguments is nullptr |
bool a_util::memory::copy | ( | void * | dest, |
std::size_t | dest_size, | ||
const void * | source, | ||
std::size_t | bytes_to_copy | ||
) |
Portable safe memcopy.
[out] | dest | Pointer to destination buffer |
[in] | dest_size | Available bytes in dest |
[in] | source | Pointer to source buffer |
[in] | bytes_to_copy | Number of bytes to copy from source buffer to dest buffer |
true | if copying was successful |
false | if either of the pointer arguments is nullptr or bytes_to_copy > dest_size |
Referenced by ConverterBase< T >::copyBytesFromBuffer(), ddl::access_element::getArrayValue(), ddl::access_element::getStructValue(), ConverterBase< T >::readSignal(), ddl::access_element::setStructValue(), and ConverterBase< T >::writeSignal().
Endianess a_util::memory::get_platform_endianess | ( | ) |
Returns the endianess of the platform.
Referenced by ConverterBase< T >::readSignal().
bool a_util::memory::isZero | ( | const void * | buffer, |
std::size_t | buffer_size | ||
) |
Check whether the given memory range is entirely zero-initialized.
[in] | buffer | Pointer to beginning of buffer to check for zero-initialized values |
[in] | buffer_size | Size of the buffer |
true | if all values of buffer are zero-initialized, false otherwise |
_Unique_if<T>::_Single_object a_util::memory::make_unique | ( | Args &&... | args | ) |
Compatibility to C++14 std::make_unique for non-array types.
T | Type to create |
Args | Arguments types matching constructor argument types of type T |
[in] | args | List of arguments passed to the constructor of type T |
A_UTIL_ENABLE_MAKE_UNIQUE
in case the platform check mistakenly identifies the existance of std::make_unique
Definition at line 68 of file unique_ptr.h.
|
delete |
Compatibility to C++14 std::make_unique to disallow construction of arrays of known bound.
T | Type of array of known bound |
Args | Ignored |
A_UTIL_ENABLE_MAKE_UNIQUE
in case the platform check mistakenly identifies the existance of std::make_unique
_Unique_if<T>::_Unknown_bound a_util::memory::make_unique | ( | size_t | n | ) |
Compatibility to C++14 std::make_unique for array types.
T | Type to create an array of unknown bound |
[in] | n | Size of the array |
A_UTIL_ENABLE_MAKE_UNIQUE
in case the platform check mistakenly identifies the existance of std::make_unique
Definition at line 88 of file unique_ptr.h.
|
inlineconstexpr |
Create a new StackPtr
.
Args | Types matching the argument list for construction of type T |
T | The storaged type - must be default and move constructible |
StackSize | Size of the stack to allocate - must at least be the sizeof the object of type T . |
Alignment | Alignment of the storage |
[in] | args | Forwarded to constructor of type T |
StackPtr
managing instantiated object of type T
Definition at line 230 of file stack_ptr_impl.h.
bool a_util::memory::operator!= | ( | const MemoryBuffer & | lhs, |
const MemoryBuffer & | rhs | ||
) |
Compare content of the managed memory of two memory buffer objects for inequality.
[in] | lhs | Left-hand side object |
[in] | rhs | Right-hand side object |
true
if the memory content is not the same, false
otherwise.
|
inline |
Compare for inequality.
T | Managed type |
StackSize | Size the managed type occupies |
Alignment | Byte alignment of the storage |
[in] | lhs | Left hand side object |
[in] | rhs | Right hand side object |
true
if both objects are inequal, false
otherwise Definition at line 223 of file stack_ptr_impl.h.
bool a_util::memory::operator== | ( | const MemoryBuffer & | lhs, |
const MemoryBuffer & | rhs | ||
) |
Compare content of the managed memory of two memory buffer objects for equality.
[in] | lhs | Left-hand side object |
[in] | rhs | Right-hand side object |
true
if the memory content is the same, false
otherwise. bool a_util::memory::set | ( | MemoryBuffer & | buffer, |
std::uint8_t | value, | ||
std::size_t | bytes_to_set | ||
) |
memset for a MemoryBuffer instance, allocating memory if neccessary
[out] | buffer | Destination memory buffer |
[in] | bytes_to_set | Number of bytes to set at the destination |
[in] | value | Byte value assigned to the buffer |
true | if successful, false if memory allocation fails |
bool a_util::memory::set | ( | void * | dest, |
std::size_t | dest_size, | ||
std::uint8_t | value, | ||
std::size_t | bytes_to_set | ||
) |
Portable safe memset.
[out] | dest | Pointer to destination buffer |
[in] | dest_size | Available bytes in the destination memory buffer |
[in] | value | Byte value assigned to the buffer |
[in] | bytes_to_set | Number of bytes to set at the destination |
true | if successful, false if dest is nullptr or bytes_to_set > dest_size |
bool a_util::memory::set | ( | void * | dest, |
std::uint8_t | value, | ||
std::size_t | bytes_to_set | ||
) |
Portable memset.
[out] | dest | Pointer to destination buffer |
[in] | value | Byte value assigned to the buffer |
[in] | bytes_to_set | Number of bytes to set at the destination |
true | if sucessful, false if dest is nullptr |
|
inline |
Swap storages of two objects of type StackPtr
.
T | The storaged type |
StackSize | Size of allocated storage size |
Alignment | Alignment of the storage |
[in,out] | lhs | Left hand side object |
[in,out] | rhs | Right hand side object |
StackSize
this operation might be very time consuming. Definition at line 191 of file stack_ptr_impl.h.
References StackPtr< T, StackSize, Alignment >::swap().
Referenced by StackPtr< T, StackSize, Alignment >::swap().
bool a_util::memory::swapEndianess | ( | bool | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::int16_t a_util::memory::swapEndianess | ( | std::int16_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::int32_t a_util::memory::swapEndianess | ( | std::int32_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::int64_t a_util::memory::swapEndianess | ( | std::int64_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::int8_t a_util::memory::swapEndianess | ( | std::int8_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::uint16_t a_util::memory::swapEndianess | ( | std::uint16_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::uint32_t a_util::memory::swapEndianess | ( | std::uint32_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::uint64_t a_util::memory::swapEndianess | ( | std::uint64_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
std::uint8_t a_util::memory::swapEndianess | ( | std::uint8_t | value | ) |
Swap the byte order of parameter value
.
value | with its byte order swapped |
bool a_util::memory::zero | ( | MemoryBuffer & | buffer, |
std::size_t | bytes_to_zero | ||
) |
memzero for a MemoryBuffer instance, allocating memory if neccessary
[out] | buffer | Destination memory buffer |
[in] | bytes_to_zero | Number of bytes to zero-assign |
true | if succesful, false if memory allocation fails |
bool a_util::memory::zero | ( | void * | dest, |
std::size_t | bytes_to_zero | ||
) |
Portable memzero.
[out] | dest | Pointer to destination buffer |
[in] | bytes_to_zero | Number of bytes to zero-assign |
true | if successful, false if dest is nullptr |
bool a_util::memory::zero | ( | void * | dest, |
std::size_t | dest_size, | ||
std::size_t | bytes_to_zero | ||
) |
Portable safe memzero.
[out] | dest | Pointer to the destination buffer |
[in] | dest_size | Available bytes in the destination memory buffer |
[in] | bytes_to_zero | Number of bytes to zero-assign |
true | if successful, false if dest is nullptr or bytes_to_zero > dest_size |
Referenced by ddl::access_element::reset().