CoreComponents 4.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Bits and Bytes

Bit coding and byte order More...

Collaboration diagram for Bits and Bytes:

Classes

class  Bit< T, j, i >
 Select the bits i to j from a word of type T. More...
class  Base64
 Base64 codec. More...
class  Binary< byteOrder >
 Read and write binary data structures. More...
class  BitSink
 Bit-wise write to a ByteSink. More...
class  BitSource
 Read from a ByteSource bit-vise. More...

Typedefs

using uint8_t = std::uint8_t
 8 bit unsigned word
using uint16_t = std::uint16_t
 16 bit unsigned word
using uint32_t = std::uint32_t
 32 bit unsigned word
using uint64_t = std::uint64_t
 64 bit unsigned word
using int8_t = std::int8_t
 8 bit signed word
using int16_t = std::int16_t
 16 bit signed word
using int32_t = std::int32_t
 32 bit signed word
using int64_t = std::int64_t
 64 bit signed word

Enumerations

enum class  ByteOrder { LittleEndian = 1 , BigEndian = 0 }
 Byte order. More...

Functions

template<class B, class A>
union_cast (A a)
 Optimization safe raw type casting.
ByteOrder localEndian ()
 Return the current system byte order
template<class T>
byteSwap (T x)
 Swap endianess of x.
template<class T>
endianGate (T x, const ByteOrder channelByteOrder=ByteOrder::BigEndian)
 Swap endianess of x from channelByteOrder to system byte order.
template<unsigned j, unsigned i = j, class T, class V>
void bitAssign (T &word, V newValue)
 Access bits i to j in word.
template<class T>
bitmask (unsigned n)
 Get bitmask of n bits.
template<class T>
bit (unsigned j, unsigned i, const T &word)
 Get bits i to j in word.
template<unsigned j, unsigned i = j, class T>
bit (const T &word)
 Get bits i to j in word.

Detailed Description

Bit coding and byte order

Typedef Documentation

◆ uint8_t

using uint8_t = std::uint8_t

8 bit unsigned word

◆ uint16_t

using uint16_t = std::uint16_t

16 bit unsigned word

◆ uint32_t

using uint32_t = std::uint32_t

32 bit unsigned word

◆ uint64_t

using uint64_t = std::uint64_t

64 bit unsigned word

◆ int8_t

using int8_t = std::int8_t

8 bit signed word

◆ int16_t

using int16_t = std::int16_t

16 bit signed word

◆ int32_t

using int32_t = std::int32_t

32 bit signed word

◆ int64_t

using int64_t = std::int64_t

64 bit signed word

Enumeration Type Documentation

◆ ByteOrder

enum class ByteOrder
strong

Byte order.

Todo
rename to Endian::Little and Endian::Big
Enumerator
LittleEndian 

Low order byte precedes the high order byte.

BigEndian 

High order byte precedes the low order byte.

Function Documentation

◆ union_cast()

template<class B, class A>
B union_cast ( A a)

Optimization safe raw type casting.

◆ localEndian()

ByteOrder localEndian ( )

Return the current system byte order

◆ byteSwap()

template<class T>
T byteSwap ( T x)

Swap endianess of x.

◆ endianGate()

template<class T>
T endianGate ( T x,
const ByteOrder channelByteOrder = ByteOrder::BigEndian )

Swap endianess of x from channelByteOrder to system byte order.

Template Parameters
TUnsigned integer type

◆ bitAssign()

template<unsigned j, unsigned i = j, class T, class V>
void bitAssign ( T & word,
V newValue )

Access bits i to j in word.

◆ bitmask()

template<class T>
T bitmask ( unsigned n)

Get bitmask of n bits.

◆ bit() [1/2]

template<class T>
T bit ( unsigned j,
unsigned i,
const T & word )

Get bits i to j in word.

◆ bit() [2/2]

template<unsigned j, unsigned i = j, class T>
T bit ( const T & word)

Get bits i to j in word.