QDP++
QDP::BinaryWriter Class Referenceabstract

Binary writer base class. More...

#include <qdp_io.h>

Inheritance diagram for QDP::BinaryWriter:
QDP::BinaryBufferWriter QDP::BinaryFileWriter QDP::BinaryReaderWriter QDP::BinaryBufferReaderWriter QDP::BinaryFileReaderWriter

Public Types

typedef std::ostream::pos_type pos_type
typedef std::ostream::off_type off_type

Public Member Functions

 BinaryWriter ()
 Default constructor.
virtual ~BinaryWriter ()
virtual void flush ()=0
 Flushes the buffer.
virtual void writeArrayPrimaryNode (const char *output, size_t nbytes, size_t nmemb)
 Write data on the primary node only.
virtual void writeArray (const char *output, size_t nbytes, size_t nmemb)
 Write data from the primary node.
virtual void writeDesc (const std::string &output)
 Writes a fixed length of characters like an array.
virtual void write (const std::string &output)
virtual void write (const char *output)
virtual void write (const char &output)
virtual void write (const int &output)
virtual void write (const unsigned int &output)
virtual void write (const short int &output)
virtual void write (const unsigned short int &output)
virtual void write (const long int &output)
virtual void write (const unsigned long int &output)
virtual void write (const long long int &output)
virtual void write (const float &output)
virtual void write (const double &output)
virtual void write (const bool &output)
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 writePrimitive (const T &output)
 The universal data-writer.
virtual QDPUtil::n_uint32_tinternalChecksum ()=0
 Get the current checksum to modify.
virtual std::ostream & getOstream ()=0
 Get the internal output stream.

Detailed Description

Binary writer base class.

This class is used to write data to a binary object. The data in the object is big-endian. If the host machine is little-endian, the data is byte-swapped. Output is done from the primary node only.

Writer object need to be opened before any of the write methods are used. In the case of files, the files need to be opened first

The write methods are also wrapped by externally defined functions and << operators,

Definition at line 1009 of file qdp_io.h.

Member Typedef Documentation

◆ off_type

typedef std::ostream::off_type QDP::BinaryWriter::off_type

Definition at line 1013 of file qdp_io.h.

◆ pos_type

typedef std::ostream::pos_type QDP::BinaryWriter::pos_type

Definition at line 1012 of file qdp_io.h.

Constructor & Destructor Documentation

◆ BinaryWriter()

QDP::BinaryWriter::BinaryWriter ( )

Default constructor.

Definition at line 1012 of file qdp_io.cc.

◆ ~BinaryWriter()

virtual QDP::BinaryWriter::~BinaryWriter ( )
inlinevirtual

Closes the last file opened

Definition at line 1022 of file qdp_io.h.

Member Function Documentation

◆ currentPosition()

std::ostream::pos_type QDP::BinaryWriter::currentPosition ( )
virtual

Current position.

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 1033 of file qdp_io.cc.

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

◆ fail()

bool QDP::BinaryWriter::fail ( )
virtual

Checks status of the previous IO operation.

Returns
true if some failure occurred in previous IO operation

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 1015 of file qdp_io.cc.

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

Referenced by QDP::writeArchiv().

◆ flush()

virtual void QDP::BinaryWriter::flush ( )
pure virtual

◆ getChecksum()

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

Get the current checksum.

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 1188 of file qdp_io.cc.

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

◆ getOstream()

virtual std::ostream & QDP::BinaryWriter::getOstream ( )
protectedpure virtual

◆ internalChecksum()

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

◆ resetChecksum()

void QDP::BinaryWriter::resetChecksum ( )
virtual

Reset the current checksum.

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 1027 of file qdp_io.cc.

References internalChecksum().

◆ rewind()

void QDP::BinaryWriter::rewind ( )
virtual

Rewind object to the beginning.

Rewind.

The checksum is reset

Reimplemented in QDP::BinaryReaderWriter.

Definition at line 1080 of file qdp_io.cc.

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

◆ seek()

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

Set the current position.

The checksum is reset

Definition at line 1044 of file qdp_io.cc.

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

◆ seekBegin()

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

Set the position relative from the start.

The checksum is reset

Definition at line 1053 of file qdp_io.cc.

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

◆ seekEnd()

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

Set the position relative from the end.

