mitteLib
Loading...
Searching...
No Matches
mlab Namespace Reference

Namespaces

namespace  impl
 
namespace  traits
 

Classes

class  any_of
 
class  bin_data
 
class  bin_stream
 
struct  bit_ref
 
struct  encode_length
 
struct  explicit_bool
 
struct  fixed_size_string
 
struct  length_encoded_t
 
struct  lsb_t
 
class  mem_counter
 
class  mem_stats
 
struct  msb_t
 
struct  null_terminated_tag
 
class  observable
 
class  observable_cref
 
class  observable_ref
 
class  observe
 
struct  ordered_extractor
 
struct  ordered_injector
 
struct  prealloc
 
struct  range
 
class  reduce_timeout
 
class  result
 
class  result< E >
 
class  result< E, T >
 
class  result< E, Ts... >
 
class  result< E, void >
 
struct  result_impl
 
struct  result_success_type
 
struct  tagged_array
 
class  timer
 
struct  tracker_allocator
 

Concepts

concept  is_range_enumerable
 
concept  is_injectable
 
concept  is_extractable
 
concept  is_signed_or_unsigned_v
 
concept  is_byte_enum
 
concept  is_byte_enumerable
 
concept  is_byte_enum_enumerable
 
concept  is_byte_sequence
 
concept  container_of_injectables
 
concept  container_of_extractables
 
concept  is_result
 

Typedefs

using bin_data_base = std::conditional_t<track_bin_data_mem, std::vector<std::uint8_t, tracker_allocator<std::uint8_t>>, std::vector<std::uint8_t>>
 
template<class T >
using underlying_t = std::conditional_t<std::is_enum_v<T>, std::underlying_type_t<T>, T>
 
template<class T >
using range_value_t = std::decay_t<decltype(*std::begin(std::declval<T>()))>
 
template<unsigned Bits>
using uint_least_t = decltype(impl::get_uint_least<Bits>())
 
template<unsigned Bits>
using uint_exact_t = decltype(impl::get_uint_exact<Bits>())
 
template<class... Ts>
using tuple_container_t = typename impl::tuple_container_type<Ts...>::type
 
using datetime = std::chrono::time_point<std::chrono::system_clock>
 
using ms = std::chrono::milliseconds
 

Enumerations

enum struct  stream_ref { beg , pos , end }
 
enum struct  byte_order { msb_first , lsb_first }
 
enum struct  log_level : int {
  none , error , warn , info ,
  debug , verbose
}
 
enum struct  result_content { error , data }
 

Functions

std::uint32_t log_timestamp ()
 
std::string concatenate_s (std::vector< std::string > const &strs, std::string_view separator)
 
std::string concatenate (std::vector< std::string_view > const &strs, std::string_view separator)
 
range< std::uint8_t const * > data_view_from_string (std::string_view s)
 
bin_data data_from_string (std::string_view s)
 
bin_data data_from_hex_string (std::string_view s)
 
std::string data_to_string (std::vector< std::uint8_t > const &v)
 
std::string data_to_string (range< bin_data::const_iterator > rg)
 
std::string data_to_string (range< std::uint8_t const * > rg)
 
std::string data_to_string (bin_data const &bd)
 
std::string data_to_hex_string (std::vector< std::uint8_t > const &v)
 
std::string data_to_hex_string (range< bin_data::const_iterator > rg)
 
std::string data_to_hex_string (range< std::uint8_t const * > rg)
 
std::string replace_all (std::string_view text, std::string_view search, std::string_view replace)
 
std::optional< datetimestrptime (std::string_view s, std::string_view fmt)
 
std::string strftime (datetime const &dt, std::string_view fmt)
 
bin_dataoperator<< (encode_length< bin_data > w, std::string_view sv)
 
bin_streamoperator>> (encode_length< bin_stream > w, std::string &c)
 
template<class Iterator >
constexpr range< Iterator > make_range (Iterator begin, Iterator end)
 
template<class Container >
constexpr auto make_range (Container &c)
 
bin_dataoperator<< (bin_data &bd, prealloc const &pa)
 
