ADTF  3.14.3
a_util::memory Namespace Reference

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

Detailed Description

Serves as component for memory access and management.

Function Documentation

◆ compare()

int a_util::memory::compare ( const void *  buf1,
std::size_t  buf1_size,
const void *  buf2,
std::size_t  buf2_size 
)

Portable safe memcmp.

Parameters
[in]buf1First buffer to compare
[in]buf1_sizeAvailable bytes in the first memory buffer
[in]buf2Second buffer to compare
[in]buf2_sizeAvailable bytes in the second memory buffer
Return values
<0buf1 is less than buf2
>0buf1 is greater than buf2
0both buffers are equal
Exceptions
std::invalid_argumentif either of the buffers is a nullptr or the sizes are different

◆ copy() [1/3]

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.

Parameters
[out]bufferDestination memory buffer
[in]sourcePointer to source buffer
[in]bytes_to_copyNumber of bytes to copy from the source buffer
Return values
trueif successful, false if source is nullptr or allocation fails

◆ copy() [2/3]

bool a_util::memory::copy ( void *  dest,
const void *  source,
std::size_t  bytes_to_copy 
)

Portable memcopy.

Parameters
[out]destPointer to destination buffer
[in]sourcePointer to source buffer
[in]bytes_to_copyNumber of bytes to copy from source buffer to dest buffer
Return values
trueif copying is sucessful, false if either of the pointer arguments is nullptr

◆ copy() [3/3]

bool a_util::memory::copy ( void *  dest,
std::size_t  dest_size,
const void *  source,
std::size_t  bytes_to_copy 
)

Portable safe memcopy.

Parameters
[out]destPointer to destination buffer
[in]dest_sizeAvailable bytes in dest
[in]sourcePointer to source buffer
[in]bytes_to_copyNumber of bytes to copy from source buffer to dest buffer
Return values
trueif copying was successful
falseif 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().

◆ get_platform_endianess()

Endianess a_util::memory::get_platform_endianess ( )

Returns the endianess of the platform.

Returns
See Endianess

Referenced by ConverterBase< T >::readSignal().

◆ isZero()

bool a_util::memory::isZero ( const void *  buffer,
std::size_t  buffer_size 
)

Check whether the given memory range is entirely zero-initialized.

Parameters
[in]bufferPointer to beginning of buffer to check for zero-initialized values
[in]buffer_sizeSize of the buffer
Return values
trueif all values of buffer are zero-initialized, false otherwise

◆ make_unique() [1/3]

_Unique_if<T>::_Single_object a_util::memory::make_unique ( Args &&...  args)

Compatibility to C++14 std::make_unique for non-array types.

Template Parameters
TType to create
ArgsArguments types matching constructor argument types of type T
Parameters
[in]argsList of arguments passed to the constructor of type T
Returns
Object of non-array type T
Note
Define A_UTIL_ENABLE_MAKE_UNIQUE in case the platform check mistakenly identifies the existance of std::make_unique

Definition at line 74 of file unique_ptr.h.

◆ make_unique() [2/3]

_Unique_if<T>::_Known_bound a_util::memory::make_unique ( Args &&  ...)
delete

Compatibility to C++14 std::make_unique to disallow construction of arrays of known bound.

Template Parameters
TType of array of known bound
ArgsIgnored
Note
Define A_UTIL_ENABLE_MAKE_UNIQUE in case the platform check mistakenly identifies the existance of std::make_unique

◆ make_unique() [3/3]

_Unique_if<T>::_Unknown_bound a_util::memory::make_unique ( size_t  n)

Compatibility to C++14 std::make_unique for array types.

Template Parameters
TType to create an array of unknown bound
Parameters
[in]nSize of the array
Returns
Array of unknown bound type T
Note
Define A_UTIL_ENABLE_MAKE_UNIQUE in case the platform check mistakenly identifies the existance of std::make_unique

Definition at line 94 of file unique_ptr.h.

◆ operator!=() [1/2]

bool a_util::memory::operator!= ( const MemoryBuffer lhs,
const MemoryBuffer rhs 
)

Compare content of the managed memory of two memory buffer objects for inequality.

Parameters
[in]lhsLeft-hand side object
[in]rhsRight-hand side object
Returns
true if the memory content is not the same, false otherwise.

◆ operator!=() [2/2]

bool operator!= ( const StackPtr< T, StackSize, Alignment > &  lhs,
const StackPtr< T, StackSize, Alignment > &  rhs 
)
inline

Compare for inequality.

Template Parameters
TManaged type
StackSizeSize the managed type occupies
AlignmentByte alignment of the storage
Parameters
[in]lhsLeft hand side object
[in]rhsRight hand side object
Returns
true if both objects are inequal, false otherwise

Definition at line 217 of file stack_ptr_impl.h.

◆ operator==()

bool a_util::memory::operator== ( const MemoryBuffer lhs,
const MemoryBuffer rhs 
)

Compare content of the managed memory of two memory buffer objects for equality.

Parameters
[in]lhsLeft-hand side object
[in]rhsRight-hand side object
Returns
true if the memory content is the same, false otherwise.

◆ set() [1/3]

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

Parameters
[out]bufferDestination memory buffer
[in]bytes_to_setNumber of bytes to set at the destination
[in]valueByte value assigned to the buffer
Return values
trueif successful, false if memory allocation fails

◆ set() [2/3]

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.

Parameters
[out]destPointer to destination buffer
[in]dest_sizeAvailable bytes in the destination memory buffer
[in]valueByte value assigned to the buffer
[in]bytes_to_setNumber of bytes to set at the destination
Return values
trueif successful, false if dest is nullptr or bytes_to_set > dest_size

◆ set() [3/3]

bool a_util::memory::set ( void *  dest,
std::uint8_t  value,
std::size_t  bytes_to_set 
)

Portable memset.

Parameters
[out]destPointer to destination buffer
[in]valueByte value assigned to the buffer
[in]bytes_to_setNumber of bytes to set at the destination
Return values
trueif sucessful, false if dest is nullptr

◆ swap()

void swap ( StackPtr< T, StackSize, Alignment > &  lhs,
StackPtr< T, StackSize, Alignment > &  rhs 
)
inline

Swap storages of two objects of type StackPtr.

Template Parameters
TThe storaged type
StackSizeSize of allocated storage size
AlignmentAlignment of the storage
Parameters
[in,out]lhsLeft hand side object
[in,out]rhsRight hand side object
Note
The storages are swapped byte-by-byte, so depending on the StackSize this operation might be very time consuming.

Definition at line 185 of file stack_ptr_impl.h.

References StackPtr< T, StackSize, Alignment >::swap().

Referenced by object_enum< T, INTERFACE_TYPE, CONTAINER >::object_enum(), sample_data< T >::sample_data(), object_enum< T, INTERFACE_TYPE, CONTAINER >::operator=(), StackPtr< T, StackSize, Alignment >::swap(), and weak_object_ptr< T >::Swap().

◆ swapEndianess() [1/9]

bool a_util::memory::swapEndianess ( bool  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [2/9]

std::int16_t a_util::memory::swapEndianess ( std::int16_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [3/9]

std::int32_t a_util::memory::swapEndianess ( std::int32_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [4/9]

std::int64_t a_util::memory::swapEndianess ( std::int64_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [5/9]

std::int8_t a_util::memory::swapEndianess ( std::int8_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [6/9]

std::uint16_t a_util::memory::swapEndianess ( std::uint16_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [7/9]

std::uint32_t a_util::memory::swapEndianess ( std::uint32_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [8/9]

std::uint64_t a_util::memory::swapEndianess ( std::uint64_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ swapEndianess() [9/9]

std::uint8_t a_util::memory::swapEndianess ( std::uint8_t  value)

Swap the byte order of parameter value.

Return values
valuewith its byte order swapped

◆ zero() [1/3]

bool a_util::memory::zero ( MemoryBuffer buffer,
std::size_t  bytes_to_zero 
)

memzero for a MemoryBuffer instance, allocating memory if neccessary

Parameters
[out]bufferDestination memory buffer
[in]bytes_to_zeroNumber of bytes to zero-assign
Return values
trueif succesful, false if memory allocation fails

◆ zero() [2/3]

bool a_util::memory::zero ( void *  dest,
std::size_t  bytes_to_zero 
)

Portable memzero.

Parameters
[out]destPointer to destination buffer
[in]bytes_to_zeroNumber of bytes to zero-assign
Return values
trueif successful, false if dest is nullptr

◆ zero() [3/3]

bool a_util::memory::zero ( void *  dest,
std::size_t  dest_size,
std::size_t  bytes_to_zero 
)

Portable safe memzero.

Parameters
[out]destPointer to the destination buffer
[in]dest_sizeAvailable bytes in the destination memory buffer
[in]bytes_to_zeroNumber of bytes to zero-assign
Return values
trueif successful, false if dest is nullptr or bytes_to_zero > dest_size

Referenced by ddl::access_element::reset().


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Thu Jun 9 2022 by doxygen 1.9.1)