Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Classes | Namespaces | Enumerations | Functions | Variables
byte_util.hpp File Reference
#include <cstring>
#include <string>
#include <memory>
#include <cstdint>
#include <vector>
#include <type_traits>
#include <jau/cpp_lang_util.hpp>
#include <jau/cpp_pragma.hpp>
#include <jau/packed_attribute.hpp>
#include <jau/int_types.hpp>
Include dependency graph for byte_util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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...
 

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 
namespace  jau::impl
 

Enumerations

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

constexpr uint128dp_t jau::be_to_cpu (uint128dp_t const &n) noexcept
 
constexpr uint16_t jau::be_to_cpu (uint16_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
 
constexpr uint32_t jau::be_to_cpu (uint32_t const n) noexcept
 
constexpr uint64_t jau::be_to_cpu (uint64_t const &n) noexcept
 
constexpr uint128dp_t jau::bswap (uint128dp_t const &source) noexcept
 
constexpr uint16_t jau::bswap (uint16_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 uint32_t jau::bswap (uint32_t const source) noexcept
 
constexpr uint64_t jau::bswap (uint64_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
 
constexpr uint128dp_t jau::cpu_to_be (uint128dp_t const &h) noexcept
 
constexpr uint16_t jau::cpu_to_be (uint16_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
 
constexpr uint32_t jau::cpu_to_be (uint32_t const h) noexcept
 
constexpr uint64_t jau::cpu_to_be (uint64_t const &h) noexcept
 
constexpr uint128dp_t jau::cpu_to_le (uint128dp_t const &h) noexcept
 
constexpr uint16_t jau::cpu_to_le (uint16_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
 
constexpr uint32_t jau::cpu_to_le (uint32_t const h) noexcept
 
constexpr uint64_t jau::cpu_to_le (uint64_t const &h) noexcept
 
constexpr uint32_t jau::impl::get_host_order () noexcept
 
constexpr int8_t jau::get_int8 (uint8_t const *buffer) noexcept
 
template<typename T >
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. More...
 
constexpr uint128dp_t jau::get_uint128 (uint8_t const *buffer) noexcept
 See get_uint16() for reference. More...
 
constexpr uint128dp_t jau::get_uint128 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept
 See get_uint16() for reference. More...
 
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. More...
 
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. More...
 
constexpr uint192dp_t jau::get_uint192 (uint8_t const *buffer) noexcept
 See get_uint16() for reference. More...
 
constexpr uint192dp_t jau::get_uint192 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept
 See get_uint16() for reference. More...
 
constexpr uint256dp_t jau::get_uint256 (uint8_t const *buffer) noexcept
 See get_uint16() for reference. More...
 
constexpr uint256dp_t jau::get_uint256 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept
 See get_uint16() for reference. More...
 
constexpr uint32_t jau::get_uint32 (uint8_t const *buffer) noexcept
 See get_uint16() for reference. More...
 
constexpr uint32_t jau::get_uint32 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept
 See get_uint16() for reference. More...
 
constexpr uint64_t jau::get_uint64 (uint8_t const *buffer) noexcept
 See get_uint16() for reference. More...
 
constexpr uint64_t jau::get_uint64 (uint8_t const *buffer, const lb_endian_t byte_order) noexcept
 See get_uint16() for reference. More...
 
constexpr uint8_t jau::get_uint8 (uint8_t const *buffer) noexcept
 
template<typename T >
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. More...
 
template<typename T >
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. More...
 
constexpr bool jau::is_big_endian () noexcept
 Evaluates true if platform is running in big endian mode, i.e. More...
 
constexpr bool jau::is_defined_endian (const endian_t &v) noexcept
 Evaluates true if the given endian is defined, i.e. More...
 
constexpr bool jau::is_little_endian () noexcept
 Evaluates true if platform is running in little endian mode, i.e. More...
 
constexpr bool jau::is_little_endian (const endian_t byte_order) noexcept
 Returns true if given byte_order equals endian::little, otherwise false. More...
 
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. More...
 
constexpr bool jau::is_little_or_big_endian () noexcept
 Evaluates true if platform is running in little or big endian mode, i.e. More...
 
constexpr uint128dp_t jau::le_to_cpu (uint128dp_t const &l) noexcept
 
constexpr uint16_t jau::le_to_cpu (uint16_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
 
constexpr uint32_t jau::le_to_cpu (uint32_t const l) noexcept
 
constexpr uint64_t jau::le_to_cpu (uint64_t const &l) noexcept
 
constexpr void jau::put_uint128 (uint8_t *buffer, const uint128dp_t &v) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint128 (uint8_t *buffer, const uint128dp_t &v, const lb_endian_t byte_order) noexcept
 See put_uint16() for reference. More...
 
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. More...
 
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. More...
 
constexpr void jau::put_uint192 (uint8_t *buffer, const uint192dp_t &v) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint192 (uint8_t *buffer, const uint192dp_t &v, const lb_endian_t byte_order) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint256 (uint8_t *buffer, const uint256dp_t &v) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint256 (uint8_t *buffer, const uint256dp_t &v, const lb_endian_t byte_order) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint32 (uint8_t *buffer, const uint32_t v) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint32 (uint8_t *buffer, const uint32_t v, const lb_endian_t byte_order) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint64 (uint8_t *buffer, const uint64_t &v) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint64 (uint8_t *buffer, const uint64_t &v, const lb_endian_t byte_order) noexcept
 See put_uint16() for reference. More...
 
constexpr void jau::put_uint8 (uint8_t *buffer, const uint8_t v) noexcept
 
template<typename T >
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. More...
 
template<typename T >
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. More...
 
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 endian_t v) noexcept
 Return std::string representation of the given endian. More...
 
std::string jau::to_string (const lb_endian_t v) noexcept
 Return std::string representation of the given lb_endian. More...
 

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 . More...
 
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 . More...