fastcgi++  3.1alpha
A C++ FastCGI/Web API
Fastcgipp::BigEndian< T > Class Template Reference

Allows raw storage of types in big endian format. More...

#include <fastcgi++/endian.hpp>

Inheritance diagram for Fastcgipp::BigEndian< T >:
[legend]
Collaboration diagram for Fastcgipp::BigEndian< T >:
[legend]

Public Member Functions

constexpr BigEndianoperator= (T x) noexcept
 
constexpr BigEndian (T x) noexcept
 
constexpr BigEndian () noexcept
 
constexpr operator T () const noexcept
 
constexpr const char * data () const
 Pointer to start of big endian integer representation. More...
 
constexpr unsigned size () const
 Size in bytes of value. More...
 

Static Public Member Functions

static constexpr T read (const unsigned char *source) noexcept
 Static function for reading the value out of a data array. More...
 
static constexpr T read (const char *source) noexcept
 Simply casts char to unsigned char. More...
 

Private Types

typedef Unsigned< s_size >::Type BaseType
 Underlying unsigned integral type. More...
 

Private Member Functions

constexpr void set (T x) noexcept
 Set the internal data to the passed parameter. More...
 

Static Private Member Functions

static constexpr void from (const unsigned char *arr, std::uint16_t &v) noexcept
 
static constexpr void from (const unsigned char *arr, std::uint32_t &v) noexcept
 
static constexpr void from (const unsigned char *arr, std::uint64_t &v) noexcept
 
static constexpr void to (unsigned char *arr, const std::uint16_t v)
 
static constexpr void to (unsigned char *arr, const std::uint32_t v)
 
static constexpr void to (unsigned char *arr, const std::uint64_t v)
 

Private Attributes

unsigned char m_data [s_size]
 The raw data of the big endian integer. More...
 

Static Private Attributes

static constexpr unsigned s_size = sizeof(T)
 

Detailed Description

template<typename T>
class Fastcgipp::BigEndian< T >

Allows raw storage of types in big endian format.

This templated class allows any trivially copyable types of size 2, 4, or 8 to be stored in big endian format but maintain type compatibility.

Template Parameters
TType to emulate. Must be either of size 2, 4 or 8 and be trivially copyable.
Date
October 9, 2018
Author
Eddie Carle <eddie.nosp@m.@isa.nosp@m.tec.c.nosp@m.a>

Definition at line 142 of file endian.hpp.

Member Typedef Documentation

◆ BaseType

template<typename T >
typedef Unsigned<s_size>::Type Fastcgipp::BigEndian< T >::BaseType
private

Underlying unsigned integral type.

Definition at line 147 of file endian.hpp.

Constructor & Destructor Documentation

◆ BigEndian() [1/2]

template<typename T >
constexpr Fastcgipp::BigEndian< T >::BigEndian ( x)
inlineconstexprnoexcept

Definition at line 174 of file endian.hpp.

◆ BigEndian() [2/2]

template<typename T >
constexpr Fastcgipp::BigEndian< T >::BigEndian ( )
inlineconstexprnoexcept

Definition at line 179 of file endian.hpp.

Member Function Documentation

◆ data()

template<typename T >
constexpr const char* Fastcgipp::BigEndian< T >::data ( ) const
inlineconstexpr

Pointer to start of big endian integer representation.

Definition at line 212 of file endian.hpp.

◆ from() [1/3]

static constexpr void Fastcgipp::BigEndian_base::from ( const unsigned char *  arr,
std::uint16_t &  v 
)
inlinestaticconstexprprotectednoexceptinherited

Definition at line 78 of file endian.hpp.

◆ from() [2/3]

static constexpr void Fastcgipp::BigEndian_base::from ( const unsigned char *  arr,
std::uint32_t &  v 
)
inlinestaticconstexprprotectednoexceptinherited

Definition at line 86 of file endian.hpp.

◆ from() [3/3]

static constexpr void Fastcgipp::BigEndian_base::from ( const unsigned char *  arr,
std::uint64_t &  v 
)
inlinestaticconstexprprotectednoexceptinherited

Definition at line 96 of file endian.hpp.

◆ operator T()

template<typename T >
constexpr Fastcgipp::BigEndian< T >::operator T ( ) const
inlineconstexprnoexcept

Definition at line 182 of file endian.hpp.

◆ operator=()

template<typename T >
constexpr BigEndian& Fastcgipp::BigEndian< T >::operator= ( x)
inlineconstexprnoexcept

Definition at line 168 of file endian.hpp.

◆ read() [1/2]

template<typename T >
static constexpr T Fastcgipp::BigEndian< T >::read ( const char *  source)
inlinestaticconstexprnoexcept

Simply casts char to unsigned char.

Definition at line 206 of file endian.hpp.

◆ read() [2/2]

template<typename T >
static constexpr T Fastcgipp::BigEndian< T >::read ( const unsigned char *  source)
inlinestaticconstexprnoexcept

Static function for reading the value out of a data array.

This will read the value out of an unsigned char array in big endian format and cast it into type T.

Parameters
[in]sourcePointer to start of data. This data should of course be at minimum size.

Definition at line 195 of file endian.hpp.

Referenced by Fastcgipp::SQL::Results_base::field().

Here is the caller graph for this function:

◆ set()

template<typename T >
constexpr void Fastcgipp::BigEndian< T >::set ( x)
inlineconstexprprivatenoexcept

Set the internal data to the passed parameter.

Definition at line 158 of file endian.hpp.

Referenced by Fastcgipp::BigEndian< uint16_t >::set().

Here is the caller graph for this function:

◆ size()

template<typename T >
constexpr unsigned Fastcgipp::BigEndian< T >::size ( ) const
inlineconstexpr

Size in bytes of value.

Definition at line 218 of file endian.hpp.

◆ to() [1/3]

static constexpr void Fastcgipp::BigEndian_base::to ( unsigned char *  arr,
const std::uint16_t  v 
)
inlinestaticconstexprprotectedinherited

Definition at line 111 of file endian.hpp.

◆ to() [2/3]

static constexpr void Fastcgipp::BigEndian_base::to ( unsigned char *  arr,
const std::uint32_t  v 
)
inlinestaticconstexprprotectedinherited

Definition at line 116 of file endian.hpp.

◆ to() [3/3]

static constexpr void Fastcgipp::BigEndian_base::to ( unsigned char *  arr,
const std::uint64_t  v 
)
inlinestaticconstexprprotectedinherited

Definition at line 123 of file endian.hpp.

Member Data Documentation

◆ m_data

template<typename T >
unsigned char Fastcgipp::BigEndian< T >::m_data[s_size]
private

The raw data of the big endian integer.

Definition at line 155 of file endian.hpp.

Referenced by Fastcgipp::BigEndian< uint16_t >::read().

◆ s_size

template<typename T >
constexpr unsigned Fastcgipp::BigEndian< T >::s_size = sizeof(T)
staticconstexprprivate

Definition at line 145 of file endian.hpp.


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