QDP++
QDP::BinaryReader Class Referenceabstract

Binary input base class. More...

#include <qdp_io.h>

Inheritance diagram for QDP::BinaryReader:
QDP::BinaryBufferReader QDP::BinaryFileReader QDP::BinaryReaderWriter QDP::BinaryBufferReaderWriter QDP::BinaryFileReaderWriter

Public Types

typedef std::istream::pos_type pos_type
typedef std::istream::off_type off_type

Public Member Functions

virtual ~BinaryReader ()
virtual void readArrayPrimaryNode (char *output, size_t nbytes, size_t nmemb)
 Read data on the primary node only.
virtual void readArray (char *output, size_t nbytes, size_t nmemb)
 Read data on the primary node and broadcast to all nodes.
virtual void readArrayLittleEndian (char *output, size_t nbytes, size_t nmemb)
virtual void readArrayPrimaryNodeLittleEndian (char *output, size_t nbytes, size_t nmemb)
virtual void readDesc (std::string &result)
virtual void read (std::string &result, size_t nbytes)
 Read some max number of characters - 1 upto and excluding a newline.
virtual void read (char &result)
virtual void read (int &result)
virtual void read (unsigned int &result)
virtual void read (short int &result)
virtual void read (unsigned short int &result)
virtual void read (long int &result)
virtual void read (unsigned long int &result)
virtual void read (long long int &result)
virtual void read (float &result)
virtual void read (double &result)
virtual void read (bool &result)
virtual bool fail ()
 Checks status of the previous IO operation.
virtual QDPUtil::n_uint32_t getChecksum ()
 Get the current checksum.
virtual void resetChecksum ()
 Reset the current checksum.
virtual pos_type currentPosition ()
 Current position.
virtual void seek (pos_type off)
 Set the current position.
virtual void seekBegin (off_type off)
 Set the position relative from the start.
virtual void seekRelative (off_type off)
 Set the position relative to the current position.
virtual void seekEnd (off_type off)
 Set the position relative from the end.
virtual void rewind ()
 Rewind object to the beginning.

Protected Member Functions

template<typename T>
void readPrimitive (T &output)
 The universal data-reader.
virtual QDPUtil::n_uint32_tinternalChecksum ()=0
 Get the current checksum to modify.
virtual std::istream & getIstream ()=0
 Get the internal input stream.

Detailed Description

Binary input base class.

This class is used to read data from a binary object. The data in the file is assumed to be big-endian. If the host nachine is little-endian, the data is byte-swapped. All nodes end up with the same data

The read methods are also wrapped by externally defined functions and >> operators,

Definition at line 371 of file qdp_io.h.

Member Typedef Documentation

◆ off_type

typedef std::istream::off_type QDP::BinaryReader::off_type

Definition at line 375 of file qdp_io.h.

◆ pos_type

typedef std::istream::pos_type QDP::BinaryReader::pos_type

Definition at line 374 of file qdp_io.h.

Constructor & Destructor Documentation

◆ ~BinaryReader()

virtual QDP::BinaryReader::~BinaryReader ( )
inlinevirtual

Shutdown the object

Definition at line 381 of file qdp_io.h.

Member Function Documentation

◆ currentPosition()

std::istream::pos_type QDP::BinaryReader::currentPosition ( )
virtual

Current position.

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 553 of file qdp_io.cc.

References QDP::QDPInternal::broadcast(), getIstream(), and QDP::Layout::primaryNode().

◆ fail()

bool QDP::BinaryReader::fail ( )
virtual

Checks status of the previous IO operation.

Returns
true if some failure occurred in the previous IO operation

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 524 of file qdp_io.cc.

References QDP::QDPInternal::broadcast(), getIstream(), and QDP::Layout::primaryNode().

Referenced by QDP::readArchiv().

◆ getChecksum()

QDPUtil::n_uint32_t QDP::BinaryReader::getChecksum ( )
virtual

Get the current checksum.

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 536 of file qdp_io.cc.

References QDP::QDPInternal::broadcast(), and internalChecksum().

◆ getIstream()

◆ internalChecksum()

virtual QDPUtil::n_uint32_t & QDP::BinaryReader::internalChecksum ( )
protectedpure virtual

◆ read() [1/12]

void QDP::BinaryReader::read ( bool & result)
virtual

Definition at line 695 of file qdp_io.cc.

References readPrimitive().

◆ read() [2/12]

void QDP::BinaryReader::read ( char & result)
virtual

Definition at line 655 of file qdp_io.cc.

References readPrimitive().

◆ read() [3/12]

void QDP::BinaryReader::read ( double & result)
virtual

Definition at line 691 of file qdp_io.cc.

References readPrimitive().

◆ read() [4/12]

void QDP::BinaryReader::read ( float & result)
virtual

Definition at line 687 of file qdp_io.cc.

References readPrimitive().

◆ read() [5/12]

void QDP::BinaryReader::read ( int & result)
virtual

Definition at line 659 of file qdp_io.cc.

References readPrimitive().

◆ read() [6/12]

void QDP::BinaryReader::read ( long int & result)
virtual

Definition at line 675 of file qdp_io.cc.

References readPrimitive().

◆ read() [7/12]

void QDP::BinaryReader::read ( long long int & result)
virtual

