MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::EndianSlice< T, Endian >::EndianWrapper Struct Reference

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

#include <byte_endian.hpp>

Collaboration diagram for mtcore::EndianSlice< T, Endian >::EndianWrapper:

Public Member Functions

constexpr operator T () const
 Grabs the pointed at value by casting it to the native endian.
 
constexpr EndianWrapperoperator= (T val)
 Sets the pointed at value using the native endian.
 
constexpr T native () const
 
constexpr T as_endian (std::endian viewAs) const
 Gets the value with the specific endian.
 
constexpr EndianWrapperwith_endian (T newVal, std::endian setAs)
 Sets the target value with the provided endian interpretation.
 

Public Attributes

EndianSliceslice
 
size_t i
 

Detailed Description

template<class T, std::endian Endian = std::endian::native>
struct mtcore::EndianSlice< T, Endian >::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.

Definition at line 239 of file byte_endian.hpp.

Member Function Documentation

◆ as_endian()

template<class T, std::endian Endian = std::endian::native>
T mtcore::EndianSlice< T, Endian >::EndianWrapper::as_endian ( std::endian viewAs) const
inlinenodiscardconstexpr

Gets the value with the specific endian.

Parameters
viewAsEndian ordering to use

Definition at line 259 of file byte_endian.hpp.

259 {
260 ensure(i < slice.size(), "SLICE ACCESS OUT OF BOUNDS");
261 ensure(slice.head, "NULL POINTER DEREFERENCE");
262 auto v = slice.head[i];
263 if (viewAs != Endian) {
264 return flip_endian(v);
265 }
266 return v;
267 }
constexpr auto flip_endian(const T bytes)
Flips the endian of a u16, char16, u32, or char32.
#define ensure(check,...)
Ensures that a check holds true, aborts the program if not true Will print error if the condition is ...
A Slice with Endian-aware data which is just a pointer + length + endian direction Accessing elements...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ native()

template<class T, std::endian Endian = std::endian::native>
T mtcore::EndianSlice< T, Endian >::EndianWrapper::native ( ) const
inlinenodiscardconstexpr

Definition at line 253 of file byte_endian.hpp.

constexpr T as_endian(std::endian viewAs) const
Gets the value with the specific endian.
Here is the call graph for this function:

◆ operator T()

template<class T, std::endian Endian = std::endian::native>
mtcore::EndianSlice< T, Endian >::EndianWrapper::operator T ( ) const
inlineconstexpr

Grabs the pointed at value by casting it to the native endian.

Definition at line 246 of file byte_endian.hpp.

◆ operator=()

template<class T, std::endian Endian = std::endian::native>
EndianWrapper & mtcore::EndianSlice< T, Endian >::EndianWrapper::operator= ( T val)
inlineconstexpr

Sets the pointed at value using the native endian.

Definition at line 251 of file byte_endian.hpp.

constexpr EndianWrapper & with_endian(T newVal, std::endian setAs)
Sets the target value with the provided endian interpretation.
Here is the call graph for this function:

◆ with_endian()

template<class T, std::endian Endian = std::endian::native>
EndianWrapper & mtcore::EndianSlice< T, Endian >::EndianWrapper::with_endian ( T newVal,
std::endian setAs )
inlineconstexpr

Sets the target value with the provided endian interpretation.

Parameters
newValNew value in the specified endian
setAsEndian of the new value

Definition at line 274 of file byte_endian.hpp.

274 {
275 ensure(i < slice.size(), "SLICE ACCESS OUT OF BOUNDS");
276 ensure(slice.head, "NULL POINTER DEREFERENCE");
277 if (setAs != Endian) {
279 }
280 slice.head[i] = newVal;
281 return *this;
282 }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ i

template<class T, std::endian Endian = std::endian::native>
size_t mtcore::EndianSlice< T, Endian >::EndianWrapper::i

Definition at line 241 of file byte_endian.hpp.

◆ slice

template<class T, std::endian Endian = std::endian::native>
EndianSlice& mtcore::EndianSlice< T, Endian >::EndianWrapper::slice

Definition at line 240 of file byte_endian.hpp.


The documentation for this struct was generated from the following file: