MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::EndianSlice< T, Endian >::ConstEndianWrapper 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 >::ConstEndianWrapper:

Public Member Functions

constexpr operator T () const
 Grabs the pointed at value by casting it to the native endian.
 
constexpr auto native () const
 
constexpr T as_endian (std::endian viewAs) const
 Gets the value with the specific endian.
 

Public Attributes

const EndianSliceslice
 
size_t i
 

Detailed Description

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

Definition at line 208 of file byte_endian.hpp.

Member Function Documentation

◆ as_endian()

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

Gets the value with the specific endian.

Parameters
viewAsEndian ordering to use

Definition at line 223 of file byte_endian.hpp.

223 {
224 ensure(i < slice.size(), "SLICE ACCESS OUT OF BOUNDS");
225 ensure(slice.head, "NULL POINTER DEREFERENCE");
226 auto v = slice.head[i];
227 if (viewAs != Endian) {
228 return flip_endian(v);
229 }
230 return v;
231 }
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>
auto mtcore::EndianSlice< T, Endian >::ConstEndianWrapper::native ( ) const
inlinenodiscardconstexpr

Definition at line 217 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 >::ConstEndianWrapper::operator T ( ) const
inlineconstexpr

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

Definition at line 215 of file byte_endian.hpp.

Member Data Documentation

◆ i

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

Definition at line 210 of file byte_endian.hpp.

◆ slice

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

Definition at line 209 of file byte_endian.hpp.


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