ADTF  3.18.2
BitSerializer

Bit Serializer Class. More...

Public Member Functions

 BitSerializer (void *data, size_t data_size)
 Constructor.
 
 BitSerializer ()
 Default Constructor.
 
template<typename T >
a_util::result::Result read (size_t start_bit, size_t bit_length, T *value, Endianess endianess=get_platform_endianess())
 Read value from bitfield. More...
 
template<typename T >
a_util::result::Result write (size_t start_bit, size_t bit_length, T value, Endianess endianess=get_platform_endianess())
 Write value to bitfield. More...
 

Private Member Functions

a_util::result::Result checkForInvalidArguments (size_t start_bit, size_t bit_length, size_t size_variable)
 Check if the parameters for the reading and writing access are valid. More...
 

Private Attributes

uint8_t * _buffer
 internal buffer
 
size_t _buffer_bytes
 size of internal buffer in bytes
 
size_t _buffer_bits
 size of internal buffer in bits
 

Detailed Description

Member Function Documentation

◆ checkForInvalidArguments()

a_util::result::Result checkForInvalidArguments ( size_t  start_bit,
size_t  bit_length,
size_t  size_variable 
)
inlineprivate

Check if the parameters for the reading and writing access are valid.

The variable to read from or into might be too small and the accessed region of the memory buffer might be out of range.

Parameters
[in]start_bitBit position to start reading from. The least significant bit has the index 0.
[in]bit_lengthNumber of bits to read.
[in]size_variableSize of the variable to read into or write from.
Returns
Returns a standard result code.

Definition at line 708 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/ddl/codec/bitserializer.h.

References BitSerializer::_buffer, and BitSerializer::_buffer_bits.

Referenced by BitSerializer::read(), and BitSerializer::write().

◆ read()

a_util::result::Result read ( size_t  start_bit,
size_t  bit_length,
T *  value,
Endianess  endianess = get_platform_endianess() 
)
inline

Read value from bitfield.

Value can be of type tFloat or an unsigned or signed integer.

....|...*****|********|**......|.... Buffer (index 0 on the right end side) |_______________| bit_length ^ | start_bit

Parameters
[in]start_bitBit position to start reading from. The least significant bit has the index 0.
[in]bit_lengthNumber of bits to read.
[out]valuePointer to the variable to store the read value in.
[in]endianessParameter describing the endianess of the bitfield to read from.
Returns
Returns a standard result code.

Definition at line 644 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/ddl/codec/bitserializer.h.

References BitSerializer::_buffer, and BitSerializer::checkForInvalidArguments().

Referenced by ddl::codec::detail::readBits().

◆ write()

a_util::result::Result write ( size_t  start_bit,
size_t  bit_length,
value,
Endianess  endianess = get_platform_endianess() 
)
inline

Write value to bitfield.

Value can be of type tFloat or an unsigned or signed integer.

....|...*****|********|**......|.... Buffer (index 0 on the right end side) |_______________| bit_length ^ | start_bit

Parameters
[in]start_bitBit position to start writing to. The least significant bit has the index 0.
[in]bit_lengthNumber of bits to write.
[out]valueValue to write to the bitfield.
[in]endianessParameter describing the endianess of the bitfield to write to.
Returns
Returns a standard result code.

Definition at line 675 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/ddl/codec/bitserializer.h.

References BitSerializer::_buffer, and BitSerializer::checkForInvalidArguments().

Referenced by ddl::codec::detail::writeBits().