The checksum is reset

Definition at line 1071 of file qdp_io.cc.

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

◆ seekRelative()

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

Set the position relative to the current position.

The checksum is reset

Definition at line 1062 of file qdp_io.cc.

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

◆ write() [1/13]

void QDP::BinaryWriter::write ( const bool & output)
virtual

Definition at line 1148 of file qdp_io.cc.

References writePrimitive().

◆ write() [2/13]

void QDP::BinaryWriter::write ( const char & output)
virtual

Definition at line 1108 of file qdp_io.cc.

References writePrimitive().

◆ write() [3/13]

void QDP::BinaryWriter::write ( const char * output)
virtual

A newline is appended to the written string.

Definition at line 1104 of file qdp_io.cc.

References write().

◆ write() [4/13]

void QDP::BinaryWriter::write ( const double & output)
virtual

Definition at line 1144 of file qdp_io.cc.

References writePrimitive().

◆ write() [5/13]

void QDP::BinaryWriter::write ( const float & output)
virtual

Definition at line 1140 of file qdp_io.cc.

References writePrimitive().

◆ write() [6/13]

void QDP::BinaryWriter::write ( const int & output)
virtual

Definition at line 1112 of file qdp_io.cc.

References writePrimitive().

◆ write() [7/13]

void QDP::BinaryWriter::write ( const long int & output)
virtual

Definition at line 1128 of file qdp_io.cc.

References writePrimitive().

◆ write() [8/13]

void QDP::BinaryWriter::write ( const long long int & output)
virtual

Definition at line 1136 of file qdp_io.cc.

References writePrimitive().

◆ write() [9/13]

void QDP::BinaryWriter::write ( const short int & output)
virtual

Definition at line 1120 of file qdp_io.cc.

References writePrimitive().

◆ write() [10/13]

void QDP::BinaryWriter::write ( const std::string & output)
virtual

A newline is appended to the written string.

Definition at line 1096 of file qdp_io.cc.

References write(), and writeArray().

Referenced by write(), write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), QDP::write(), and QDP::write().

◆ write() [11/13]

void QDP::BinaryWriter::write ( const unsigned int & output)
virtual

Definition at line 1116 of file qdp_io.cc.

References writePrimitive().

◆ write() [12/13]

void QDP::BinaryWriter::write ( const unsigned long int & output)
virtual

Definition at line 1132 of file qdp_io.cc.

References writePrimitive().

◆ write() [13/13]

void QDP::BinaryWriter::write ( const unsigned short int & output)
virtual

Definition at line 1124 of file qdp_io.cc.

References writePrimitive().

◆ writeArray()

void QDP::BinaryWriter::writeArray ( const char * output,
size_t nbytes,
size_t nmemb )
virtual

Write data from the primary node.

Parameters
outputThe data to write
nbytesThe size in bytes of each datum
Thenumber of data.

Definition at line 1182 of file qdp_io.cc.

References writeArrayPrimaryNode().

Referenced by write(), QDP::write(), QDP::writeArchivHeader(), writeDesc(), QDP::writeOLattice(), writePrimitive(), and QDP::LatticeTimeSliceIO::writeSlice().

◆ writeArrayPrimaryNode()

void QDP::BinaryWriter::writeArrayPrimaryNode ( const char * output,
size_t nbytes,
size_t nmemb )
virtual

Write 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 1159 of file qdp_io.cc.

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

Referenced by QDP::writeArchiv(), writeArray(), QDP::writeOLattice(), QDP::writeOLattice(), and QDP::LatticeTimeSliceIO::writeOLatticeSlice().

◆ writeDesc()

void QDP::BinaryWriter::writeDesc ( const std::string & output)
virtual

Writes a fixed length of characters like an array.

Definition at line 1089 of file qdp_io.cc.

References writeArray(), and writePrimitive().

Referenced by QDP::writeDesc().

◆ writePrimitive()

template<typename T>
void QDP::BinaryWriter::writePrimitive ( const T & output)
protected

The universal data-writer.

All the write functions call this.

Parameters
outputThe location of the datum to be written.

Definition at line 1154 of file qdp_io.cc.

References writeArray().

Referenced by write(), write(), write(), write(), write(), write(), write(), write(), write(), write(), write(), and writeDesc().


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