liborigin2: /build/liborigin2/src/liborigin2/OriginParser.h Source File

liborigin2 29/08/2011

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

/build/liborigin2/src/liborigin2/OriginParser.h
Go to the documentation of this file.
1 /***************************************************************************
2 File : OriginParser.h
3 --------------------------------------------------------------------
4 Copyright : (C) 2009 - 2011 Ion Vasilief
5 (C) 2008 Alex Kargovsky
6 Email (use @ for *) : ion_vasilief*yahoo.fr
7 Description : Origin file parser base class
8
9 ***************************************************************************/
10
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 * This program is distributed in the hope that it will be useful, *
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21 * GNU General Public License for more details. *
22 * *
23 * You should have received a copy of the GNU General Public License *
24 * along with this program; if not, write to the Free Software *
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26 * Boston, MA 02110-1301 USA *
27 * *
28 ***************************************************************************/
29
30 #ifndef ORIGIN_PARSER_H
31 #define ORIGIN_PARSER_H
32
33 #include "OriginObj.h"
34 #include "tree.hh"
35
36 #ifndef NO_LOG_FILE
37 #define LOG_PRINT( logfile, args... )\
38 {\
39 int ioret = fprintf(logfile, args);\
40 assert(ioret>0);\
41 }
42 #else
43 #define LOG_PRINT( logfile, args... ) {};
44 #endif
45
46 class OriginParser
47 {
48 public:
49 virtual ~OriginParser() {};
50 virtual bool parse() = 0;
51 void setFileVersion(unsigned int version){fileVersion = version;};
52
53 int findSpreadByName(const string& name) const;
54 int findMatrixByName(const string& name) const;
55 int findFunctionByName(const string& name) const;
56 int findExcelByName(const string& name) const;
57
58 protected:
59 int findExcelColumnByName(int excel, int sheet, const string& name) const;
60 pair<string, string> findDataByIndex(unsigned int index) const;
61 pair<Origin::ProjectNode::NodeType, string> findObjectByIndex(unsigned int index) const;
62 void convertSpreadToExcel(vector<Origin::SpreadSheet>::size_type spread);
63
64 int findColumnByName(int spread, const string& name);
65 int findColumnByIndexAndName(int spread, unsigned int index, const string& name);
66
67 public:
68 vector<Origin::SpreadSheet> speadSheets;
69 vector<Origin::Matrix> matrices;
70 vector<Origin::Excel> excels;
71 vector<Origin::Function> functions;
72 vector<Origin::Graph> graphs;
73 vector<Origin::Note> notes;
74 tree<Origin::ProjectNode> projectTree;
75 string resultsLog;
76 unsigned int windowsCount;
77 unsigned int fileVersion;
78 };
79
80 OriginParser* createOrigin410Parser(const string& fileName);
81 OriginParser* createOrigin500Parser(const string& fileName);
82 OriginParser* createOrigin610Parser(const string& fileName);
83 OriginParser* createOrigin700Parser(const string& fileName);
84 OriginParser* createOrigin750Parser(const string& fileName);
85 OriginParser* createOrigin800Parser(const string& fileName);
86 OriginParser* createOrigin810Parser(const string& fileName);
87 OriginParser* createOrigin850Parser(const string& fileName);
88
89 #endif // ORIGIN_PARSER_H