Gamp: Byte Utilities (original) (raw)
Byte utility functions and types for endian- and bit conversions, inclusive alignment handling and general get & put functionality. More...
| Classes | |
|---|---|
| class | jau::AOctets< FixedSize > |
| Persistent endian aware octet data, i.e. More... | |
| class | jau::bitfield_t< StorageType, BitSize > |
| Simple statically sized bitfield template for efficient bit storage access. More... | |
| class | jau::bitheap |
| Simple dynamically heap-sized bitheap for efficient bit storage access. More... | |
| struct | jau::has_endian_big< Dummy_type > |
| A big-endian type trait for convenience . More... | |
| struct | jau::has_endian_little< Dummy_type > |
| A little-endian type trait for convenience . More... | |
| class | jau::POctets |
| Persistent endian aware octet data, i.e. More... | |
| class | jau::TOctets |
| Transient endian aware octet data, i.e. More... | |
| class | jau::TOctetSlice |
| Transient endian aware octet data slice, i.e. More... | |
| class | jau::TROOctets |
| Transient read only and endian aware octet data, i.e. More... | |
| Typedefs | |
|---|---|
| template<size_t BitSize> | |
| using | jau::bitfield = bitfield_t<jau::nsize_t, BitSize> |
| Simple bitfield template for efficient bit storage access. | |
| Enumerations | |
|---|---|
| enum class | jau::bit_order_t : bool { jau::bit_order_t::lsb = false , jau::bit_order_t::msb = true } |
| Bit order type, i.e. More... | |
| enum class | jau::endian_t : uint32_t { jau::endian_t::little = 0x41424344U , jau::endian_t::big = 0x44434241U , jau::endian_t::pdp = 0x43444142U , jau::endian_t::honeywell = 0x42414443U , jau::endian_t::undefined = 0x00000000U , jau::endian_t::native = impl::get_host_order() } |
| Endian identifier, indicating endianess of all scalar types. More... | |
| enum class | jau::lb_endian_t : uint32_t { jau::lb_endian_t::little = static_cast<uint32_t>( endian_t::little ) , jau::lb_endian_t::big = static_cast<uint32_t>( endian_t::big ) , jau::lb_endian_t::native = static_cast<uint32_t>( endian_t::native ) } |
| Simplified reduced endian type only covering little- and big-endian. More... | |
| Functions | |
|---|---|
| template<jau::req::unsigned_integral T> | |
| constexpr T | jau::be_to_cpu (T const n) noexcept |
| constexpr uint128dp_t | jau::be_to_cpu (uint128dp_t const &n) noexcept |
| constexpr uint192dp_t | jau::be_to_cpu (uint192dp_t const &n) noexcept |
| constexpr uint256dp_t | jau::be_to_cpu (uint256dp_t const &n) noexcept |
| template<jau::req::unsigned_integral T> | |
| static constexpr T | jau::bit_mask (size_t n) noexcept |
| Returns the T bit mask of n-bits, i.e. | |
| template<jau::req::unsigned_integral T> requires (sizeof(T) == 2) | |
| constexpr T | jau::bswap (T const &source) noexcept |
| constexpr uint128dp_t | jau::bswap (uint128dp_t const &source) noexcept |
| constexpr uint192dp_t | jau::bswap (uint192dp_t const &source) noexcept |
| constexpr uint256dp_t | jau::bswap (uint256dp_t const &source) noexcept |
| constexpr void | jau::bswap (uint8_t *sink, uint8_t const *source, nsize_t len) |
| const uint8_t * | jau::cast_char_ptr_to_uint8 (const char *s) noexcept |
| const char * | jau::cast_uint8_ptr_to_char (const uint8_t *b) noexcept |
| char * | jau::cast_uint8_ptr_to_char (uint8_t *b) noexcept |
| template<jau::req::unsigned_integral T> | |
| constexpr T | jau::cpu_to_be (T const h) noexcept |
| constexpr uint128dp_t | jau::cpu_to_be (uint128dp_t const &h) noexcept |
| constexpr uint192dp_t | jau::cpu_to_be (uint192dp_t const &h) noexcept |
| constexpr uint256dp_t | jau::cpu_to_be (uint256dp_t const &h) noexcept |
| template<jau::req::unsigned_integral T> | |
| constexpr T | jau::cpu_to_le (T const h) noexcept |
| constexpr uint128dp_t | jau::cpu_to_le (uint128dp_t const &h) noexcept |
| constexpr uint192dp_t | jau::cpu_to_le (uint192dp_t const &h) noexcept |
| constexpr uint256dp_t | jau::cpu_to_le (uint256dp_t const &h) noexcept |
| std::string | jau::dfa_utf8_decode (const uint8_t *buffer, const size_t buffer_size) |
| Returns all valid consecutive UTF-8 characters within buffer in the range up to buffer_size or until EOS. | |
| uint32_t | jau::dfa_utf8_decode (uint32_t &state, uint32_t &codep, const uint32_t byte_value) |
| constexpr int16_t | jau::get_int16 (uint8_t const *buffer) noexcept |
| Returns a int16_t value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr int16_t | jau::get_int16 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| Returns a int16_t value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr int32_t | jau::get_int32 (uint8_t const *buffer) noexcept |
| See get_int16() for reference. | |
| constexpr int32_t | jau::get_int32 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| See get_int16() for reference. | |
| constexpr int64_t | jau::get_int64 (uint8_t const *buffer) noexcept |
| See get_int16() for reference. | |
| constexpr int64_t | jau::get_int64 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| See get_int16() for reference. | |
| constexpr int8_t | jau::get_int8 (uint8_t const *buffer) noexcept |
| template | |
| constexpr T | jau::get_packed_value (const packed_t< T > *source, const lb_endian_t byte_order) noexcept |
| Return packed_t::store after converting it to from either lb_endian::little or lb_endian::big depending on given byte_order to lb_endian::native. | |
| constexpr uint128dp_t | jau::get_uint128 (uint8_t const *buffer) noexcept |
| See get_uint16() for reference. | |
| constexpr uint128dp_t | jau::get_uint128 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| See get_uint16() for reference. | |
| constexpr uint16_t | jau::get_uint16 (uint8_t const *buffer) noexcept |
| Returns a uint16_t value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr uint16_t | jau::get_uint16 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| Returns a uint16_t value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr uint192dp_t | jau::get_uint192 (uint8_t const *buffer) noexcept |
| See get_uint16() for reference. | |
| constexpr uint192dp_t | jau::get_uint192 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| See get_uint16() for reference. | |
| constexpr uint256dp_t | jau::get_uint256 (uint8_t const *buffer) noexcept |
| See get_uint16() for reference. | |
| constexpr uint256dp_t | jau::get_uint256 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| See get_uint16() for reference. | |
| constexpr uint32_t | jau::get_uint32 (uint8_t const *buffer) noexcept |
| See get_uint16() for reference. | |
| constexpr uint32_t | jau::get_uint32 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| See get_uint16() for reference. | |
| constexpr uint64_t | jau::get_uint64 (uint8_t const *buffer) noexcept |
| See get_uint16() for reference. | |
| constexpr uint64_t | jau::get_uint64 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| See get_uint16() for reference. | |
| constexpr uint8_t | jau::get_uint8 (uint8_t const *buffer) noexcept |
| template | |
| constexpr std::enable_if_t< std::is_standard_layout_v< T >, T > | jau::get_value (uint8_t const *buffer) noexcept |
| Returns a T value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| template | |
| constexpr std::enable_if_t< std::is_standard_layout_v< T >, T > | jau::get_value (uint8_t const *buffer, const lb_endian_t byte_order) noexcept |
| Returns a T value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr bool | jau::is_big_endian () noexcept |
| Evaluates true if platform is running in big endian mode, i.e. | |
| constexpr bool | jau::is_defined_endian (const endian_t &v) noexcept |
| Evaluates true if the given endian is defined, i.e. | |
| constexpr bool | jau::is_little_endian () noexcept |
| Evaluates true if platform is running in little endian mode, i.e. | |
| constexpr bool | jau::is_little_endian (const endian_t byte_order) noexcept |
| Returns true if given byte_order equals endian::little, otherwise false. | |
| constexpr bool | jau::is_little_endian (const lb_endian_t byte_order) noexcept |
| Returns true if given byte_order equals lb_endian::little, otherwise false. | |
| constexpr bool | jau::is_little_or_big_endian () noexcept |
| Evaluates true if platform is running in little or big endian mode, i.e. | |
| template<jau::req::unsigned_integral T> | |
| constexpr T | jau::le_to_cpu (T const l) noexcept |
| constexpr uint128dp_t | jau::le_to_cpu (uint128dp_t const &l) noexcept |
| constexpr uint192dp_t | jau::le_to_cpu (uint192dp_t const &l) noexcept |
| constexpr uint256dp_t | jau::le_to_cpu (uint256dp_t const &l) noexcept |
| template<jau::req::unsigned_integral StorageType, size_t BitSize> requires requires (StorageType) { sizeof(StorageType) <= sizeof(size_t); } | |
| std::ostream & | jau::operator<< (std::ostream &out, const bitfield_t< StorageType, BitSize > &v) |
| std::ostream & | jau::operator<< (std::ostream &out, const bitheap &v) |
| constexpr void | jau::put_int16 (uint8_t *buffer, const int16_t v) noexcept |
| Put the given int16_t value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr void | jau::put_int16 (uint8_t *buffer, const int16_t v, const lb_endian_t byte_order) noexcept |
| Put the given uint16_t value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr void | jau::put_int32 (uint8_t *buffer, const int32_t v) noexcept |
| See put_int16() for reference. | |
| constexpr void | jau::put_int32 (uint8_t *buffer, const int32_t v, const lb_endian_t byte_order) noexcept |
| See put_int16() for reference. | |
| constexpr void | jau::put_int64 (uint8_t *buffer, const int64_t &v) noexcept |
| See put_int16() for reference. | |
| constexpr void | jau::put_int64 (uint8_t *buffer, const int64_t &v, const lb_endian_t byte_order) noexcept |
| See put_int16() for reference. | |
| constexpr void | jau::put_uint128 (uint8_t *buffer, const uint128dp_t &v) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint128 (uint8_t *buffer, const uint128dp_t &v, const lb_endian_t byte_order) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint16 (uint8_t *buffer, const uint16_t v) noexcept |
| Put the given uint16_t value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr void | jau::put_uint16 (uint8_t *buffer, const uint16_t v, const lb_endian_t byte_order) noexcept |
| Put the given uint16_t value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| constexpr void | jau::put_uint192 (uint8_t *buffer, const uint192dp_t &v) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint192 (uint8_t *buffer, const uint192dp_t &v, const lb_endian_t byte_order) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint256 (uint8_t *buffer, const uint256dp_t &v) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint256 (uint8_t *buffer, const uint256dp_t &v, const lb_endian_t byte_order) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint32 (uint8_t *buffer, const uint32_t v) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint32 (uint8_t *buffer, const uint32_t v, const lb_endian_t byte_order) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint64 (uint8_t *buffer, const uint64_t &v) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint64 (uint8_t *buffer, const uint64_t &v, const lb_endian_t byte_order) noexcept |
| See put_uint16() for reference. | |
| constexpr void | jau::put_uint8 (uint8_t *buffer, const uint8_t v) noexcept |
| template | |
| constexpr std::enable_if_t< std::is_standard_layout_v< T >, void > | jau::put_value (uint8_t *buffer, const T &v) noexcept |
| Put the given T value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| template | |
| constexpr std::enable_if_t< std::is_standard_layout_v< T >, void > | jau::put_value (uint8_t *buffer, const T &v, const lb_endian_t byte_order) noexcept |
| Put the given T value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs. | |
| template<jau::req::unsigned_integral T> | |
| constexpr T | jau::rev_bits (jau::nsize_t n, T v) |
| Reversed n bits of value v, this is an O(n) operation. | |
| constexpr uint16_t | jau::rev_bits (uint16_t v) noexcept |
| Reverse bits of two bytes. | |
| constexpr uint32_t | jau::rev_bits (uint32_t v) noexcept |
| Reverse bits of four bytes. | |
| constexpr uint64_t | jau::rev_bits (uint64_t v) noexcept |
| Reverse bits of eight bytes. | |
| constexpr uint8_t | jau::rev_bits (uint8_t v) noexcept |
| Reverse bits of one byte. | |
| constexpr endian_t | jau::to_endian (const lb_endian_t v) noexcept |
| constexpr lb_endian_t | jau::to_lb_endian (const endian_t v) noexcept |
| std::string | jau::to_string (const bit_order_t v) noexcept |
| Return std::string representation of the given bit_order_t. | |
| std::string_view | jau::to_string (const endian_t v) noexcept |
| Return std::string representation of the given endian. | |
| std::string_view | jau::to_string (const lb_endian_t v) noexcept |
| Return std::string representation of the given lb_endian. | |
| Variables | |
|---|---|
| template<typename Dummy_type> | |
| constexpr bool | jau::has_endian_big_v = has_endian_big<Dummy_type>::value |
| Value access of big-endian type trait for convenience . | |
| template<typename Dummy_type> | |
| constexpr bool | jau::has_endian_little_v = has_endian_little<Dummy_type>::value |
| Value access of little-endian type trait for convenience . | |
Byte utility functions and types for endian- and bit conversions, inclusive alignment handling and general get & put functionality.
This category is also supporting Integer types and arithmetic.
All endian API entries are of constexpr and hence evaluated at compile time.
Therefore, if-branches and expressions are also of constexpr and optimized 'away' at compile time.
This includes the cpu_to_<endian>(..) and <endian>_to_cpu(..) etc utility functions.
See endian enum class regarding endian constexpr compile time determination.
Aligned memory transfer from and to potentially unaligned memory is performed via put_uint16(), get_uint16() with all its explicit stdint types, as well as the generic template functions put_value() and get_value(). The implementation uses packed_t to resolve a potential memory alignment issue free of costs, see packed_t_alignment_cast.
◆ bitfield
◆ endian_t
| enum class jau::endian_t : uint32_t | strong |
|---|
Endian identifier, indicating endianess of all scalar types.
Inspired by C++20 std::endian
Corner case platforms currently not supported, i.e. unified endianess and mixed endianess.
All endian API entries are of constexpr and hence evaluated at compile time.
Therefore, if-branches and expressions are also of constexpr and optimized 'away' at compile time.
This includes the cpu_to_<endian>(..) and <endian>_to_cpu(..) etc utility functions.
On i386 platforms the host byte order is Least Significant Byte first (LSB) or Little-Endian, whereas the network byte order, as used on the Internet, is Most Significant Byte first (MSB) or Big-Endian. See #include <arpa/inet.h>
Bluetooth is LSB or Little-Endian!
See lb_endian
| Enumerator | |
|---|---|
| little | Identifier for little endian. |
| big | Identifier for big endian. |
| pdp | Identifier for DEC PDP-11, aka ENDIAN_LITTLE_WORD. |
| honeywell | Identifier for Honeywell 316, aka ENDIAN_BIG_WORD. |
| undefined | Undetermined endian. |
| native | Identifier for native platform type, one of the above. |
Definition at line 258 of file byte_util.hpp.
◆ lb_endian_t
| enum class jau::lb_endian_t : uint32_t | strong |
|---|
Simplified reduced endian type only covering little- and big-endian.
See endian for details.
| Enumerator | |
|---|---|
| little | Identifier for little endian, equivalent to endian::little. |
| big | Identifier for big endian, equivalent to endian::big. |
| native | Identifier for native platform type, one of the above. |
Definition at line 282 of file byte_util.hpp.
◆ bit_order_t
| enum class jau::bit_order_t : bool | strong |
|---|
Bit order type, i.e.
least-significant-bit (lsb) or most-significant-bit (msb) first.
| Enumerator | |
|---|---|
| lsb | Identifier for least-significant-bit (lsb) first. |
| msb | Identifier for most-significant-bit (msb) first. |
Definition at line 1174 of file byte_util.hpp.
◆ operator<<() [1/2]
template<jau::req::unsigned_integral StorageType, size_t BitSize>
requires requires (StorageType) { sizeof(StorageType) <= sizeof(size_t); }
| std::ostream & jau::operator<< ( std::ostream & _out_, const bitfield_t< StorageType, BitSize > & v ) | inline |
|---|
◆ operator<<() [2/2]
| std::ostream & jau::operator<< ( std::ostream & out, const bitheap & v ) | inline |
|---|
◆ bswap() [1/5]
| T jau::bswap ( T const & source) | constexprnoexcept |
|---|
◆ bswap() [2/5]
| void jau::bswap ( uint8_t * sink, uint8_t const * source, nsize_t len ) | constexpr |
|---|
◆ bswap() [3/5]
◆ bswap() [4/5]
◆ bswap() [5/5]
◆ cast_uint8_ptr_to_char() [1/2]
| char * jau::cast_uint8_ptr_to_char ( uint8_t * b) | inlinenoexcept |
|---|
◆ cast_uint8_ptr_to_char() [2/2]
| const char * jau::cast_uint8_ptr_to_char ( const uint8_t * b) | inlinenoexcept |
|---|
◆ cast_char_ptr_to_uint8()
| const uint8_t * jau::cast_char_ptr_to_uint8 ( const char * s) | inlinenoexcept |
|---|
◆ to_string() [1/3]
| std::string_view jau::to_string ( const endian_t v) | noexcept |
|---|
◆ to_string() [2/3]
| std::string_view jau::to_string ( const lb_endian_t v) | noexcept |
|---|
Return std::string representation of the given lb_endian.
Parameters
Returns
the std::string representation
Definition at line 1180 of file basic_types.cpp.
◆ to_lb_endian()
| lb_endian_t jau::to_lb_endian ( const endian_t v) | constexprnoexcept |
|---|
◆ to_endian()
| endian_t jau::to_endian ( const lb_endian_t v) | constexprnoexcept |
|---|
◆ is_defined_endian()
| bool jau::is_defined_endian ( const endian_t & v) | constexprnoexcept |
|---|
Evaluates true if the given endian is defined, i.e.
little, big, pdp or honeywell.
Definition at line 331 of file byte_util.hpp.
◆ is_little_endian() [1/3]
| bool jau::is_little_endian ( const endian_t byte_order) | constexprnoexcept |
|---|
Returns true if given byte_order equals endian::little, otherwise false.
Definition at line 349 of file byte_util.hpp.
◆ is_little_endian() [2/3]
| bool jau::is_little_endian ( const lb_endian_t byte_order) | constexprnoexcept |
|---|
Returns true if given byte_order equals lb_endian::little, otherwise false.
Definition at line 356 of file byte_util.hpp.
◆ is_little_endian() [3/3]
| bool jau::is_little_endian ( ) | constexprnoexcept |
|---|
◆ is_big_endian()
| bool jau::is_big_endian ( ) | constexprnoexcept |
|---|
Evaluates true if platform is running in big endian mode, i.e.
jau::endian::big == jau::endian::native.
Definition at line 372 of file byte_util.hpp.
◆ is_little_or_big_endian()
| bool jau::is_little_or_big_endian ( ) | constexprnoexcept |
|---|
Evaluates true if platform is running in little or big endian mode, i.e.
jau::endian::little == jau::endian::native || jau::endian::big == jau::endian::native.
Definition at line 380 of file byte_util.hpp.
◆ be_to_cpu() [1/4]
| T jau::be_to_cpu ( T const n) | constexprnoexcept |
|---|
◆ cpu_to_be() [1/4]
| T jau::cpu_to_be ( T const h) | constexprnoexcept |
|---|
◆ le_to_cpu() [1/4]
| T jau::le_to_cpu ( T const l) | constexprnoexcept |
|---|
◆ cpu_to_le() [1/4]
| T jau::cpu_to_le ( T const h) | constexprnoexcept |
|---|
◆ be_to_cpu() [2/4]
◆ cpu_to_be() [2/4]
◆ le_to_cpu() [2/4]
◆ cpu_to_le() [2/4]
◆ be_to_cpu() [3/4]
◆ cpu_to_be() [3/4]
◆ le_to_cpu() [3/4]
◆ cpu_to_le() [3/4]
◆ be_to_cpu() [4/4]
◆ cpu_to_be() [4/4]
◆ le_to_cpu() [4/4]
◆ cpu_to_le() [4/4]
◆ rev_bits() [1/5]
| uint8_t jau::rev_bits ( uint8_t v) | constexprnoexcept |
|---|
◆ rev_bits() [2/5]
| uint16_t jau::rev_bits ( uint16_t v) | constexprnoexcept |
|---|
◆ rev_bits() [3/5]
| uint32_t jau::rev_bits ( uint32_t v) | constexprnoexcept |
|---|
◆ rev_bits() [4/5]
| uint64_t jau::rev_bits ( uint64_t v) | constexprnoexcept |
|---|
◆ bit_mask()
| static constexpr T jau::bit_mask ( size_t n) | staticconstexprnoexcept |
|---|
Returns the T bit mask of n-bits, i.e.
n low order 1’s
Definition at line 689 of file byte_util.hpp.
◆ rev_bits() [5/5]
◆ put_uint8()
| void jau::put_uint8 ( uint8_t * buffer, const uint8_t v ) | constexprnoexcept |
|---|
◆ get_uint8()
| uint8_t jau::get_uint8 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_int8()
| int8_t jau::get_int8 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_packed_value()
template
| T jau::get_packed_value ( const packed_t< T > * source, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
Return packed_t::store after converting it to from either lb_endian::little or lb_endian::big depending on given byte_order to lb_endian::native.
Template Parameters
Parameters
Definition at line 747 of file byte_util.hpp.
◆ put_uint16() [1/2]
| void jau::put_uint16 ( uint8_t * buffer, const uint16_t v ) | constexprnoexcept |
|---|
◆ put_uint16() [2/2]
| void jau::put_uint16 ( uint8_t * buffer, const uint16_t v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
Put the given uint16_t value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs.
The value is converted from lb_endian::native to either lb_endian::little or lb_endian::big depending on given byte_order before it is stored in memory.
See also
Definition at line 770 of file byte_util.hpp.
◆ get_uint16() [1/2]
| uint16_t jau::get_uint16 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_uint16() [2/2]
| uint16_t jau::get_uint16 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
Returns a uint16_t value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs.
The value is converted from either lb_endian::little or lb_endian::big depending on given byte_order to lb_endian::native before it is returned to the caller.
See also
Definition at line 793 of file byte_util.hpp.
◆ put_int16() [1/2]
| void jau::put_int16 ( uint8_t * buffer, const int16_t v ) | constexprnoexcept |
|---|
◆ put_int16() [2/2]
| void jau::put_int16 ( uint8_t * buffer, const int16_t v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
Put the given uint16_t value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs.
The value is converted from lb_endian::native to either lb_endian::little or lb_endian::big depending on given byte_order before it is stored in memory.
See also
Definition at line 817 of file byte_util.hpp.
◆ get_int16() [1/2]
| int16_t jau::get_int16 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_int16() [2/2]
| int16_t jau::get_int16 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
Returns a int16_t value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs.
The value is converted from either lb_endian::little or lb_endian::big depending on given byte_order to lb_endian::native before it is returned to the caller.
See also
Definition at line 840 of file byte_util.hpp.
◆ put_uint32() [1/2]
| void jau::put_uint32 ( uint8_t * buffer, const uint32_t v ) | constexprnoexcept |
|---|
◆ put_uint32() [2/2]
| void jau::put_uint32 ( uint8_t * buffer, const uint32_t v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ get_uint32() [1/2]
| uint32_t jau::get_uint32 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_uint32() [2/2]
| uint32_t jau::get_uint32 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ put_int32() [1/2]
| void jau::put_int32 ( uint8_t * buffer, const int32_t v ) | constexprnoexcept |
|---|
◆ put_int32() [2/2]
| void jau::put_int32 ( uint8_t * buffer, const int32_t v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ get_int32() [1/2]
| int32_t jau::get_int32 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_int32() [2/2]
| int32_t jau::get_int32 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ put_uint64() [1/2]
| void jau::put_uint64 ( uint8_t * buffer, const uint64_t & v ) | constexprnoexcept |
|---|
◆ put_uint64() [2/2]
| void jau::put_uint64 ( uint8_t * buffer, const uint64_t & v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ get_uint64() [1/2]
| uint64_t jau::get_uint64 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_uint64() [2/2]
| uint64_t jau::get_uint64 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ put_int64() [1/2]
| void jau::put_int64 ( uint8_t * buffer, const int64_t & v ) | constexprnoexcept |
|---|
◆ put_int64() [2/2]
| void jau::put_int64 ( uint8_t * buffer, const int64_t & v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ get_int64() [1/2]
| int64_t jau::get_int64 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_int64() [2/2]
| int64_t jau::get_int64 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ put_uint128() [1/2]
| void jau::put_uint128 ( uint8_t * buffer, const uint128dp_t & v ) | constexprnoexcept |
|---|
◆ put_uint128() [2/2]
| void jau::put_uint128 ( uint8_t * buffer, const uint128dp_t & v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ get_uint128() [1/2]
| uint128dp_t jau::get_uint128 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_uint128() [2/2]
| uint128dp_t jau::get_uint128 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ put_uint192() [1/2]
| void jau::put_uint192 ( uint8_t * buffer, const uint192dp_t & v ) | constexprnoexcept |
|---|
◆ put_uint192() [2/2]
| void jau::put_uint192 ( uint8_t * buffer, const uint192dp_t & v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ get_uint192() [1/2]
| uint192dp_t jau::get_uint192 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_uint192() [2/2]
| uint192dp_t jau::get_uint192 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ put_uint256() [1/2]
| void jau::put_uint256 ( uint8_t * buffer, const uint256dp_t & v ) | constexprnoexcept |
|---|
◆ put_uint256() [2/2]
| void jau::put_uint256 ( uint8_t * buffer, const uint256dp_t & v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ get_uint256() [1/2]
| uint256dp_t jau::get_uint256 ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_uint256() [2/2]
| uint256dp_t jau::get_uint256 ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
◆ put_value() [1/2]
template
| std::enable_if_t< std::is_standard_layout_v< T >, void > jau::put_value ( uint8_t * buffer, const T & v ) | constexprnoexcept |
|---|
◆ put_value() [2/2]
template
| std::enable_if_t< std::is_standard_layout_v< T >, void > jau::put_value ( uint8_t * buffer, const T & v, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
Put the given T value into the given byte address using packed_t to resolve a potential memory alignment issue free of costs.
The value is converted from lb_endian::native to either lb_endian::little or lb_endian::big depending on given byte_order before it is stored in memory.
Template Parameters
Parameters
See also
Definition at line 1120 of file byte_util.hpp.
◆ get_value() [1/2]
template
| std::enable_if_t< std::is_standard_layout_v< T >, T > jau::get_value ( uint8_t const * buffer) | constexprnoexcept |
|---|
◆ get_value() [2/2]
template
| std::enable_if_t< std::is_standard_layout_v< T >, T > jau::get_value ( uint8_t const * buffer, const lb_endian_t byte_order ) | constexprnoexcept |
|---|
Returns a T value from the given byte address using packed_t to resolve a potential memory alignment issue free of costs.
The value is converted from either lb_endian::little or lb_endian::big depending on given byte_order to lb_endian::native before it is returned to the caller.
Template Parameters
Parameters
Returns
See also
Definition at line 1162 of file byte_util.hpp.
◆ to_string() [3/3]
| std::string jau::to_string ( const bit_order_t v) | inlinenoexcept |
|---|
Return std::string representation of the given bit_order_t.
Parameters
Returns
the std::string representation
Definition at line 1188 of file byte_util.hpp.
◆ dfa_utf8_decode() [1/2]
| uint32_t jau::dfa_utf8_decode | ( | uint32_t & | state, |
|---|---|---|---|
| uint32_t & | codep, | ||
| const uint32_t | byte_value ) |
◆ dfa_utf8_decode() [2/2]
| std::string jau::dfa_utf8_decode | ( | const uint8_t * | buffer, |
|---|---|---|---|
| const size_t | buffer_size ) |
Returns all valid consecutive UTF-8 characters within buffer in the range up to buffer_size or until EOS.
In case a non UTF-8 character has been detected, the content will be cut off and the decoding loop ends.
Method utilizes a finite state machine detecting variable length UTF-8 codes. See Bjoern Hoehrmann's site http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
Definition at line 31 of file dfa_utf8_decode.cpp.
◆ has_endian_little_v
template<typename Dummy_type>
Value access of little-endian type trait for convenience .
Since all endian definitions are of constexpr, code can simply use expressions of these for compile-time evaluation and optimization. A template SFINAE is not required.
Template Parameters
| Dummy_type | just to make template SFINAE happy |
|---|
Examples
Definition at line 402 of file byte_util.hpp.
◆ has_endian_big_v
template<typename Dummy_type>
Value access of big-endian type trait for convenience .
Since all endian definitions are of constexpr, code can simply use expressions of these for compile-time evaluation and optimization. A template SFINAE is not required.
Template Parameters
| Dummy_type | just to make template SFINAE happy |
|---|
Definition at line 422 of file byte_util.hpp.