Mantid
Loading...
Searching...
No Matches
BinaryStreamWriter.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8//------------------------------------------------------------------------------
9// Includes
10//------------------------------------------------------------------------------
11#include "MantidKernel/DllConfig.h"
12
13#include <cstdint>
14#include <iosfwd>
15#include <string>
16#include <vector>
17
18namespace Mantid {
19namespace Kernel {
20
21// Forward declarations
22template <typename T> class Matrix;
23
32class MANTID_KERNEL_DLL BinaryStreamWriter {
33public:
35 enum class MatrixOrdering { RowMajor, ColumnMajor };
36
37 BinaryStreamWriter(std::ostream &ofstrm);
38
41 BinaryStreamWriter &operator<<(const int16_t &value);
42 BinaryStreamWriter &operator<<(const int32_t &value);
43 BinaryStreamWriter &operator<<(const int64_t &value);
44 BinaryStreamWriter &operator<<(const float &value);
45 BinaryStreamWriter &operator<<(const double &value);
46 BinaryStreamWriter &operator<<(const std::string &value);
47 BinaryStreamWriter &operator<<(const uint16_t &value);
48 BinaryStreamWriter &operator<<(const uint32_t &value);
50
53 BinaryStreamWriter &write(const std::vector<int16_t> &value, const size_t nvals);
54 BinaryStreamWriter &write(const std::vector<int32_t> &value, const size_t nvals);
55 BinaryStreamWriter &write(const std::vector<int64_t> &value, const size_t nvals);
56 BinaryStreamWriter &write(const std::vector<float> &value, const size_t nvals);
57 BinaryStreamWriter &write(const std::vector<double> &value, const size_t nvals);
58 BinaryStreamWriter &write(const std::string &value, const size_t length);
60
63 BinaryStreamWriter &write(const std::vector<std::string> &value, const std::vector<int32_t> &shape,
64 MatrixOrdering order);
65 BinaryStreamWriter &write(const Kernel::Matrix<float> &value, const std::vector<int32_t> &shape,
66 MatrixOrdering order);
67 BinaryStreamWriter &write(const Kernel::Matrix<double> &value, const std::vector<int32_t> &shape,
68 MatrixOrdering order);
70
71private:
73 std::ostream &m_ofstrm;
78};
79
80} // namespace Kernel
81} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
std::ostream & operator<<(std::ostream &out, const MantidQt::MantidWidgets::IndexType< i > &index)
Definition: IndexTypes.h:103
Assists with writing a binary file by providing standard overloads for the ostream operators (<<) to ...
std::ostream & m_ofstrm
Reference to the stream being written to.
BinaryStreamWriter & write(const Kernel::Matrix< float > &value, const std::vector< int32_t > &shape, MatrixOrdering order)
uint64_t m_strLengthSize
The default size in bytes of the type used to encode the length of a string in the file.
BinaryStreamWriter & write(const Kernel::Matrix< double > &value, const std::vector< int32_t > &shape, MatrixOrdering order)
BinaryStreamWriter & write(const std::vector< std::string > &value, const std::vector< int32_t > &shape, MatrixOrdering order)
MatrixOrdering
Define the ordering of 2D structures in the file.
Numerical Matrix class.
Definition: Matrix.h:42
Helper class which provides the Collimation Length for SANS instruments.