LibQuicR
bytes.h File Reference
#include <bit>
#include <cstdint>
#include <span>
#include <string>
#include <type_traits>
#include <vector>

Go to the source code of this file.

Namespaces

 quicr
 

Typedefs

using quicr::Byte = uint8_t
 One octet of binary data. More...
 
using quicr::Bytes = std::vector< Byte >
 Owning contiguous byte buffer. More...
 
using quicr::BytesSpan = std::span< const Byte >
 Non-owning, read-only view of contiguous bytes. More...
 

Functions

template<class T >
requires std::is_standard_layout_v< T > std::is_same_v< std::decay_t< T >, std::string > std::span< const uint8_t > quicr::AsBytes (const T &value)
 Views a value's in-memory object representation as bytes. More...
 
template<>
std::span< const uint8_t > quicr::AsBytes< std::string > (const std::string &value)
 Views a string's character data as bytes without copying. More...
 
template<class T >
requires std::is_standard_layout_v< T > std::is_same_v< std::decay_t< T >, std::string > Bytes quicr::AsOwnedBytes (const T &value)
 Copies a value's native object representation into an owning byte buffer. More...
 
template<class T >
T quicr::FromBytes (std::span< const uint8_t > bytes)
 Constructs a value from bytes. More...
 
void quicr::AppendBytes (Bytes &buffer, BytesSpan bytes)
 Appends bytes to an owning buffer. More...
 
constexpr std::uint16_t quicr::SwapBytes (const std::uint16_t value)
 Converts a 16-bit value between native and big-endian byte order. More...
 
constexpr std::uint32_t quicr::SwapBytes (const std::uint32_t value)
 Converts a 32-bit value between native and big-endian byte order. More...
 
constexpr std::uint64_t quicr::SwapBytes (const std::uint64_t value)
 Converts a 64-bit value between native and big-endian byte order. More...