|
Mantid
|
Assists with writing a binary file by providing standard overloads for the ostream operators (<<) to given types (and vectors of those types). More...
#include <BinaryStreamWriter.h>
Public Types | |
| enum class | MatrixOrdering { RowMajor , ColumnMajor } |
| Define the ordering of 2D structures in the file. More... | |
Public Member Functions | |
| BinaryStreamWriter (std::ostream &ofstrm) | |
| Constructor taking the stream to write. More... | |
Single-value stream operators | |
| BinaryStreamWriter & | operator<< (const int16_t &value) |
| write a int16_t to the stream More... | |
| BinaryStreamWriter & | operator<< (const int32_t &value) |
| write a int32_t to the stream More... | |
| BinaryStreamWriter & | operator<< (const int64_t &value) |
| write a int64_t to the stream More... | |
| BinaryStreamWriter & | operator<< (const float &value) |
| write a float (4-bytes) to the stream More... | |
| BinaryStreamWriter & | operator<< (const double &value) |
| write a double (8-bytes) to the stream More... | |
| BinaryStreamWriter & | operator<< (const std::string &value) |
| write a string of characters from given object. More... | |
| BinaryStreamWriter & | operator<< (const uint16_t &value) |
| write a uint16_t to the stream More... | |
| BinaryStreamWriter & | operator<< (const uint32_t &value) |
| write a uint32_t to the stream More... | |
1D methods | |
| BinaryStreamWriter & | write (const std::vector< int16_t > &value, const size_t nvals) |
| write an array of int16_t from the given vector. More... | |
| BinaryStreamWriter & | write (const std::vector< int32_t > &value, const size_t nvals) |
| write an array of int32_t from the given vector. More... | |
| BinaryStreamWriter & | write (const std::vector< int64_t > &value, const size_t nvals) |
| write an array of int64_t from the given vector. More... | |
| BinaryStreamWriter & | write (const std::vector< float > &value, const size_t nvals) |
| write an array of float balues from the given vector. More... | |
| BinaryStreamWriter & | write (const std::vector< double > &value, const size_t nvals) |
| write an array of double values from the given vector. More... | |
| BinaryStreamWriter & | write (const std::string &value, const size_t length) |
| write a series of characters from a string object. More... | |
2D methods | |
| BinaryStreamWriter & | write (const std::vector< std::string > &value, const std::vector< int32_t > &shape, MatrixOrdering order) |
| BinaryStreamWriter & | write (const Kernel::Matrix< float > &value, const std::vector< int32_t > &shape, MatrixOrdering order) |
| BinaryStreamWriter & | write (const Kernel::Matrix< double > &value, const std::vector< int32_t > &shape, MatrixOrdering order) |
Private Attributes | |
| std::ostream & | m_ofstrm |
| Reference to the stream being written to. More... | |
| uint64_t | m_strLengthSize |
| The default size in bytes of the type used to encode the length of a string in the file. More... | |
Assists with writing a binary file by providing standard overloads for the ostream operators (<<) to given types (and vectors of those types).
It only allows for writing fixed-width integer types to avoid cross-platform differences on the sizes of various types.
Definition at line 32 of file BinaryStreamWriter.h.
|
strong |
Define the ordering of 2D structures in the file.
| Enumerator | |
|---|---|
| RowMajor | |
| ColumnMajor | |
Definition at line 35 of file BinaryStreamWriter.h.
| Mantid::Kernel::BinaryStreamWriter::BinaryStreamWriter | ( | std::ostream & | ofstrm | ) |
Constructor taking the stream to write.
| ofstrm | An open stream from which data will be write. The object does not take ownership of the stream. The caller is responsible for closing it. |
Definition at line 56 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const double & | value | ) |
write a double (8-bytes) to the stream
| value | The value is stored in this object |
Definition at line 109 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const float & | value | ) |
write a float (4-bytes) to the stream
| value | The value is stored in the given stream |
Definition at line 99 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const int16_t & | value | ) |
write a int16_t to the stream
| value | the value is stored in the given stream |
Definition at line 69 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const int32_t & | value | ) |
write a int32_t to the stream
| value | The value is stored in the given stream |
Definition at line 79 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const int64_t & | value | ) |
write a int64_t to the stream
| value | The value is stored in the given stream |
Definition at line 89 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const std::string & | value | ) |
write a string of characters from given object.
This method assumes that the stream currently points at a type specifying the length followed directly by the string itself.
| value | The string value is stored in the given object. It is resized to the appropriate length |
Definition at line 122 of file BinaryStreamWriter.cpp.
References m_ofstrm, m_strLengthSize, and value.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const uint16_t & | value | ) |
write a uint16_t to the stream
| value | The value is stored in the given stream |
Definition at line 136 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::operator<< | ( | const uint32_t & | value | ) |
write a uint32_t to the stream
| value | The value is stored in the given stream |
Definition at line 146 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const Kernel::Matrix< double > & | value, |
| const std::vector< int32_t > & | shape, | ||
| MatrixOrdering | order | ||
| ) |
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const Kernel::Matrix< float > & | value, |
| const std::vector< int32_t > & | shape, | ||
| MatrixOrdering | order | ||
| ) |
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const std::string & | value, |
| const size_t | length | ||
| ) |
write a series of characters from a string object.
| value | The string to fill. Its size is increased if necessary |
| length | The number characters to attempt to write to the stream |
Definition at line 212 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const std::vector< double > & | value, |
| const size_t | nvals | ||
| ) |
write an array of double values from the given vector.
| value | The array to fill. Its size is increased if necessary |
| nvals | The number values to attempt to write to the stream |
Definition at line 201 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const std::vector< float > & | value, |
| const size_t | nvals | ||
| ) |
write an array of float balues from the given vector.
| value | The array to fill. Its size is increased if necessary |
| nvals | The number values to attempt to write to the stream |
Definition at line 190 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const std::vector< int16_t > & | value, |
| const size_t | nvals | ||
| ) |
write an array of int16_t from the given vector.
| value | The array to fille. Its size is increased if necessary |
| nvals | The number values to attempt to write to the stream |
Definition at line 157 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const std::vector< int32_t > & | value, |
| const size_t | nvals | ||
| ) |
write an array of int32_t from the given vector.
| value | The array to fill. Its size is increased if necessary |
| nvals | The number values to attempt to write to the stream |
Definition at line 168 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const std::vector< int64_t > & | value, |
| const size_t | nvals | ||
| ) |
write an array of int64_t from the given vector.
| value | The array to fill. Its size is increased if necessary |
| nvals | The number values to attempt to write to the stream |
Definition at line 179 of file BinaryStreamWriter.cpp.
| BinaryStreamWriter & Mantid::Kernel::BinaryStreamWriter::write | ( | const std::vector< std::string > & | value, |
| const std::vector< int32_t > & | shape, | ||
| MatrixOrdering | order | ||
| ) |
|
private |
Reference to the stream being written to.
Definition at line 73 of file BinaryStreamWriter.h.
Referenced by operator<<(), and write().
|
private |
The default size in bytes of the type used to encode the length of a string in the file.
Used by operator<<(std::string&). Use largest fixed-width unsigned integer as sizeof(size_t) varies
Definition at line 77 of file BinaryStreamWriter.h.
Referenced by operator<<().