liborigin2 13/09/2010
|
00001 /*************************************************************************** 00002 File : OriginParser.h 00003 -------------------------------------------------------------------- 00004 Copyright : (C) 2008 Alex Kargovsky 00005 Email (use @ for *) : kargovsky*yumr.phys.msu.su 00006 Description : Origin file parser base class 00007 00008 ***************************************************************************/ 00009 00010 /*************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 * This program is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU General Public License * 00023 * along with this program; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00025 * Boston, MA 02110-1301 USA * 00026 * * 00027 ***************************************************************************/ 00028 00029 #ifndef ORIGIN_PARSER_H 00030 #define ORIGIN_PARSER_H 00031 00032 #include "OriginObj.h" 00033 #include "tree.hh" 00034 00035 #ifndef NO_CODE_GENERATION_FOR_LOG 00036 #define LOG_PRINT( logfile, args... ) \ 00037 { \ 00038 int ioret= fprintf(logfile, args); \ 00039 assert(ioret>0); \ 00040 } 00041 #else // !NO_CODE_GENERATION_FOR_LOG 00042 #define LOG_PRINT( logfile, args... ) {}; 00043 #endif // NO_CODE_GENERATION_FOR_LOG 00044 00045 class OriginParser 00046 { 00047 public: 00048 virtual ~OriginParser() {}; 00049 virtual bool parse() = 0; 00050 void setFileVersion(unsigned int version){fileVersion = version;}; 00051 00052 vector<Origin::SpreadSheet>::difference_type findSpreadByName(const string& name) const; 00053 vector<Origin::Matrix>::difference_type findMatrixByName(const string& name) const; 00054 vector<Origin::Function>::difference_type findFunctionByName(const string& name) const; 00055 vector<Origin::Excel>::difference_type findExcelByName(const string& name) const; 00056 00057 protected: 00058 vector<Origin::SpreadColumn>::difference_type findSpreadColumnByName(vector<Origin::SpreadSheet>::size_type spread, const string& name) const; 00059 vector<Origin::SpreadColumn>::difference_type findExcelColumnByName(vector<Origin::Excel>::size_type excel, vector<Origin::SpreadSheet>::size_type sheet, const string& name) const; 00060 pair<string, string> findDataByIndex(unsigned int index) const; 00061 pair<Origin::ProjectNode::NodeType, string> findObjectByIndex(unsigned int index) const; 00062 void convertSpreadToExcel(vector<Origin::SpreadSheet>::size_type spread); 00063 00064 int findColumnByName(int spread, const string& name); 00065 00066 public: 00067 vector<Origin::SpreadSheet> speadSheets; 00068 vector<Origin::Matrix> matrixes; 00069 vector<Origin::Excel> excels; 00070 vector<Origin::Function> functions; 00071 vector<Origin::Graph> graphs; 00072 vector<Origin::Note> notes; 00073 tree<Origin::ProjectNode> projectTree; 00074 string resultsLog; 00075 unsigned int windowsCount; 00076 unsigned int fileVersion; 00077 }; 00078 00079 OriginParser* createOriginDefaultParser(const string& fileName); 00080 OriginParser* createOrigin600Parser(const string& fileName); 00081 OriginParser* createOrigin610Parser(const string& fileName); 00082 OriginParser* createOrigin700Parser(const string& fileName); 00083 OriginParser* createOrigin750Parser(const string& fileName); 00084 OriginParser* createOrigin800Parser(const string& fileName); 00085 OriginParser* createOrigin810Parser(const string& fileName); 00086 00087 #endif // ORIGIN_PARSER_H