liborigin  3.0.0
OriginParser.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : OriginParser.h
3  --------------------------------------------------------------------
4  Copyright : (C) 2008 Alex Kargovsky (kargovsky@yumr.phys.msu.su)
5  Copyright : (C) 2017 Stefan Gerlach (stefan.gerlach@uni.kn)
6  Description : Origin file parser base class
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  * This program is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU General Public License *
23  * along with this program; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25  * Boston, MA 02110-1301 USA *
26  * *
27  ***************************************************************************/
28 
29 #ifndef ORIGIN_PARSER_H
30 #define ORIGIN_PARSER_H
31 
32 #include "OriginObj.h"
33 #include "tree.hh"
34 
35 #ifdef GENERATE_CODE_FOR_LOG
36 #define LOG_PRINT( logfile, ... ) { fprintf(logfile, __VA_ARGS__); }
37 #else // !GENERATE_CODE_FOR_LOG
38 #define LOG_PRINT( logfile, ... ) {};
39 #endif
40 
42 {
43 public:
44  virtual ~OriginParser() = default;
45  virtual bool parse() = 0;
46 
47  vector<Origin::SpreadSheet>::difference_type findSpreadByName(const string& name) const;
48  vector<Origin::Matrix>::difference_type findMatrixByName(const string& name) const;
49  vector<Origin::Function>::difference_type findFunctionByName(const string& name) const;
50  vector<Origin::Excel>::difference_type findExcelByName(const string& name) const;
51 
52 protected:
53  vector<Origin::SpreadColumn>::difference_type findSpreadColumnByName(vector<Origin::SpreadSheet>::size_type spread, const string& name) const;
54  vector<Origin::SpreadColumn>::difference_type findExcelColumnByName(vector<Origin::Excel>::size_type excel, vector<Origin::SpreadSheet>::size_type sheet, const string& name) const;
55  pair<string, string> findDataByIndex(unsigned int index) const;
56  pair<Origin::ProjectNode::NodeType, string> findObjectByIndex(unsigned int index) const;
57  pair<Origin::ProjectNode::NodeType, Origin::Window> findWindowObjectByIndex(unsigned int index) const;
58  void convertSpreadToExcel(vector<Origin::SpreadSheet>::size_type spread);
59 
60  int findColumnByName(int spread, const string& name);
61 private:
62  bool iequals(const string&, const string&, const std::locale& = std::locale()) const;
63 
64 public:
65  vector<Origin::SpreadColumn> datasets;
66  vector<Origin::SpreadSheet> spreadSheets;
67  vector<Origin::Matrix> matrixes;
68  vector<Origin::Excel> excels;
69  vector<Origin::Function> functions;
70  vector<Origin::Graph> graphs;
71  vector<Origin::Note> notes;
72  tree<Origin::ProjectNode> projectTree;
73  string resultsLog;
74  unsigned int windowsCount;
75  unsigned int fileVersion, buildVersion;
76 };
77 
78 OriginParser* createOriginAnyParser(const string& fileName);
79 
80 #endif // ORIGIN_PARSER_H
unsigned int windowsCount
Definition: OriginParser.h:74
vector< Origin::Excel >::difference_type findExcelByName(const string &name) const
Definition: OriginParser.cpp:53
virtual ~OriginParser()=default
vector< Origin::Function > functions
Definition: OriginParser.h:69
int findColumnByName(int spread, const string &name)
Definition: OriginParser.cpp:237
pair< string, string > findDataByIndex(unsigned int index) const
Definition: OriginParser.cpp:98
vector< Origin::SpreadSheet >::difference_type findSpreadByName(const string &name) const
Definition: OriginParser.cpp:44
bool iequals(const string &, const string &, const std::locale &=std::locale()) const
Definition: OriginParser.cpp:35
vector< Origin::SpreadColumn > datasets
Definition: OriginParser.h:65
virtual bool parse()=0
unsigned int fileVersion
Definition: OriginParser.h:75
vector< Origin::Function >::difference_type findFunctionByName(const string &name) const
Definition: OriginParser.cpp:89
vector< Origin::Note > notes
Definition: OriginParser.h:71
vector< Origin::SpreadColumn >::difference_type findExcelColumnByName(vector< Origin::Excel >::size_type excel, vector< Origin::SpreadSheet >::size_type sheet, const string &name) const
Definition: OriginParser.cpp:71
vector< Origin::Matrix > matrixes
Definition: OriginParser.h:67
vector< Origin::SpreadSheet > spreadSheets
Definition: OriginParser.h:66
string resultsLog
Definition: OriginParser.h:73
pair< Origin::ProjectNode::NodeType, string > findObjectByIndex(unsigned int index) const
Definition: OriginParser.cpp:147
pair< Origin::ProjectNode::NodeType, Origin::Window > findWindowObjectByIndex(unsigned int index) const
Definition: OriginParser.cpp:180
Definition: OriginParser.h:41
vector< Origin::SpreadColumn >::difference_type findSpreadColumnByName(vector< Origin::SpreadSheet >::size_type spread, const string &name) const
Definition: OriginParser.cpp:62
tree< Origin::ProjectNode > projectTree
Definition: OriginParser.h:72
vector< Origin::Matrix >::difference_type findMatrixByName(const string &name) const
Definition: OriginParser.cpp:80
OriginParser * createOriginAnyParser(const string &fileName)
Definition: OriginAnyParser.cpp:176
vector< Origin::Graph > graphs
Definition: OriginParser.h:70
void convertSpreadToExcel(vector< Origin::SpreadSheet >::size_type spread)
Definition: OriginParser.cpp:213
unsigned int buildVersion
Definition: OriginParser.h:75
vector< Origin::Excel > excels
Definition: OriginParser.h:68