BornAgain  1.19.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 reflection and scattering
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_INPUTOUTPUT_DATAFORMATUTILS_H
21 #define BORNAGAIN_DEVICE_INPUTOUTPUT_DATAFORMATUTILS_H
22 
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 class IAxis;
28 template <class T> class OutputData;
29 
30 //! Utility functions for data input and output.
31 
32 namespace DataFormatUtils {
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 file extension after stripping '.gz' if any
43 std::string GetFileMainExtension(const std::string& name);
44 
45 //! returns true if file name corresponds to BornAgain native format (compressed or not)
46 bool isIntFile(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 std::unique_ptr<IAxis> createAxis(std::istream& input_stream);
52 
53 void fillOutputData(OutputData<double>* 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 } // namespace DataFormatUtils
59 
60 #endif // BORNAGAIN_DEVICE_INPUTOUTPUT_DATAFORMATUTILS_H
61 #endif // USER_API
Interface for one-dimensional axes.
Definition: IAxis.h:25
Templated class to store data of type double or CumulativeValue in multi-dimensional space.
Definition: OutputData.h:32
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.
QString const & name(EShape k)
Definition: particles.cpp:21