9#include "int_types.hpp"
35constexpr auto read_u16le(std::span<std::byte const, 2> bytes)
noexcept
37 if constexpr (std::endian::native == std::endian::little) {
38 return u16np(std::bit_cast<u16>(std::array{bytes[0], bytes[1]}));
44constexpr auto read_u32le(std::span<std::byte const, 4> bytes)
noexcept
46 if constexpr (std::endian::native == std::endian::little) {
47 return u32np(std::bit_cast<u32>(
48 std::array{bytes[0], bytes[1], bytes[2], bytes[3]}));
55constexpr auto read_u64le(std::span<std::byte const, 8> bytes)
noexcept
57 if constexpr (std::endian::native == std::endian::little) {
58 return u64np(std::bit_cast<u64>(
59 std::array{bytes[0], bytes[1], bytes[2], bytes[3], bytes[4],
60 bytes[5], bytes[6], bytes[7]}));
76template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
78 static_assert(Offset + 1 <= N);
79 auto const s = bytes.template subspan<Offset, 1>();
80 auto const b = std::span<std::byte const, 1>(s);
81 return u8np(
u8(b.front()));
89template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
91 static_assert(Offset + 2 <= N);
92 auto const s = bytes.template subspan<Offset, 2>();
93 return internal::read_u16le(std::span<std::byte const, 2>(s));
101template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
103 static_assert(Offset + 4 <= N);
104 auto const s = bytes.template subspan<Offset, 4>();
105 return internal::read_u32le(std::span<std::byte const, 4>(s));
113template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
115 static_assert(Offset + 8 <= N);
116 auto const s = bytes.template subspan<Offset, 8>();
117 return internal::read_u64le(std::span<std::byte const, 8>(s));
125template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
135template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
145template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
155template <std::
size_t Offset, std::convertible_to<std::
byte> T, std::
size_t N>
constexpr auto read_i32le_at(std::span< T, N > bytes) noexcept -> i32np
Read a little-endian 32-bit signed integer from bytes at offset.
Definition read_integers.hpp:146
npint< u32 > u32np
Non-promoted unsigned 32-bit integer.
Definition npint.hpp:306
npint< i64 > i64np
Non-promoted signed 64-bit integer.
Definition npint.hpp:341
constexpr auto read_u8_at(std::span< T, N > bytes) noexcept -> u8np
Read an 8-bit unsigned integer from bytes at offset.
Definition read_integers.hpp:77
constexpr auto read_i64le_at(std::span< T, N > bytes) noexcept -> i64np
Read a little-endian 64-bit signed integer from bytes at offset.
Definition read_integers.hpp:156
npint< i32 > i32np
Non-promoted signed 32-bit integer.
Definition npint.hpp:334
constexpr auto read_u32le_at(std::span< T, N > bytes) noexcept -> u32np
Read a little-endian 32-bit unsigned integer from bytes at offset.
Definition read_integers.hpp:102
npint< u8 > u8np
Non-promoted unsigned 8-bit integer.
Definition npint.hpp:292
npint< i8 > i8np
Non-promoted signed 8-bit integer.
Definition npint.hpp:320
constexpr auto read_u64le_at(std::span< T, N > bytes) noexcept -> u64np
Read a little-endian 64-bit unsigned integer from bytes at offset.
Definition read_integers.hpp:114
npint< u64 > u64np
Non-promoted unsigned 64-bit integer.
Definition npint.hpp:313
npint< u16 > u16np
Non-promoted unsigned 16-bit integer.
Definition npint.hpp:299
constexpr auto read_i8_at(std::span< T, N > bytes) noexcept -> i8np
Read an 8-bit signed integer from bytes at offset.
Definition read_integers.hpp:126
constexpr auto read_i16le_at(std::span< T, N > bytes) noexcept -> i16np
Read a little-endian 16-bit signed integer from bytes at offset.
Definition read_integers.hpp:136
npint< i16 > i16np
Non-promoted signed 16-bit integer.
Definition npint.hpp:327
constexpr auto read_u16le_at(std::span< T, N > bytes) noexcept -> u16np
Read a little-endian 16-bit unsigned integer from bytes at offset.
Definition read_integers.hpp:90
std::uint64_t u64
Short name for uint64_t.
Definition int_types.hpp:33
std::uint8_t u8
Short name for uint8_t.
Definition int_types.hpp:24
std::uint16_t u16
Short name for uint16_t.
Definition int_types.hpp:27
std::uint32_t u32
Short name for uint32_t.
Definition int_types.hpp:30
libtcspc namespace.
Definition acquire.hpp:29