TF++, Miscellaneous classes and modules in C++:

read FORTRAN binary data ,This class reads FORTRAN binary data. FORTRAN binary data is always written in chunks of several bytes, where each chunk is preceded and followed by a 4-byte integer byte-count. This class takes care of this structure of byte-counts an returns only the real data (omitting the counts). More...

#include <fortranio.h>

Collaboration diagram for tfxx::fortranio::FortranBinInput:

Public Member Functions

 FortranBinInput (std::istream &is, const bool &swap=false)
 start reading from input stream is More...
 
 ~FortranBinInput ()
 needs a cleaning destructor More...
 
bool more () const
 are there more data expected? More...
 
template<typename T >
void get (T &value)
 
bool match_magic (const char *cmagic)
 expect magic number and adjust swapping flag More...
 

Private Member Functions

char extract_next_char ()
 return next element from input stream More...
 
void extract_chars (char *buf, const int &n)
 extract next set of characters More...
 
void read_block_size ()
 read next block size More...
 
void finish_block ()
 finish open block More...
 

Private Attributes

std::istream & Mistream
 The input stream to read from. More...
 
bool Mswap
 Has byte swapping to be performed. More...
 
long int Mnbytes
 Number of bytes expected in current block. More...
 
long int Mnremain
 Number of bytes still to read from current block. More...
 

Detailed Description

read FORTRAN binary data ,

This class reads FORTRAN binary data. FORTRAN binary data is always written in chunks of several bytes, where each chunk is preceded and followed by a 4-byte integer byte-count. This class takes care of this structure of byte-counts an returns only the real data (omitting the counts).

No buffering is done, because we rely on stream-buffering.

By creating the object the reading process is initialized. For convenient access I/O operators are provided.

No checking for block alignment is performed. This means, the class does not complain in case the first three bytes of a double are at the end of one block and the next five bytes are at the beginning of the next block. The class just ensures that block byte-counts are skipped.

See also
TEST: Fortran I/O and byte swapping.
tfxx::fortranio::FortranBinInput
tfxx::fortranio::FortranBinInput& operator>>(tfxx::fortranio::FortranBinInput&, const T&) \
Examples:
tests/fortraniotest.cc.

Definition at line 137 of file fortranio.h.


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