Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
uavcan::ScalarCodec Class Reference

#include <scalar_codec.hpp>

Public Member Functions

template<unsigned BitLen, typename T >
int decode (T &value)
 
template<unsigned BitLen, typename T >
int encode (const T value)
 
 ScalarCodec (BitStream &stream)
 

Private Member Functions

int decodeBytesImpl (uint8_t *bytes, unsigned bitlen)
 
int encodeBytesImpl (uint8_t *bytes, unsigned bitlen)
 
template<unsigned BitLen, typename T >
void validate ()
 

Static Private Member Functions

template<unsigned BitLen, typename T >
static EnableIf<((sizeof(T) *8)==BitLen)>::Type clearExtraBits (T &)
 
template<unsigned BitLen, typename T >
static EnableIf<((sizeof(T) *8) > BitLen)>::Type clearExtraBits (T &value)
 
template<unsigned BitLen, unsigned Size>
static EnableIf<(BitLen<=8)>::Type convertByteOrder (uint8_t(&)[Size])
 
template<unsigned BitLen, unsigned Size>
static EnableIf<(BitLen > 8)>::Type convertByteOrder (uint8_t(&bytes)[Size])
 
template<unsigned BitLen, typename T >
static EnableIf<!static_cast< bool >NumericTraits< T >::IsSigned)||((sizeof(T) *8)==BitLen)>::Type fixTwosComplement (T &)
 
template<unsigned BitLen, typename T >
static EnableIf< static_cast< bool >NumericTraits< T >::IsSigned) &&((sizeof(T) *8) > BitLen)>::Type fixTwosComplement (T &value)
 
static void swapByteOrder (uint8_t *bytes, unsigned len)
 

Private Attributes

BitStreamstream_
 

Detailed Description

This class implements fast encoding/decoding of primitive type scalars into/from bit arrays. It uses the compile-time type information to eliminate run-time operations where possible.

Definition at line 20 of file scalar_codec.hpp.

Constructor & Destructor Documentation

◆ ScalarCodec()

uavcan::ScalarCodec::ScalarCodec ( BitStream stream)
inlineexplicit

Definition at line 85 of file scalar_codec.hpp.

Member Function Documentation

◆ clearExtraBits() [1/2]

template<unsigned BitLen, typename T >
static EnableIf<((sizeof(T) * 8) == BitLen)>::Type uavcan::ScalarCodec::clearExtraBits ( T &  )
inlinestaticprivate

Definition at line 71 of file scalar_codec.hpp.

◆ clearExtraBits() [2/2]

template<unsigned BitLen, typename T >
static EnableIf<((sizeof(T) * 8) > BitLen)>::Type uavcan::ScalarCodec::clearExtraBits ( T &  value)
inlinestaticprivate

Definition at line 64 of file scalar_codec.hpp.

◆ convertByteOrder() [1/2]

template<unsigned BitLen, unsigned Size>
static EnableIf<(BitLen <= 8)>::Type uavcan::ScalarCodec::convertByteOrder ( uint8_t(&)  [Size])
inlinestaticprivate

Definition at line 45 of file scalar_codec.hpp.

◆ convertByteOrder() [2/2]

template<unsigned BitLen, unsigned Size>
static EnableIf<(BitLen > 8)>::Type uavcan::ScalarCodec::convertByteOrder ( uint8_t(&)  bytes[Size])
inlinestaticprivate

Definition at line 28 of file scalar_codec.hpp.

◆ decode()

template<unsigned BitLen, typename T >
int uavcan::ScalarCodec::decode ( T &  value)

Definition at line 114 of file scalar_codec.hpp.

◆ decodeBytesImpl()

int uavcan::ScalarCodec::decodeBytesImpl ( uint8_t bytes,
unsigned  bitlen 
)
private

Definition at line 32 of file uc_scalar_codec.cpp.

◆ encode()

template<unsigned BitLen, typename T >
int uavcan::ScalarCodec::encode ( const T  value)

Definition at line 99 of file scalar_codec.hpp.

◆ encodeBytesImpl()

int uavcan::ScalarCodec::encodeBytesImpl ( uint8_t bytes,
unsigned  bitlen 
)
private

Definition at line 21 of file uc_scalar_codec.cpp.

◆ fixTwosComplement() [1/2]

template<unsigned BitLen, typename T >
static EnableIf<!static_cast<bool>NumericTraits<T>::IsSigned) || ((sizeof(T) * 8) == BitLen)>::Type uavcan::ScalarCodec::fixTwosComplement ( T &  )
inlinestaticprivate

Definition at line 60 of file scalar_codec.hpp.

◆ fixTwosComplement() [2/2]

template<unsigned BitLen, typename T >
static EnableIf<static_cast<bool>NumericTraits<T>::IsSigned) && ((sizeof(T) * 8) > BitLen)>::Type uavcan::ScalarCodec::fixTwosComplement ( T &  value)
inlinestaticprivate

Definition at line 49 of file scalar_codec.hpp.

◆ swapByteOrder()

void uavcan::ScalarCodec::swapByteOrder ( uint8_t bytes,
unsigned  len 
)
staticprivate

Definition at line 10 of file uc_scalar_codec.cpp.

◆ validate()

template<unsigned BitLen, typename T >
void uavcan::ScalarCodec::validate ( )
inlineprivate

Definition at line 74 of file scalar_codec.hpp.

Member Data Documentation

◆ stream_

BitStream& uavcan::ScalarCodec::stream_
private

Definition at line 22 of file scalar_codec.hpp.


The documentation for this class was generated from the following files:


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:05