template<is_signed_or_unsigned_v Num, unsigned BitSize, byte_order Order>
bin_streamoperator>> (ordered_extractor< BitSize, Order > e, Num &n)
 
template<is_signed_or_unsigned_v Num, unsigned BitSize, byte_order Order>
bin_dataoperator<< (ordered_injector< BitSize, Order > i, Num n)
 
template<unsigned BitSize>
ordered_extractor< BitSize, byte_order::lsb_firstoperator>> (bin_stream &s, lsb_t< BitSize >)
 
template<unsigned BitSize>
ordered_extractor< BitSize, byte_order::msb_firstoperator>> (bin_stream &s, msb_t< BitSize >)
 
template<unsigned BitSize>
ordered_injector< BitSize, byte_order::lsb_firstoperator<< (bin_data &bd, lsb_t< BitSize >)
 
template<unsigned BitSize>
ordered_injector< BitSize, byte_order::msb_firstoperator<< (bin_data &bd, msb_t< BitSize >)
 
bin_dataoperator<< (bin_data &bd, explicit_bool b)
 
bin_streamoperator>> (bin_stream &s, bool &b)
 
bin_streamoperator>> (bin_stream &s, std::uint8_t &byte)
 
template<std::size_t Length>
bin_streamoperator>> (bin_stream &s, std::array< std::uint8_t, Length > &out)
 
template<is_byte_enum Enum>
bin_streamoperator>> (bin_stream &s, Enum &t)
 
template<is_byte_sequence T>
bin_dataoperator<< (bin_data &bd, T const &t)
 
encode_length< bin_streamoperator>> (bin_stream &s, length_encoded_t)
 
encode_length< bin_dataoperator<< (bin_data &bd, length_encoded_t)
 
template<container_of_injectables Container>
bin_dataoperator<< (encode_length< bin_data > w, Container const &c)
 
template<container_of_extractables Container>
bin_streamoperator>> (encode_length< bin_stream > w, Container &c)
 
template<byte_order Order, unsigned Bits, class Num >
std::array< std::uint8_t, Bits/8 > encode (Num n)
 
template<byte_order Order, unsigned Bits, class Num >
Num decode (std::array< std::uint8_t, Bits/8 > const &b)
 
template<class Num , std::size_t NBytes>
constexpr Num lsb_unsigned_decode (std::array< std::uint8_t, NBytes > b)
 
template<class Num , std::size_t NBytes, std::size_t I = NBytes - 1>
constexpr Num msb_unsigned_decode (std::array< std::uint8_t, NBytes > b)
 
template<class Num , std::size_t NBytes>
constexpr std::array< std::uint8_t, NBytes > lsb_unsigned_encode (Num n)
 
template<class Num , std::size_t NBytes>
constexpr std::array< std::uint8_t, NBytes > msb_unsigned_encode (Num n)
 
template<class Num , std::size_t NBytes>
constexpr Num msb_unsigned_decode (std::array< std::uint8_t, NBytes > b)
 
template<class N >
constexpr N next_multiple (N n, N d)
 
template<class N >
constexpr std::pair< N, N > log2_remainder (N n)
 
template<is_result R1, is_result... Rs>
decltype(auto) concat_result (R1 &&r1, Rs &&...rs)
 Concatenates as many results as provided. The returned object will contain all result::value_type of the provided results, in the given order. If any of the results provided has an error state, the error is returned. It is only returned the first found error in the order in which the results are provided.
 
template<class T , is_result R>
decltype(auto) get (R &&r)
 
template<is_result R>
auto result_to_tuple (R &&r)
 
template<class E , class Tuple >
auto result_from_tuple (Tuple &&tpl)
 
template<std::size_t N>
std::string data_to_string (std::array< std::uint8_t, N > const &v)
 
template<std::size_t N>
std::string data_to_hex_string (std::array< std::uint8_t, N > const &v)
 
template<class It >
std::string data_to_hex_string (It begin, It end)
 
template<class T , class U >
bool operator== (tracker_allocator< T > const &, tracker_allocator< U > const &) noexcept
 
