BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DataFormatUtils.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/InputOutput/DataFormatUtils.h
6 //! @brief Defines class OutputDataIOFactory.
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 #ifndef BORNAGAIN_CORE_INPUTOUTPUT_DATAFORMATUTILS_H
16 #define BORNAGAIN_CORE_INPUTOUTPUT_DATAFORMATUTILS_H
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 class IAxis;
23 template <class T> class OutputData;
24 
25 //! Utility functions for data input and output.
26 
27 namespace DataFormatUtils
28 {
29 //! Returns true if name contains *.gz extension
30 bool isCompressed(const std::string& name);
31 
32 //! Returns true if name contains *.gz extension
33 bool isGZipped(const std::string& name);
34 
35 //! Returns true if name contains *.bz2 extension
36 bool isBZipped(const std::string& name);
37 
38 //! Returns file extension after stripping '.gz' if any
39 std::string GetFileMainExtension(const std::string& name);
40 
41 //! returns true if file name corresponds to BornAgain native format (compressed or not)
42 bool isIntFile(const std::string& file_name);
43 
44 //! returns true if file name corresponds to tiff file (can be also compressed)
45 bool isTiffFile(const std::string& file_name);
46 
47 std::unique_ptr<IAxis> createAxis(std::istream& input_stream);
48 
49 void fillOutputData(OutputData<double>* data, std::istream& input_stream);
50 
51 std::vector<double> parse_doubles(const std::string& str);
52 
53 void readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss);
54 } // namespace DataFormatUtils
55 
56 #endif // BORNAGAIN_CORE_INPUTOUTPUT_DATAFORMATUTILS_H
Interface for one-dimensional axes.
Definition: IAxis.h:25
Template class to store data of any type in multi-dimensional space.
Definition: OutputData.h:33
Utility functions for data input and output.
bool isBZipped(const std::string &name)
Returns true if name contains *.bz2 extension.
void readLineOfDoubles(std::vector< double > &buffer, std::istringstream &iss)
bool isCompressed(const std::string &name)
Returns true if name contains *.gz extension.
bool isIntFile(const std::string &file_name)
returns true if file name corresponds to BornAgain native format (compressed or not)
std::string GetFileMainExtension(const std::string &name)
Returns file extension after stripping '.gz' if any.
bool isTiffFile(const std::string &file_name)
returns true if file name corresponds to tiff file (can be also compressed)
std::unique_ptr< IAxis > createAxis(std::istream &input_stream)
Creates axis of certain type from input stream.
std::vector< double > parse_doubles(const std::string &str)
Parse double values from string to vector of double.
bool isGZipped(const std::string &name)
Returns true if name contains *.gz extension.
void fillOutputData(OutputData< double > *data, std::istream &input_stream)
Fills output data raw buffer from input stream.