BitStream
bitstream::utility Namespace Reference

Classes

struct  has_serialize
 
struct  has_serialize< std::void_t< decltype(serialize_traits< T >::serialize(std::declval< Stream & >(), std::declval< Args >()...))>, T, Stream, Args... >
 
struct  is_serialize_noexcept
 
struct  is_serialize_noexcept< std::enable_if_t< has_serialize_v< T, Stream, Args... > >, T, Stream, Args... >
 
struct  deduce_trait
 
struct  deduce_trait< std::enable_if_t< !std::is_pointer_v< std::decay_t< Trait > > &&has_serialize_v< base_t< Trait >, Stream, Trait, Args... > >, Trait, Stream, Args... >
 
struct  deduce_trait< std::enable_if_t< !std::is_pointer_v< std::decay_t< Trait > > &&has_serialize_v< std::add_const_t< base_t< Trait > >, Stream, Trait, Args... > >, Trait, Stream, Args... >
 
struct  deduce_trait< std::enable_if_t< std::is_pointer_v< std::decay_t< Trait > > &&has_serialize_v< std::add_pointer_t< base_t< Trait > >, Stream, Trait, Args... > >, Trait, Stream, Args... >
 
struct  deduce_trait< std::enable_if_t< std::is_pointer_v< std::decay_t< Trait > > &&has_serialize_v< std::add_pointer_t< std::add_const_t< base_t< Trait > > >, Stream, Trait, Args... > >, Trait, Stream, Args... >
 

Typedefs

template<typename T , typename Stream , typename... Args>
using has_serialize_t = std::void_t< decltype(serialize_traits< T >::serialize(std::declval< Stream & >(), std::declval< Args >()...))>
 
template<typename T , typename R = bool>
using is_writing_t = std::enable_if_t< T::writing, R >
 
template<typename T , typename R = bool>
using is_reading_t = std::enable_if_t< T::reading, R >
 
template<typename T >
using base_t = typename std::remove_const_t< std::remove_pointer_t< std::decay_t< T > >>
 
template<typename Trait , typename Stream , typename... Args>
using deduce_trait_t = typename deduce_trait< void, Trait, Stream, Args... >::type
 
template<typename Trait , typename Stream , typename... Args>
using has_deduce_serialize_t = has_serialize_t< deduce_trait_t< Trait, Stream, Args... >, Stream, Trait, Args... >
 

Functions

constexpr uint32_t bits_to_represent (uintmax_t n)
 
constexpr uint32_t bits_in_range (intmax_t min, intmax_t max)
 
constexpr uint32_t crc_uint32 (const uint8_t *bytes, uint32_t size)
 
constexpr uint32_t crc_uint32 (const uint8_t *checksum, const uint8_t *bytes, uint32_t size)
 
constexpr bool little_endian ()
 
uint32_t endian_swap32 (uint32_t value)
 
uint32_t to_big_endian32 (uint32_t value)
 

Variables

constexpr auto CHECKSUM_TABLE
 
template<typename T , typename Stream , typename... Args>
constexpr bool has_serialize_v = has_serialize<void, T, Stream, Args...>::value
 
template<typename T , typename Stream , typename... Args>
constexpr bool is_serialize_noexcept_v = is_serialize_noexcept<void, T, Stream, Args...>::value
 
template<typename Trait , typename Stream , typename... Args>
constexpr bool is_deduce_serialize_noexcept_v = is_serialize_noexcept_v<deduce_trait_t<Trait, Stream, Args...>, Stream, Trait, Args...>
 

Typedef Documentation

◆ base_t

template<typename T >
using bitstream::utility::base_t = typedef typename std::remove_const_t<std::remove_pointer_t<std::decay_t<T> >>

◆ deduce_trait_t

template<typename Trait , typename Stream , typename... Args>
using bitstream::utility::deduce_trait_t = typedef typename deduce_trait<void, Trait, Stream, Args...>::type

◆ has_deduce_serialize_t

template<typename Trait , typename Stream , typename... Args>
using bitstream::utility::has_deduce_serialize_t = typedef has_serialize_t<deduce_trait_t<Trait, Stream, Args...>, Stream, Trait, Args...>

◆ has_serialize_t

template<typename T , typename Stream , typename... Args>
using bitstream::utility::has_serialize_t = typedef std::void_t<decltype(serialize_traits<T>::serialize(std::declval<Stream&>(), std::declval<Args>()...))>

◆ is_reading_t

template<typename T , typename R = bool>
using bitstream::utility::is_reading_t = typedef std::enable_if_t<T::reading, R>

◆ is_writing_t

template<typename T , typename R = bool>
using bitstream::utility::is_writing_t = typedef std::enable_if_t<T::writing, R>

Function Documentation

◆ bits_in_range()

constexpr uint32_t bitstream::utility::bits_in_range ( intmax_t  min,
intmax_t  max 
)
inlineconstexpr

◆ bits_to_represent()

constexpr uint32_t bitstream::utility::bits_to_represent ( uintmax_t  n)
inlineconstexpr

◆ crc_uint32() [1/2]

constexpr uint32_t bitstream::utility::crc_uint32 ( const uint8_t *  bytes,
uint32_t  size 
)
inlineconstexpr

◆ crc_uint32() [2/2]

constexpr uint32_t bitstream::utility::crc_uint32 ( const uint8_t *  checksum,
const uint8_t *  bytes,
uint32_t  size 
)
inlineconstexpr

◆ endian_swap32()

uint32_t bitstream::utility::endian_swap32 ( uint32_t  value)
inline

◆ little_endian()

constexpr bool bitstream::utility::little_endian ( )
inlineconstexpr

◆ to_big_endian32()

uint32_t bitstream::utility::to_big_endian32 ( uint32_t  value)
inline

Variable Documentation

◆ CHECKSUM_TABLE

constexpr auto bitstream::utility::CHECKSUM_TABLE
inlineconstexpr
Initial value:
= []()
{
constexpr uint32_t POLYNOMIAL = 0xEDB88320;
std::array<uint32_t, 0x100> table{};
for (uint32_t i = 0; i < 0x100; ++i)
{
uint32_t item = i;
for (uint32_t bit = 0; bit < 8; ++bit)
item = ((item & 1) != 0) ? (POLYNOMIAL ^ (item >> 1)) : (item >> 1);
table[i] = item;
}
return table;
}()

◆ has_serialize_v

template<typename T , typename Stream , typename... Args>
constexpr bool bitstream::utility::has_serialize_v = has_serialize<void, T, Stream, Args...>::value
constexpr

◆ is_deduce_serialize_noexcept_v

template<typename Trait , typename Stream , typename... Args>
constexpr bool bitstream::utility::is_deduce_serialize_noexcept_v = is_serialize_noexcept_v<deduce_trait_t<Trait, Stream, Args...>, Stream, Trait, Args...>
constexpr

◆ is_serialize_noexcept_v

template<typename T , typename Stream , typename... Args>
constexpr bool bitstream::utility::is_serialize_noexcept_v = is_serialize_noexcept<void, T, Stream, Args...>::value
constexpr