template<class T , class U >
bool operator!= (tracker_allocator< T > const &x, tracker_allocator< U > const &y) noexcept
 
template<class T , std::size_t BufSize = 256>
constexpr auto type_name ()
 

Variables

static const auto _time_at_start = std::chrono::steady_clock::now()
 
static constexpr bool track_bin_data_mem = false
 
static constexpr lsb_t< 16 > lsb16 {}
 
static constexpr lsb_t< 24 > lsb24 {}
 
static constexpr lsb_t< 32 > lsb32 {}
 
static constexpr lsb_t< 64 > lsb64 {}
 
static constexpr msb_t< 16 > msb16 {}
 
static constexpr msb_t< 24 > msb24 {}
 
static constexpr msb_t< 32 > msb32 {}
 
static constexpr msb_t< 64 > msb64 {}
 
static constexpr lsb_t< 0 > lsb_auto {}
 
static constexpr msb_t< 0 > msb_auto {}
 
struct mlab::length_encoded_t length_encoded
 
static constexpr result_success_type result_success {}
 
struct mlab::null_terminated_tag null_terminated
 

Typedef Documentation

◆ bin_data_base

using mlab::bin_data_base = std::conditional_t<track_bin_data_mem, std::vector<std::uint8_t, tracker_allocator<std::uint8_t>>, std::vector<std::uint8_t>>

◆ datetime

using mlab::datetime = std::chrono::time_point<std::chrono::system_clock>

◆ ms

using mlab::ms = std::chrono::milliseconds

◆ range_value_t

template<class T >
using mlab::range_value_t = std::decay_t<decltype(*std::begin(std::declval<T>()))>

◆ tuple_container_t

template<class... Ts>
using mlab::tuple_container_t = typename impl::tuple_container_type<Ts...>::type

◆ uint_exact_t

template<unsigned Bits>
using mlab::uint_exact_t = decltype(impl::get_uint_exact<Bits>())

◆ uint_least_t

template<unsigned Bits>
using mlab::uint_least_t = decltype(impl::get_uint_least<Bits>())

◆ underlying_t

template<class T >
using mlab::underlying_t = std::conditional_t<std::is_enum_v<T>, std::underlying_type_t<T>, T>

Enumeration Type Documentation

◆ byte_order

enum struct mlab::byte_order
strong
Enumerator
msb_first 
lsb_first 

◆ log_level

enum struct mlab::log_level : int
strong
Enumerator
none 
error 
warn 
info 
debug 
verbose 

◆ result_content

enum struct mlab::result_content
strong
Enumerator
error 
data 

◆ stream_ref

enum struct mlab::stream_ref
strong
Enumerator
beg 
pos 
end 

Function Documentation

◆ concat_result()

template<is_result R1, is_result... Rs>
decltype(auto) mlab::concat_result ( R1 && r1,
Rs &&... rs )
nodiscard

Concatenates as many results as provided. The returned object will contain all result::value_type of the provided results, in the given order. If any of the results provided has an error state, the error is returned. It is only returned the first found error in the order in which the results are provided.

Template Parameters
RsA sequence of result types, which all must share the same result::error_type.
Parameters
rsA sequence of result types.
Returns
A result object having as value type all the concatenated values, and the same error type.

◆ concatenate()

std::string mlab::concatenate ( std::vector< std::string_view > const & strs,
std::string_view separator )
nodiscard

◆ concatenate_s()

std::string mlab::concatenate_s ( std::vector< std::string > const & strs,
std::string_view separator )
nodiscard

◆ data_from_hex_string()

bin_data mlab::data_from_hex_string ( std::string_view s)
nodiscard

◆ data_from_string()

bin_data mlab::data_from_string ( std::string_view s)
nodiscard

◆ data_to_hex_string() [1/5]

template<class It >
std::string mlab::data_to_hex_string ( It begin,
It end )
nodiscard

◆ data_to_hex_string() [2/5]

std::string mlab::data_to_hex_string ( range< bin_data::const_iterator > rg)
nodiscard

