PSCF v1.4.0
Util::MemoryIArchive Class Reference

Input archive for packed heterogeneous binary data. More...

#include <MemoryIArchive.h>

Public Member Functions

 MemoryIArchive ()
 Constructor.
 ~MemoryIArchive ()
 Destructor.
void allocate (size_t capacity)
 Allocate memory block.
MemoryIArchive & operator= (MemoryOArchive &other)
 Assignment from MemoryOArchive.
void reset ()
 Reset the cursor to the beginning (for rereading).
void clear ()
 Reset to empty state.
void release ()
 Release memory obtained by assignment.
template<typename T>
MemoryIArchive & operator>> (T &data)
 Load (read) one object of type T via the >> operator.
template<typename T>
MemoryIArchive & operator& (T &data)
 Load (read) one object of type T via the & operator.
template<typename T, size_t N>
MemoryIArchive & operator>> (T(&data)[N])
 Load a fixed size array via operator >>.
template<typename T, size_t N>
MemoryIArchive & operator& (T(&data)[N])
 Load a fixed size array via operator &.
template<typename T>
void unpack (T &data)
 Unpack one object of type T.
template<typename T>
void unpack (T *array, int n)
 Read a C-array of objects of type T.
template<typename T>
void unpack (T *array, int m, int n, int np)
 Unpack a 2D C array.
Byte * begin () const
 Return pointer to beginning of block.
Byte * cursor () const
 Return pointer to current position (cursor).
Byte * end () const
 Return pointer to end of packed block (one Byte past the last).
size_t capacity () const
 Return capacity in Bytes.
bool isAllocated () const
 Has memory been allocated?

Static Public Member Functions

static bool is_saving ()
 Returns true;.
static bool is_loading ()
 Returns false;.

Detailed Description

Input archive for packed heterogeneous binary data.

Definition at line 31 of file MemoryIArchive.h.

Constructor & Destructor Documentation

◆ MemoryIArchive()

Util::MemoryIArchive::MemoryIArchive ( )

Constructor.

Definition at line 20 of file MemoryIArchive.cpp.

Referenced by operator&(), operator&(), operator=(), operator>>(), and operator>>().

◆ ~MemoryIArchive()

Util::MemoryIArchive::~MemoryIArchive ( )

Destructor.

Definition at line 35 of file MemoryIArchive.cpp.

References Util::Memory::deallocate().

Member Function Documentation

◆ is_saving()

bool Util::MemoryIArchive::is_saving ( )
inlinestatic

Returns true;.

Definition at line 220 of file MemoryIArchive.h.

◆ is_loading()

bool Util::MemoryIArchive::is_loading ( )
inlinestatic

Returns false;.

Definition at line 223 of file MemoryIArchive.h.

◆ allocate()

void Util::MemoryIArchive::allocate ( size_t capacity)

Allocate memory block.

Parameters
capacitysizeof of block, in Bytes.

Definition at line 46 of file MemoryIArchive.cpp.

References Util::Memory::allocate(), capacity(), and UTIL_THROW.

◆ operator=()

MemoryIArchive & Util::MemoryIArchive::operator= ( MemoryOArchive & other)

Assignment from MemoryOArchive.

Definition at line 64 of file MemoryIArchive.cpp.

References isAllocated(), MemoryIArchive(), and UTIL_THROW.

◆ reset()

void Util::MemoryIArchive::reset ( )

Reset the cursor to the beginning (for rereading).

Definition at line 84 of file MemoryIArchive.cpp.

References begin(), isAllocated(), and UTIL_THROW.

◆ clear()

void Util::MemoryIArchive::clear ( )

Reset to empty state.

Resets cursor and end pointers to beginning of memory block.

Definition at line 95 of file MemoryIArchive.cpp.

References begin(), isAllocated(), and UTIL_THROW.

◆ release()

void Util::MemoryIArchive::release ( )

Release memory obtained by assignment.

Definition at line 110 of file MemoryIArchive.cpp.

References UTIL_THROW.

◆ operator>>() [1/2]

template<typename T>
MemoryIArchive & Util::MemoryIArchive::operator>> ( T & data)
inline

Load (read) one object of type T via the >> operator.

Parameters
dataobject to be loaded from this archive.

Definition at line 264 of file MemoryIArchive.h.

References MemoryIArchive().

◆ operator&() [1/2]

template<typename T>
MemoryIArchive & Util::MemoryIArchive::operator& ( T & data)
inline

Load (read) one object of type T via the & operator.

Parameters
dataobject to be loaded from this archive.

Definition at line 274 of file MemoryIArchive.h.

References MemoryIArchive().

◆ operator>>() [2/2]

template<typename T, size_t N>
MemoryIArchive & Util::MemoryIArchive::operator>> ( T(&) data[N])
inline

Load a fixed size array via operator >>.

The implementation applies the serialize function to each element. This template should thus work for any type T for which a serialize function exists.

Parameters
dataarray of fixed size N with elements of type T

Definition at line 284 of file MemoryIArchive.h.

References MemoryIArchive().

◆ operator&() [2/2]

template<typename T, size_t N>
MemoryIArchive & Util::MemoryIArchive::operator& ( T(&) data[N])
inline

Load a fixed size array via operator &.

Equivalent to the corresponding >> operator.

Parameters
dataarray of fixed size N with elements of type T

Definition at line 296 of file MemoryIArchive.h.

References MemoryIArchive().

◆ unpack() [1/3]

template<typename T>
void Util::MemoryIArchive::unpack ( T & data)

Unpack one object of type T.

Parameters
dataobject to be loaded from this archive.

Definition at line 308 of file MemoryIArchive.h.

References UTIL_THROW.

◆ unpack() [2/3]

template<typename T>
void Util::MemoryIArchive::unpack ( T * array,
int n )

Read a C-array of objects of type T.

Parameters
arrayarray into which data should be loaded.
nexpected number of elements in the array.

Definition at line 323 of file MemoryIArchive.h.

References UTIL_THROW.

◆ unpack() [3/3]

template<typename T>
void Util::MemoryIArchive::unpack ( T * array,
int m,
int n,
int np )

Unpack a 2D C array.

Unpack m rows of n elements into array of type T array[mp][np], with m <= mp and n <= np.

Parameters
arraypointer to [0][0] element of 2D array
mlogical number of rows
nlogical number of columns
npphysical number of columns

Definition at line 340 of file MemoryIArchive.h.

References UTIL_THROW.

◆ begin()

Byte * Util::MemoryIArchive::begin ( ) const
inline

Return pointer to beginning of block.

Definition at line 231 of file MemoryIArchive.h.

Referenced by clear(), and reset().

◆ cursor()

Byte * Util::MemoryIArchive::cursor ( ) const
inline

Return pointer to current position (cursor).

Definition at line 237 of file MemoryIArchive.h.

◆ end()

Byte * Util::MemoryIArchive::end ( ) const
inline

Return pointer to end of packed block (one Byte past the last).

Definition at line 243 of file MemoryIArchive.h.

◆ capacity()

size_t Util::MemoryIArchive::capacity ( ) const
inline

Return capacity in Bytes.

Definition at line 249 of file MemoryIArchive.h.

Referenced by allocate().

◆ isAllocated()

bool Util::MemoryIArchive::isAllocated ( ) const
inline

Has memory been allocated?

Definition at line 255 of file MemoryIArchive.h.

Referenced by clear(), operator=(), and reset().


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