Go to the documentation of this file.
39 #include <boost/format.hpp>
51 fileName_(
""), extOStream_(&stream), littleEndianStorage_(littleEndian),
52 tpefVersion_(TPEFHeaders::
TPEF_V2) {
65 fileName_(name), extOStream_(NULL), littleEndianStorage_(littleEndian),
66 tpefVersion_(TPEFHeaders::
TPEF_V1) {
152 Byte buffer[
sizeof(HalfWord)];
189 Byte buffer[
sizeof(Word)];
227 for (
unsigned int i = 0; i < howmany; i++) {
256 for (
unsigned int i = 0; i < howmany; i++) {
285 for (
unsigned int i = 0; i < howmany; i++) {
337 Byte buffer[
sizeof(HalfWord)];
369 Byte buffer[
sizeof(Word)];
403 for (
unsigned int i = 0; i < howmany; i++) {
431 for (
unsigned int i = 0; i < howmany; i++) {
459 for (
unsigned int i = 0; i < howmany; i++) {
487 __FILE__, __LINE__,
__func__,
"External stream is write-only.");
493 const std::string error = (boost::format(
494 "File '%s' could not be opened for input.") % name).str();
496 __FILE__, __LINE__,
__func__, error);
518 "External stream should be always open.");
521 oStream_.open(name.c_str(), fstream::out);
529 oStream_.open(name.c_str(), fstream::out | fstream::trunc);
533 const std::string error = (boost::format(
534 "File '%s' could not be opened for output.") %
fileName_).str();
536 __FILE__, __LINE__,
__func__, error);
564 __FILE__, __LINE__,
__func__,
"External stream is write-only.");
580 "BinaryStream::readPosition",
fileName_);
632 __FILE__, __LINE__,
__func__,
"External stream is write-only.");
661 unsigned int fileSize =
iStream_.tellg();
662 if (position <= fileSize) {
725 __FILE__, __LINE__,
__func__,
"External stream is write-only.");
776 unsigned int fileSize =
oStream_.tellp();
799 unsigned int fileSize =
iStream_.tellg();
void writeHalfWord(HalfWord halfword)
unsigned int readPosition()
void setReadPosition(unsigned int position)
void writeWord(Word word)
std::string fileName_
The name of the stream.
void writeHalfWordBlock(HalfWord *hwords, unsigned int howmany)
unsigned int writePosition()
void setCause(const Exception &cause)
void readWordBlock(Word *buffer, unsigned int howmany)
void setTPEFVersion(TPEFHeaders::TPEFVersion version)
void writeByteBlock(Byte *bytes, unsigned int howmany)
std::ostream * extOStream_
Externally given output stream.
bool littleEndianStorage_
In case we want to store the words in little endian order, big endian otherwise.
void readHalfWordBlock(HalfWord *buffer, unsigned int howmany)
void setWritePosition(unsigned int position)
std::ifstream iStream_
The input stream.
void writeWordBlock(Word *words, unsigned int howmany)
std::ofstream oStream_
The output stream.
static void swap(const Byte *src, Byte *dst, int size)
void writeByte(Byte byte)
BinaryStream(std::ostream &stream, bool littleEndian=false)
void openInput(std::string name)
TPEFHeaders::TPEFVersion TPEFVersion() const
unsigned int sizeOfFile()
void readByteBlock(Byte *buffer, unsigned int howmany)
TPEFHeaders::TPEFVersion tpefVersion_
Indicates TPEF format version used.
void openOutput(std::string name)