PSCF v1.5.0
Util::TextFileIArchive Class Reference

Loading archive for text istream. More...

#include <TextFileIArchive.h>

Public Member Functions

 TextFileIArchive ()
 Constructor.
 TextFileIArchive (std::string filename)
 Constructor.
 TextFileIArchive (std::ifstream &file)
 Constructor.
virtual ~TextFileIArchive ()
 Destructor.
std::ifstream & file ()
 Get the underlying ifstream by reference.
template<typename T>
TextFileIArchive & operator>> (T &data)
 Load one object of type T via operator >>.
template<typename T>
TextFileIArchive & operator& (T &data)
 Load one object of type T via operator &.
template<typename T, size_t N>
TextFileIArchive & operator>> (T(&data)[N])
 Load a fixed-size array via operator >>.
template<typename T, size_t N>
TextFileIArchive & operator& (T(&data)[N])
 Load a fixed-size array via operator &.
template<typename T>
void unpack (T &data)
 Load a single T object.
template<typename T>
void unpack (T *array, int n)
 Load a C-array of T objects.
template<typename T>
void unpack (T *array, int m, int n, int np)
 Load a 2D C array.
void endRecord ()
 Read the end of a record written by TextFileOArchive::pack().

Static Public Member Functions

static bool is_saving ()
 Is this a saving (output) archive?
static bool is_loading ()
 Is this a loading (input) archive?

Detailed Description

Loading archive for text istream.

Definition at line 30 of file TextFileIArchive.h.

Constructor & Destructor Documentation

◆ TextFileIArchive() [1/3]

Util::TextFileIArchive::TextFileIArchive ( )

Constructor.

Definition at line 18 of file TextFileIArchive.cpp.

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

◆ TextFileIArchive() [2/3]

Util::TextFileIArchive::TextFileIArchive ( std::string filename)

Constructor.

Parameters
filenamename of file to open for reading.

Definition at line 27 of file TextFileIArchive.cpp.

◆ TextFileIArchive() [3/3]

Util::TextFileIArchive::TextFileIArchive ( std::ifstream & file)

Constructor.

Parameters
fileoutput file

Definition at line 37 of file TextFileIArchive.cpp.

References file().

◆ ~TextFileIArchive()

Util::TextFileIArchive::~TextFileIArchive ( )
virtual

Destructor.

Definition at line 51 of file TextFileIArchive.cpp.

Member Function Documentation

◆ is_saving()

bool Util::TextFileIArchive::is_saving ( )
inlinestatic

Is this a saving (output) archive?

Returns false.

Definition at line 187 of file TextFileIArchive.h.

◆ is_loading()

bool Util::TextFileIArchive::is_loading ( )
inlinestatic

Is this a loading (input) archive?

Returns true.

Definition at line 190 of file TextFileIArchive.h.

◆ file()

std::ifstream & Util::TextFileIArchive::file ( )

Get the underlying ifstream by reference.

Definition at line 61 of file TextFileIArchive.cpp.

Referenced by TextFileIArchive().

◆ operator>>() [1/2]

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

Load one object of type T via operator >>.

Implementation calls a global serialize function, which thus must exist.

Parameters
dataobject of type T to be loaded from archive

Definition at line 199 of file TextFileIArchive.h.

References TextFileIArchive().

◆ operator&() [1/2]

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

Load one object of type T via operator &.

Equivalent to operator >>.

Parameters
dataobject of type T to be loaded from archive

Definition at line 209 of file TextFileIArchive.h.

References TextFileIArchive().

◆ operator>>() [2/2]

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

Load a fixed-size array via operator >>.

Applies a serialize function to each element of array.

Parameters
dataarray of fixed size N with elements of type T

Definition at line 219 of file TextFileIArchive.h.

References TextFileIArchive().

◆ operator&() [2/2]

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

Load a fixed-size array via operator &.

Equivalent to operator >>.

Parameters
dataarray of fixed size N with elements of type T

Definition at line 231 of file TextFileIArchive.h.

References TextFileIArchive().

◆ unpack() [1/3]

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

Load a single T object.

This template uses the ifstream >> extractor operator to unpack object data. It will thus work for any type T for which the extractor operator is defined.

Parameters
dataobject to be loaded from this archive.

Definition at line 245 of file TextFileIArchive.h.

References endRecord().

◆ unpack() [2/3]

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

Load a C-array of T objects.

This template uses the ifstream >> extractor operator to unpack each element of a C array. It will thus work for any type T for which the extractor operator is defined.

Parameters
arraypointer to array of T objecs.
nnumber of elements in array

Definition at line 255 of file TextFileIArchive.h.

References endRecord().

◆ unpack() [3/3]

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

Load a 2D C array.

This template uses the ifstream >> extractor operator to unpack each element of a 2D C array. It will thus work for any type T for which the extractor operator is defined.

Parameters
arraypointer to first row or element
mlogical number of rows
nlogical number of columns
npphysical number of columns (elements allocated per row)

Definition at line 267 of file TextFileIArchive.h.

References endRecord().

◆ endRecord()

void Util::TextFileIArchive::endRecord ( )

Read the end of a record written by TextFileOArchive::pack().

Reads spaces, tabs and carriage returns, and then the next character if it is a newline. Leaves any other character in the file. Does nothing if the file is not good().

Definition at line 67 of file TextFileIArchive.cpp.

Referenced by unpack(), unpack(), and unpack().


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