MT Core (C++)
Core library for replacing C++ standard in project usage
|
A Slice with Endian-aware data which is just a pointer + length + endian direction Accessing elements through the array operator will do bounds checks and will convert to native endian by default (this can be overridden with access methods) Accessing out of bounds will terminate the program instead of throw Can also get sub slices. More...
#include <byte_endian.hpp>
Classes | |
struct | ConstEndianWrapper |
Endian Wrapper for grabbing the endian value By default, will handle converting to and from the native architecture Can also manually specify the endian architecture to use. More... | |
struct | EndianWrapper |
Endian Wrapper for grabbing the endian value By default, will handle converting to and from the native architecture Can also manually specify the endian architecture to use. More... | |
Public Types | |
using | Elem = T |
Public Member Functions | |
decltype(auto) | ptr_iter () noexcept |
decltype(auto) | ptr_iter () const noexcept |
decltype(auto) | iter () const noexcept |
constexpr Slice< std::add_const_t< T > > | to_const () const noexcept |
Converts to a const Slice. | |
constexpr void | init (T *head, size_t len) |
Initializes a Slice Using init instead of a constructor so that slices allocated with malloc or an arena can be initialized after the fact. | |
constexpr ConstEndianWrapper | operator[] (size_t i) const noexcept |
Access element at a specific index Const operator, returns a const reference. | |
EndianWrapper | operator[] (size_t i) noexcept |
Access element at a specific index Non-const operator, returns a mutable reference. | |
EndianWrapper | at (size_t i) noexcept |
Access element at a specific index Non-const operator, returns a mutable reference. | |
constexpr ConstEndianWrapper | at (size_t i) const noexcept |
Access element at a specific index Const operator, returns a const reference. | |
constexpr size_t | size () const noexcept |
Gets the size of a Slice. | |
constexpr bool | empty () const noexcept |
Checks if a Slice is empty. | |
constexpr EndianSlice | sub (size_t start) const noexcept |
Gets a sub Slice from start to end. | |
constexpr EndianSlice | sub (size_t start, size_t len) const noexcept |
Gets a sub Slice from start up to a length. | |
template<std::endian E> | |
std::strong_ordering | operator<=> (const EndianSlice< std::remove_const_t< T >, E > &other) const noexcept |
Compares against another Slice. | |
template<std::endian E> | |
std::strong_ordering | operator<=> (const EndianSlice< std::add_const_t< T >, E > &other) const noexcept |
Compares against another Slice. | |
template<std::endian E> | |
bool | operator== (const EndianSlice< std::remove_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator!= (const EndianSlice< std::remove_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator< (const EndianSlice< std::remove_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator> (const EndianSlice< std::remove_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator<= (const EndianSlice< std::remove_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator>= (const EndianSlice< std::remove_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator== (const EndianSlice< std::add_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator!= (const EndianSlice< std::add_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator< (const EndianSlice< std::add_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator> (const EndianSlice< std::add_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator<= (const EndianSlice< std::add_const_t< T >, E > &o) const noexcept |
template<std::endian E> | |
bool | operator>= (const EndianSlice< std::add_const_t< T >, E > &o) const noexcept |
Public Attributes | |
T * | head = nullptr |
size_t | len = 0 |
A Slice with Endian-aware data which is just a pointer + length + endian direction Accessing elements through the array operator will do bounds checks and will convert to native endian by default (this can be overridden with access methods) Accessing out of bounds will terminate the program instead of throw Can also get sub slices.
Note: this is limited to char16_t and char32_t (const and non-const variants)!
T | Type of element pointed to by the Slice |
Definition at line 173 of file byte_endian.hpp.
using mtcore::EndianSlice< T, Endian >::Elem = T |
Definition at line 176 of file byte_endian.hpp.
|
inlinenodiscardconstexprnoexcept |
Access element at a specific index Const operator, returns a const reference.
i | Index of the element in the Slice to access |
Definition at line 319 of file byte_endian.hpp.
|
inlinenoexcept |
Access element at a specific index Non-const operator, returns a mutable reference.
i | Index of the element in the Slice to access |
Definition at line 312 of file byte_endian.hpp.
|
inlinenodiscardconstexprnoexcept |
|
inlineconstexpr |
Initializes a Slice Using init instead of a constructor so that slices allocated with malloc or an arena can be initialized after the fact.
Definition at line 198 of file byte_endian.hpp.
|
inlinenodiscardnoexcept |
Definition at line 183 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 444 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 412 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 449 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 417 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 459 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 427 of file byte_endian.hpp.
|
inlinenoexcept |
Compares against another Slice.
other | Constant Slice to compare to |
Definition at line 376 of file byte_endian.hpp.
|
inlinenoexcept |
Compares against another Slice.
other | Mutable Slice to compare to |
Definition at line 366 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 439 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 407 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 454 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 422 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 465 of file byte_endian.hpp.
|
inlinenoexcept |
Definition at line 433 of file byte_endian.hpp.
|
inlinenodiscardconstexprnoexcept |
Access element at a specific index Const operator, returns a const reference.
i | Index of the element in the Slice to access |
Definition at line 290 of file byte_endian.hpp.
|
inlinenoexcept |
Access element at a specific index Non-const operator, returns a mutable reference.
i | Index of the element in the Slice to access |
Definition at line 301 of file byte_endian.hpp.
|
inlinenodiscardnoexcept |
Definition at line 182 of file byte_endian.hpp.
|
inlinenodiscardnoexcept |
Definition at line 181 of file byte_endian.hpp.
|
inlinenodiscardconstexprnoexcept |
Gets the size of a Slice.
Definition at line 324 of file byte_endian.hpp.
|
inlinenodiscardconstexprnoexcept |
Gets a sub Slice from start to end.
start | The starting index to get a sub Slice from |
Definition at line 335 of file byte_endian.hpp.
|
inlinenodiscardconstexprnoexcept |
Gets a sub Slice from start up to a length.
Definition at line 353 of file byte_endian.hpp.
|
inlinenodiscardconstexprnoexcept |
Converts to a const Slice.
Definition at line 186 of file byte_endian.hpp.
T* mtcore::EndianSlice< T, Endian >::head = nullptr |
Definition at line 178 of file byte_endian.hpp.
size_t mtcore::EndianSlice< T, Endian >::len = 0 |
Definition at line 179 of file byte_endian.hpp.