BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
DataFormatUtils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/IO/DataFormatUtils.h
6 //! @brief Defines class DatafieldIOFactory.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_IO_DATAFORMATUTILS_H
21 #define BORNAGAIN_DEVICE_IO_DATAFORMATUTILS_H
22 
23 #include <string>
24 #include <vector>
25 
26 class IAxis;
27 class Datafield;
28 
29 //! Utility functions for data input and output.
30 
31 namespace DataUtils::Format {
32 
33 //! Returns true if name contains *.gz extension
34 bool isCompressed(const std::string& name);
35 
36 //! Returns true if name contains *.gz extension
37 bool isGZipped(const std::string& name);
38 
39 //! Returns true if name contains *.bz2 extension
40 bool isBZipped(const std::string& name);
41 
42 //! Returns true if file name corresponds to BornAgain native format (compressed or not)
43 bool isIntFile(const std::string& file_name);
44 
45 //! Returns true if file name corresponds to Nicos format (compressed or not)
46 bool isNicosFile(const std::string& file_name);
47 
48 //! Returns true if file name corresponds to tiff file (can be also compressed)
49 bool isTiffFile(const std::string& file_name);
50 
51 IAxis* createAxis(std::istream& input_stream);
52 
53 void fillDatafield(Datafield* data, std::istream& input_stream);
54 
55 std::vector<double> parse_doubles(const std::string& str);
56 
57 void readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss);
58 
59 } // namespace DataUtils::Format
60 
61 #endif // BORNAGAIN_DEVICE_IO_DATAFORMATUTILS_H
62 #endif // USER_API
Stores radiation power per bin.
Definition: Datafield.h:30
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27
Utility functions for data input and output.
bool isBZipped(const std::string &name)
Returns true if name contains *.bz2 extension.
bool isIntFile(const std::string &file_name)
Returns true if file name corresponds to BornAgain native format (compressed or not)
std::vector< double > parse_doubles(const std::string &str)
Parse double values from string to vector of double.
void readLineOfDoubles(std::vector< double > &buffer, std::istringstream &iss)
void fillDatafield(Datafield *data, std::istream &input_stream)
Fills output data raw buffer from input stream.
bool isGZipped(const std::string &name)
Returns true if name contains *.gz extension.
IAxis * createAxis(std::istream &input_stream)
Creates axis of certain type from input stream.
bool isTiffFile(const std::string &file_name)
Returns true if file name corresponds to tiff file (can be also compressed)
bool isCompressed(const std::string &name)
Returns true if name contains *.gz extension.
bool isNicosFile(const std::string &file_name)
Returns true if file name corresponds to Nicos format (compressed or not)