Definition at line 683 of file qdp_io.cc.

References readPrimitive().

◆ read() [8/12]

void QDP::BinaryReader::read ( short int & result)
virtual

Definition at line 667 of file qdp_io.cc.

References readPrimitive().

◆ read() [9/12]

void QDP::BinaryReader::read ( std::string & result,
size_t nbytes )
virtual

Read some max number of characters - 1 upto and excluding a newline.

This is the getline function for the underlying stream

Definition at line 630 of file qdp_io.cc.

References QDP::QDPInternal::broadcast(), QDPUtil::crc32(), getIstream(), internalChecksum(), QDP::Layout::primaryNode(), and QDP::QDP_error_exit().

Referenced by QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), QDP::read(), and QDP::readArchivHeader().

◆ read() [10/12]

void QDP::BinaryReader::read ( unsigned int & result)
virtual

Definition at line 663 of file qdp_io.cc.

References readPrimitive().

◆ read() [11/12]

void QDP::BinaryReader::read ( unsigned long int & result)
virtual

Definition at line 679 of file qdp_io.cc.

References readPrimitive().

◆ read() [12/12]

void QDP::BinaryReader::read ( unsigned short int & result)
virtual

Definition at line 671 of file qdp_io.cc.

References readPrimitive().

◆ readArray()

void QDP::BinaryReader::readArray ( char * output,
size_t nbytes,
size_t nmemb )
virtual

Read data on the primary node and broadcast to all nodes.

Parameters
outputThe location to which data is read
nbytesThe size in bytes of each datum
Thenumber of data.

Definition at line 706 of file qdp_io.cc.

References QDP::QDPInternal::broadcast(), and readArrayPrimaryNode().

Referenced by QDP::read(), QDP::readArchiv(), and readPrimitive().

◆ readArrayLittleEndian()

void QDP::BinaryReader::readArrayLittleEndian ( char * output,
size_t nbytes,
size_t nmemb )
virtual

Read data on the primary node and broadcast to all nodes. Assumes data is little endian and no checksums are done.

Parameters
outputThe location to which data is read
nbytesThe size in bytes of each datum
Thenumber of data.

Definition at line 734 of file qdp_io.cc.

References QDPUtil::big_endian(), QDP::QDPInternal::broadcast(), QDPUtil::byte_swap(), getIstream(), and QDP::Layout::primaryNode().

◆ readArrayPrimaryNode()

void QDP::BinaryReader::readArrayPrimaryNode ( char * output,
size_t nbytes,
size_t nmemb )
virtual

Read data on the primary node only.

Parameters
outputThe location to which data is read
nbytesThe size in bytes of each datum
Thenumber of data.

Definition at line 715 of file qdp_io.cc.

References QDPUtil::big_endian(), QDPUtil::byte_swap(), QDPUtil::crc32(), getIstream(), internalChecksum(), and QDP::Layout::primaryNode().

Referenced by QDP::readArchiv(), readArray(), readDesc(), QDP::readOLattice(), QDP::readOLattice(), QDP::readOLattice(), and QDP::LatticeTimeSliceIO::readOLatticeSlice().

◆ readArrayPrimaryNodeLittleEndian()

void QDP::BinaryReader::readArrayPrimaryNodeLittleEndian ( char * output,
size_t nbytes,
size_t nmemb )
virtual

◆ readDesc()

void QDP::BinaryReader::readDesc ( std::string & result)
virtual

◆ readPrimitive()

template<typename T>
void QDP::BinaryReader::readPrimitive ( T & output)
protected

The universal data-reader.

All the read functions call this.

Parameters
outputThe location to which the datum is read.

Definition at line 701 of file qdp_io.cc.

References readArray().

Referenced by read(), read(), read(), read(), read(), read(), read(), read(), read(), read(), and read().

◆ resetChecksum()

void QDP::BinaryReader::resetChecksum ( )
virtual

Reset the current checksum.

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 547 of file qdp_io.cc.

References internalChecksum().

◆ rewind()

void QDP::BinaryReader::rewind ( )
virtual

Rewind object to the beginning.

Rewind.

The checksum is reset

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 600 of file qdp_io.cc.

References getIstream(), internalChecksum(), and QDP::Layout::primaryNode().

◆ seek()

void QDP::BinaryReader::seek ( pos_type off)
virtual

Set the current position.

The checksum is reset

Definition at line 564 of file qdp_io.cc.

References getIstream(), internalChecksum(), and QDP::Layout::primaryNode().

◆ seekBegin()

void QDP::BinaryReader::seekBegin ( off_type off)
virtual

Set the position relative from the start.

The checksum is reset

Definition at line 573 of file qdp_io.cc.

References getIstream(), internalChecksum(), and QDP::Layout::primaryNode().

◆ seekEnd()

void QDP::BinaryReader::seekEnd ( off_type off)
virtual

Set the position relative from the end.

The checksum is reset

Definition at line 591 of file qdp_io.cc.

References getIstream(), internalChecksum(), and QDP::Layout::primaryNode().

◆ seekRelative()

void QDP::BinaryReader::seekRelative ( off_type off)
virtual

Set the position relative to the current position.

The checksum is reset

Definition at line 582 of file qdp_io.cc.

References getIstream(), internalChecksum(), and QDP::Layout::primaryNode().


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