ADTF  3.18.2
cBitSerializer

Bit Serializer Class. More...

Public Member Functions

 cBitSerializer (cMemoryBlock *pMemoryBlock)
 Constructor.
 
 cBitSerializer (tVoid *pData, tSize nDataSize)
 Constructor.
 
 cBitSerializer ()
 Default Constructor.
 
virtual ~cBitSerializer ()
 Destructor.
 
template<typename T >
tResult Read (tSize nStartBit, tSize nBitLength, T *pValue, tInt nEndianess=PLATFORM_BYTEORDER)
 Read value from bitfield. More...
 
template<typename T >
tResult Write (tSize nStartBit, tSize nBitLength, T nValue, tInt nEndianess=PLATFORM_BYTEORDER)
 Write value to bitfield. More...
 

Private Member Functions

tResult CheckForInvalidArguments (tSize nStartBit, tSize nBitLength, tSize nSizeVariable)
 Check if the parameters for the reading and writing access are valid. More...
 

Private Attributes

tUInt8m_pBuffer
 internal buffer
 
tSize m_nBufferBytes
 size of internal buffer in bytes
 
tSize m_nBufferBits
 size of internal buffer in bits
 

Detailed Description

Member Function Documentation

◆ CheckForInvalidArguments()

tResult CheckForInvalidArguments ( tSize  nStartBit,
tSize  nBitLength,
tSize  nSizeVariable 
)
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]nStartBitBit position to start reading from. The least significant bit has the index 0.
[in]nBitLengthNumber of bits to read.
[in]nSizeVariableSize of the variable to read into or write from.
Returns
Returns a standard result code.

Definition at line 753 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/bitserializer.h.

References cBitSerializer::m_nBufferBits, cBitSerializer::m_pBuffer, RETURN_ERROR, RETURN_IF_POINTER_NULL, and RETURN_NOERROR.

Referenced by cBitSerializer::Read(), and cBitSerializer::Write().

◆ Read()

tResult Read ( tSize  nStartBit,
tSize  nBitLength,
T *  pValue,
tInt  nEndianess = PLATFORM_BYTEORDER 
)
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) |_______________| nBitLength ^ | nStartBit

Parameters
[in]nStartBitBit position to start reading from. The least significant bit has the index 0.
[in]nBitLengthNumber of bits to read.
[out]pValuePointer to the variable to store the read value in.
[in]nEndianessParameter describing the endianess of the bitfield to read from. PLATFORM_BIG_ENDIAN_8: Bitfield interpreted as Big Endian. PLATFORM_LITTLE_ENDIAN_8: Bitfield interpreted as Little Endian. PLATFORM_BYTEORDER: Endianess can be neglected.
Returns
Returns a standard result code.

Definition at line 674 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/bitserializer.h.

References cBitSerializer::CheckForInvalidArguments(), cResult::IsFailed(), cBitSerializer::m_pBuffer, and RETURN_NOERROR.

◆ Write()

tResult Write ( tSize  nStartBit,
tSize  nBitLength,
nValue,
tInt  nEndianess = PLATFORM_BYTEORDER 
)
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) |_______________| nBitLength ^ | nStartBit

Parameters
[in]nStartBitBit position to start writing to. The least significant bit has the index 0.
[in]nBitLengthNumber of bits to write.
[out]nValueValue to write to the bitfield.
[in]nEndianessParameter describing the endianess of the bitfield to write to. PLATFORM_BIG_ENDIAN_8: Bitfield interpreted as Big Endian. PLATFORM_LITTLE_ENDIAN_8: Bitfield interpreted as Little Endian. PLATFORM_BYTEORDER: Endianess can be neglected.
Returns
Returns a standard result code.

Definition at line 713 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/core/bitserializer.h.

References cBitSerializer::CheckForInvalidArguments(), cResult::IsFailed(), cBitSerializer::m_pBuffer, and RETURN_NOERROR.