39 lleng = input.length() + 1;
46 dd_tmp =
new(std::nothrow)
char[lleng];
52 memcpy(dd_tmp, input.c_str(), lleng);
110 template<
typename T>
231 f.open(p.c_str(),std::ifstream::in);
363 write(std::string(output));
421 template<
typename T>
477 f.open(p.c_str(),std::ofstream::out | std::ofstream::trunc);
619 char* str =
new char[n];
622 input.assign(str, n);
632 char *str =
new(std::nothrow)
char[maxBytes];
700 template<
typename T>
780 bin.
read(input, maxBytes);
835 param = std::complex<float>(re,im);
844 param = std::complex<double>(re,im);
974 f.open(p.c_str(),std::ifstream::in | std::ifstream::binary);
977 QDP_error_exit(
"BinaryFileReader: error opening file %s",p.c_str());
1074 getOstream().seekp(-off, std::ios_base::end);
1091 size_t n = output.length();
1099 size_t n = output.length();
1106 write(std::string(output));
1153 template<
typename T>
1156 writeArray((
const char*)&output,
sizeof(T), 1);
1210 bin.
write(std::string(output));
1260 write(bin, param.real());
1261 write(bin, param.imag());
1267 write(bin, param.real());
1268 write(bin, param.imag());
1403 f.open(p.c_str(),std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
1406 QDP_error_exit(
"BinaryFileWriter: error opening file %s",p.c_str());
1601 f.open(p.c_str(), mode | std::ios_base::binary);
1604 QDP_error_exit(
"BinaryFileReaderWriter: error opening file %s",p.c_str());
std::string str() const
Return entire buffer as a string.
void clear()
Clear the buffer.
void open(const std::string &s)
Construct from a string.
std::string strPrimaryNode() const
Return entire buffer as a string.
~BinaryBufferReaderWriter()
Closes the buffer.
BinaryBufferReaderWriter()
std::string str() const
Return entire buffer as a string.
std::string strPrimaryNode() const
Return entire buffer as a string.
void clear()
Clear the buffer.
~BinaryBufferReader()
Closes the buffer.
void open(const std::string &s)
Construct from a string.
~BinaryBufferWriter()
Closes the buffer.
void open(const std::string &s)
Construct from a string.
void clear()
Clear the buffer.
std::string str() const
Return entire buffer as a string.
std::string strPrimaryNode() const
Return entire buffer as a string.
void close()
Closes the last file opened.
void open(const std::string &p, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
Opens a file for reading.
~BinaryFileReaderWriter()
bool is_open()
Queries whether the file is open.
void flush()
Flushes the buffer.
bool is_open()
Queries whether the file is open.
void open(const std::string &p)
Opens a file for reading.
void close()
Closes the last file opened.
bool is_open()
Queries whether the file is open.
void close()
Closes the last file opened.
void flush()
Flushes the buffer.
void open(const std::string &p)
virtual QDPUtil::n_uint32_t & internalChecksum()=0
Get the current checksum to modify.
std::iostream::off_type off_type
virtual std::iostream & getIOstream()=0
Get the internal input/output stream.
virtual pos_type currentPosition()
Current position.
virtual void resetChecksum()
Reset the current checksum.
virtual void seek(pos_type off)
Set the current position.
virtual bool fail()
Checks status of the previous IO operation.
virtual void rewind()
Rewind object to the beginning.
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.
std::iostream::pos_type pos_type
virtual QDPUtil::n_uint32_t getChecksum()
Get the current checksum.
virtual void seekEnd(off_type off)
Set the position relative from the end.
std::istream::pos_type pos_type
virtual void read(std::string &result, size_t nbytes)
Read some max number of characters - 1 upto and excluding a newline.
virtual void seek(pos_type off)
Set the current position.
virtual void readArray(char *output, size_t nbytes, size_t nmemb)
Read data on the primary node and broadcast to all nodes.
virtual void seekEnd(off_type off)
Set the position relative from the end.
virtual void rewind()
Rewind object to the beginning.
virtual void seekRelative(off_type off)
Set the position relative to the current position.
void readPrimitive(T &output)
The universal data-reader.
virtual void resetChecksum()
Reset the current checksum.
virtual QDPUtil::n_uint32_t getChecksum()
Get the current checksum.
virtual pos_type currentPosition()
Current position.
virtual QDPUtil::n_uint32_t & internalChecksum()=0
Get the current checksum to modify.
virtual void readArrayLittleEndian(char *output, size_t nbytes, size_t nmemb)
virtual bool fail()
Checks status of the previous IO operation.
virtual void seekBegin(off_type off)
Set the position relative from the start.
virtual void readArrayPrimaryNodeLittleEndian(char *output, size_t nbytes, size_t nmemb)
virtual void readDesc(std::string &result)
virtual std::istream & getIstream()=0
Get the internal input stream.
std::istream::off_type off_type
virtual void readArrayPrimaryNode(char *output, size_t nbytes, size_t nmemb)
Read data on the primary node only.
Binary writer base class.
virtual void writeArrayPrimaryNode(const char *output, size_t nbytes, size_t nmemb)
Write data on the primary node only.
virtual void writeDesc(const std::string &output)
Writes a fixed length of characters like an array.
virtual void rewind()
Rewind object to the beginning.
BinaryWriter()
Default constructor.
void writePrimitive(const T &output)
The universal data-writer.
virtual void writeArray(const char *output, size_t nbytes, size_t nmemb)
Write data from the primary node.
virtual pos_type currentPosition()
Current position.
virtual QDPUtil::n_uint32_t & internalChecksum()=0
Get the current checksum to modify.
virtual std::ostream & getOstream()=0
Get the internal output stream.
virtual void seekBegin(off_type off)
Set the position relative from the start.
std::ostream::pos_type pos_type
virtual bool fail()
Checks status of the previous IO operation.
virtual void seek(pos_type off)
Set the current position.
virtual void write(const std::string &output)
std::ostream::off_type off_type
virtual void seekRelative(off_type off)
Set the position relative to the current position.
virtual QDPUtil::n_uint32_t getChecksum()
Get the current checksum.
virtual void resetChecksum()
Reset the current checksum.
virtual void seekEnd(off_type off)
Set the position relative from the end.
std::string strPrimaryNode() const
Return entire buffer as a string.
~TextBufferReader()
Shutdown the buffer.
void open(const std::string &p)
Opens a buffer for reading.
std::string str() const
Return entire buffer as a string.
std::string strPrimaryNode() const
Return entire buffer as a string.
~TextBufferWriter()
Shutdown the buffer.
std::string str() const
Return entire buffer as a string.
void open(const std::string &s)
Construct from a string.
bool is_open()
Queries whether the file is open.
void open(const std::string &p)
Opens a file for reading.
void close()
Closes the last file opened.
void flush()
Flushes the buffer.
void open(const std::string &p)
void close()
Closes the last file opened.
bool is_open()
Queries whether the file is open.
virtual bool fail()
Checks status of the previous IO operation.
virtual std::istream & getIstream()=0
Get the internal input stream.
virtual void read(std::string &result)
void readPrimitive(T &output)
The universal data-reader.
virtual void write(const std::string &output)
void writePrimitive(const T &output)
The universal data-writer.
virtual std::ostream & getOstream()=0
Get the internal output stream.
virtual bool fail()
Checks status of the previous IO operation.
TextWriter & operator<<(TextWriter &txt, const std::string &output)
TextReader & operator>>(TextReader &txt, std::string &input)
void write(BinaryWriter &bin, const std::string &output)
void readDesc(BinaryReader &bin, std::string &input)
void writeDesc(BinaryWriter &bin, const std::string &output)
void read(BinaryReader &bin, std::string &input, size_t maxBytes)
n_uint32_t crc32(n_uint32_t crc, const unsigned char *buf, size_t len)
crc32
void byte_swap(void *ptr, size_t size, size_t nmemb)
Byte-swap an array of data each of size nmemb.
bool big_endian()
Is the native byte order big endian?
bool primaryNode()
Returns whether this is the primary node.
void broadcast(T &dest)
Broadcast from primary node to all other nodes.
Yet another random number generator.
bool QDP_isInitialized()
Is the machine initialized?
void QDP_error_exit(const char *format,...)
Simple error display and abort routine.
Primary include file for QDP.