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

◆ read_block_size()

void tfxx::fortranio::FortranBinInput::read_block_size ( )
private

read next block size

return next character from buffer

Definition at line 66 of file fortranio.cc.

References tfxx::ioswap::IOUnion< T >::bytes, Mistream, Mnbytes, Mnremain, Mswap, tfxx::ioswap::swap(), TFXX_assert, and tfxx::ioswap::IOUnion< T >::value.

Referenced by extract_next_char().

67  {
69  // in case we are already in the file, we have to read and check the
70  // byte-count at the end of the block
71  if (Mnbytes != 0)
72  {
73  TFXX_assert((Mnremain==0),
74  "FotranBinInput: internal error - remain count is not zero!");
75  Mistream.read(buf.bytes, sizeof(int));
76  int endcount=buf.value;
77  if (Mswap) { endcount=tfxx::ioswap::swap(buf.value); }
78  TFXX_assert((Mnbytes == endcount),
79  "FortranBinInput: bount count at end of block does not match!");
80  }
81  // read byte-count at beginning of next block
82  Mistream.read(buf.bytes, sizeof(int));
83  Mnremain=buf.value;
84  if (Mswap) { Mnremain=tfxx::ioswap::swap(buf.value); }
86  TFXX_assert((Mistream.good()),
87  "FortranBinInput: stream is not good after reading block size");
88  }
#define TFXX_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:175
std::istream & Mistream
The input stream to read from.
Definition: fortranio.h:169
long int Mnremain
Number of bytes still to read from current block.
Definition: fortranio.h:175
char bytes[sizeof(T)]
Definition: bytesex.h:100
T swap(const T &value)
How to swap any generic type.
Definition: bytesex.h:138
bool Mswap
Has byte swapping to be performed.
Definition: fortranio.h:171
long int Mnbytes
Number of bytes expected in current block.
Definition: fortranio.h:173
Here is the call graph for this function:
Here is the caller graph for this function: