File indexing completed on 2024-04-14 14:12:16
0001 /*************************************************************************** 0002 File : OriginParser.h 0003 -------------------------------------------------------------------- 0004 Copyright : (C) 2008 Alex Kargovsky (kargovsky@yumr.phys.msu.su) 0005 Copyright : (C) 2017 Stefan Gerlach (stefan.gerlach@uni.kn) 0006 Description : Origin file parser base class 0007 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 * This program is distributed in the hope that it will be useful, * 0018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0020 * GNU General Public License for more details. * 0021 * * 0022 * You should have received a copy of the GNU General Public License * 0023 * along with this program; if not, write to the Free Software * 0024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0025 * Boston, MA 02110-1301 USA * 0026 * * 0027 ***************************************************************************/ 0028 0029 #ifndef ORIGIN_PARSER_H 0030 #define ORIGIN_PARSER_H 0031 0032 #include "OriginObj.h" 0033 #include "tree.hh" 0034 0035 #ifdef GENERATE_CODE_FOR_LOG 0036 #define LOG_PRINT( logfile, ... ) { fprintf(logfile, __VA_ARGS__); } 0037 #else // !GENERATE_CODE_FOR_LOG 0038 #define LOG_PRINT( logfile, ... ) {}; 0039 #endif 0040 0041 class OriginParser 0042 { 0043 public: 0044 virtual ~OriginParser() = default; 0045 virtual bool parse() = 0; 0046 0047 vector<Origin::SpreadSheet>::difference_type findSpreadByName(const string& name) const; 0048 vector<Origin::Matrix>::difference_type findMatrixByName(const string& name) const; 0049 vector<Origin::Function>::difference_type findFunctionByName(const string& name) const; 0050 vector<Origin::Excel>::difference_type findExcelByName(const string& name) const; 0051 0052 protected: 0053 vector<Origin::SpreadColumn>::difference_type findSpreadColumnByName(vector<Origin::SpreadSheet>::size_type spread, const string& name) const; 0054 vector<Origin::SpreadColumn>::difference_type findExcelColumnByName(vector<Origin::Excel>::size_type excel, vector<Origin::SpreadSheet>::size_type sheet, const string& name) const; 0055 pair<string, string> findDataByIndex(unsigned int index) const; 0056 pair<Origin::ProjectNode::NodeType, string> findObjectByIndex(unsigned int index) const; 0057 pair<Origin::ProjectNode::NodeType, Origin::Window> findWindowObjectByIndex(unsigned int index) const; 0058 void convertSpreadToExcel(vector<Origin::SpreadSheet>::size_type spread); 0059 0060 int findColumnByName(int spread, const string& name); 0061 private: 0062 bool iequals(const string&, const string&, const std::locale& = std::locale()) const; 0063 0064 public: 0065 vector<Origin::SpreadColumn> datasets; 0066 vector<Origin::SpreadSheet> spreadSheets; 0067 vector<Origin::Matrix> matrixes; 0068 vector<Origin::Excel> excels; 0069 vector<Origin::Function> functions; 0070 vector<Origin::Graph> graphs; 0071 vector<Origin::Note> notes; 0072 tree<Origin::ProjectNode> projectTree; 0073 string resultsLog; 0074 unsigned int windowsCount; 0075 unsigned int fileVersion, buildVersion; 0076 }; 0077 0078 OriginParser* createOriginAnyParser(const string& fileName); 0079 0080 #endif // ORIGIN_PARSER_H