◆ data_to_hex_string() [3/5]

std::string mlab::data_to_hex_string ( range< std::uint8_t const * > rg)
nodiscard

◆ data_to_hex_string() [4/5]

template<std::size_t N>
std::string mlab::data_to_hex_string ( std::array< std::uint8_t, N > const & v)
nodiscard

◆ data_to_hex_string() [5/5]

std::string mlab::data_to_hex_string ( std::vector< std::uint8_t > const & v)
nodiscard

◆ data_to_string() [1/5]

std::string mlab::data_to_string ( bin_data const & bd)

◆ data_to_string() [2/5]

std::string mlab::data_to_string ( range< bin_data::const_iterator > rg)
nodiscard

◆ data_to_string() [3/5]

std::string mlab::data_to_string ( range< std::uint8_t const * > rg)
nodiscard

◆ data_to_string() [4/5]

template<std::size_t N>
std::string mlab::data_to_string ( std::array< std::uint8_t, N > const & v)
nodiscard

◆ data_to_string() [5/5]

std::string mlab::data_to_string ( std::vector< std::uint8_t > const & v)
nodiscard

◆ data_view_from_string()

range< std::uint8_t const * > mlab::data_view_from_string ( std::string_view s)
nodiscard

◆ decode()

template<byte_order Order, unsigned Bits, class Num >
Num mlab::decode ( std::array< std::uint8_t, Bits/8 > const & b)

◆ encode()

template<byte_order Order, unsigned Bits, class Num >
std::array< std::uint8_t, Bits/8 > mlab::encode ( Num n)

◆ get()

template<class T , is_result R>
decltype(auto) mlab::get ( R && r)
nodiscard

◆ log2_remainder()

template<class N >
std::pair< N, N > mlab::log2_remainder ( N n)
nodiscardconstexpr

◆ log_timestamp()

std::uint32_t mlab::log_timestamp ( )
nodiscard

◆ make_range() [1/2]

template<class Container >
auto mlab::make_range ( Container & c)
inlineconstexpr

◆ make_range() [2/2]

template<class Iterator >
range< Iterator > mlab::make_range ( Iterator begin,
Iterator end )
inlineconstexpr

◆ msb_unsigned_decode()

template<class Num , std::size_t NBytes>
Num mlab::msb_unsigned_decode ( std::array< std::uint8_t, NBytes > b)
constexpr

◆ next_multiple()

template<class N >
N mlab::next_multiple ( N n,
N d )
nodiscardconstexpr

◆ operator!=()

template<class T , class U >
bool mlab::operator!= ( tracker_allocator< T > const & x,
tracker_allocator< U > const & y )
noexcept

◆ operator<<() [1/9]

bin_data & mlab::operator<< ( bin_data & bd,
explicit_bool b )
inline

◆ operator<<() [2/9]

encode_length< bin_data > mlab::operator<< ( bin_data & bd,
length_encoded_t  )
inline

◆ operator<<() [3/9]

template<unsigned BitSize>
ordered_injector< BitSize, byte_order::lsb_first > mlab::operator<< ( bin_data & bd,
lsb_t< BitSize >  )

◆ operator<<() [4/9]

template<unsigned BitSize>
ordered_injector< BitSize, byte_order::msb_first > mlab::operator<< ( bin_data & bd,
msb_t< BitSize >  )

◆ operator<<() [5/9]

bin_data & mlab::operator<< ( bin_data & bd,
prealloc const & pa )
inline

◆ operator<<() [6/9]

template<is_byte_sequence T>
bin_data & mlab::operator<< ( bin_data & bd,
T const & t )

◆ operator<<() [7/9]

template<container_of_injectables Container>
bin_data & mlab::operator<< ( encode_length< bin_data > w,
Container const & c )

◆ operator<<() [8/9]

bin_data & mlab::operator<< ( encode_length< bin_data > w,
std::string_view sv )

◆ operator<<() [9/9]

template<is_signed_or_unsigned_v Num, unsigned BitSize, byte_order Order>
bin_data & mlab::operator<< ( ordered_injector< BitSize, Order > i,
Num n )

