Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
GetBlock< T, B, A > Class Template Reference

Access a block of memory. More...

#include <misc.h>

Public Member Functions

 GetBlock (const void *block)
 Construct a GetBlock. More...
 
template<class U >
GetBlock< T, B, A > & operator() (U &x)
 Access a block of memory. More...
 

Private Attributes

const bytem_block
 

Detailed Description

template<class T, class B, bool A = false>
class GetBlock< T, B, A >

Access a block of memory.

Template Parameters
Tclass or type
Benumeration indicating endianness
Aflag indicating alignment

GetBlock() provides alternate read access to a block of memory. The enumeration B is BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T. Repeatedly applying operator() results in advancing in the block of memory.

An example of reading two word32 values from a block of memory is shown below. w1 will be 0x03020100 and w1 will be 0x07060504.

   word32 w1, w2;
   byte buffer[8] = {0,1,2,3,4,5,6,7};
   GetBlock<word32, LittleEndian> block(buffer);
   block(w1)(w2);

Definition at line 2153 of file misc.h.

Constructor & Destructor Documentation

template<class T, class B, bool A = false>
GetBlock< T, B, A >::GetBlock ( const void *  block)
inline

Construct a GetBlock.

Parameters
blockthe memory block

Definition at line 2158 of file misc.h.

Member Function Documentation

template<class T, class B, bool A = false>
template<class U >
GetBlock<T, B, A>& GetBlock< T, B, A >::operator() ( U &  x)
inline

Access a block of memory.

Template Parameters
Uclass or type
Parameters
xthe value to read
Returns
pointer to the remainder of the block after reading x

Definition at line 2166 of file misc.h.

Member Data Documentation

template<class T, class B, bool A = false>
const byte* GetBlock< T, B, A >::m_block
private

Definition at line 2175 of file misc.h.


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