BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
defaultparser.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/dataloader/defaultparser.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI2_DATALOADER_DEFAULTPARSER_H
16 #define BORNAGAIN_GUI2_DATALOADER_DEFAULTPARSER_H
17 
18 #include "darefl_export.h"
21 #include <map>
22 
23 namespace gui2 {
24 
25 //! Provides basic algorirthm for parsing multi-string data representing content
26 //! of multi-column ASCII file.
27 //! + Skips empty lines or lines matching the prefix.
28 //! + Skips lines matching given line number pattern.
29 //! + Parse data in columns of basing on given separator value.
30 
31 // #import Here is a parser implementation (the only present parser so far)
32 class DAREFLCORE_EXPORT DefaultParser : public ParserInterface {
33 public:
34  DefaultParser(const ParserOptions& options);
35 
36  void process(const std::vector<std::string>& raw_data) override;
37 
38  size_t totalLineCount() const override;
39 
40  std::string getLine(size_t index) const override;
41 
42  std::vector<std::string> parseResults(size_t index) const override;
43 
44  std::vector<std::vector<std::string>> parsedData() const override;
45 
46 private:
50  std::vector<std::string> m_rawData;
51  //!< correspondence of parsed data to original line index
52  std::map<size_t, std::vector<std::string>> m_parsedData;
53 };
54 
55 } // namespace gui2
56 
57 #endif // BORNAGAIN_GUI2_DATALOADER_DEFAULTPARSER_H
Provides basic algorirthm for parsing multi-string data representing content of multi-column ASCII fi...
Definition: defaultparser.h:32
accept_int_t m_isSkipLineNumber
Definition: defaultparser.h:47
accept_string_t m_isValidLineContent
Definition: defaultparser.h:48
std::map< size_t, std::vector< std::string > > m_parsedData
Definition: defaultparser.h:52
std::vector< std::string > m_rawData
correspondence of parsed data to original line index
Definition: defaultparser.h:50
line_splitter_t m_line_splitter
Definition: defaultparser.h:49
Interface for all classes capable of parsing ASCII data into multicolumn presentation.
Defines class CLASS?
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
std::function< bool(const std::string &line)> accept_string_t
Function to define if given string should be accepted for further consideration.
std::function< bool(int)> accept_int_t
Function to define if given index satisfies criteria.
std::function< std::vector< std::string >(const std::string &line)> line_splitter_t
Function to define line splitter according to some criteria.
Defines class CLASS?
Parser options to process multi column ASCII files.