◆ operator==()

template<class T , class U >
bool mlab::operator== ( tracker_allocator< T > const & ,
tracker_allocator< U > const &  )
noexcept

◆ operator>>() [1/10]

bin_stream & mlab::operator>> ( bin_stream & s,
bool & b )
inline

◆ operator>>() [2/10]

template<is_byte_enum Enum>
bin_stream & mlab::operator>> ( bin_stream & s,
Enum & t )

◆ operator>>() [3/10]

encode_length< bin_stream > mlab::operator>> ( bin_stream & s,
length_encoded_t  )
inline

◆ operator>>() [4/10]

template<unsigned BitSize>
ordered_extractor< BitSize, byte_order::lsb_first > mlab::operator>> ( bin_stream & s,
lsb_t< BitSize >  )
inline

◆ operator>>() [5/10]

template<unsigned BitSize>
ordered_extractor< BitSize, byte_order::msb_first > mlab::operator>> ( bin_stream & s,
msb_t< BitSize >  )
inline

◆ operator>>() [6/10]

template<std::size_t Length>
bin_stream & mlab::operator>> ( bin_stream & s,
std::array< std::uint8_t, Length > & out )

◆ operator>>() [7/10]

bin_stream & mlab::operator>> ( bin_stream & s,
std::uint8_t & byte )
inline

◆ operator>>() [8/10]

template<container_of_extractables Container>
bin_stream & mlab::operator>> ( encode_length< bin_stream > w,
Container & c )

◆ operator>>() [9/10]

bin_stream & mlab::operator>> ( encode_length< bin_stream > w,
std::string & c )

◆ operator>>() [10/10]

template<is_signed_or_unsigned_v Num, unsigned BitSize, byte_order Order>
bin_stream & mlab::operator>> ( ordered_extractor< BitSize, Order > e,
Num & n )

◆ replace_all()

std::string mlab::replace_all ( std::string_view text,
std::string_view search,
std::string_view replace )
nodiscard

◆ result_from_tuple()

template<class E , class Tuple >
auto mlab::result_from_tuple ( Tuple && tpl)
nodiscard

◆ result_to_tuple()

template<is_result R>
auto mlab::result_to_tuple ( R && r)
nodiscard

◆ strftime()

std::string mlab::strftime ( datetime const & dt,
std::string_view fmt )
nodiscard

Formats C++ dates using C's strftime.

◆ strptime()

std::optional< datetime > mlab::strptime ( std::string_view s,
std::string_view fmt )
nodiscard

Parse C++ dates using C's strptime.

◆ type_name()

template<class T , std::size_t BufSize = 256>
auto mlab::type_name ( )
nodiscardconstexpr

Variable Documentation

◆ _time_at_start

const auto mlab::_time_at_start = std::chrono::steady_clock::now()
static

◆ length_encoded

struct mlab::length_encoded_t mlab::length_encoded

◆ lsb16

lsb_t<16> mlab::lsb16 {}
staticconstexpr

◆ lsb24

lsb_t<24> mlab::lsb24 {}
staticconstexpr

◆ lsb32

lsb_t<32> mlab::lsb32 {}
staticconstexpr

◆ lsb64

lsb_t<64> mlab::lsb64 {}
staticconstexpr

◆ lsb_auto

lsb_t<0> mlab::lsb_auto {}
staticconstexpr

◆ msb16

msb_t<16> mlab::msb16 {}
staticconstexpr

◆ msb24

msb_t<24> mlab::msb24 {}
staticconstexpr

◆ msb32

msb_t<32> mlab::msb32 {}
staticconstexpr

◆ msb64

msb_t<64> mlab::msb64 {}
staticconstexpr

◆ msb_auto

msb_t<0> mlab::msb_auto {}
staticconstexpr

◆ null_terminated

struct mlab::null_terminated_tag mlab::null_terminated

◆ result_success

result_success_type mlab::result_success {}
staticconstexpr

◆ track_bin_data_mem

bool mlab::track_bin_data_mem = false
staticconstexpr