File indexing completed on 2024-05-12 03:47:01

0001 /*
0002     OriginAnyParser.h
0003 
0004     SPDX-FileCopyrightText: 2017 Miquel Garriga <gbmiquel@gmail.com>
0005 
0006     SPDX-License-Identifier: GPL-3.0-or-later
0007 
0008     Parser for all versions. Based mainly on Origin750Parser.h
0009 */
0010 #ifndef ORIGIN_ANY_PARSER_H
0011 #define ORIGIN_ANY_PARSER_H
0012 
0013 #include "OriginParser.h"
0014 #include "endianfstream.hh"
0015 
0016 #include <string>
0017 #include <cmath> // for floor()
0018 
0019 using namespace Origin;
0020 using namespace endianfstream;
0021 
0022 class ORIGIN_EXPORT OriginAnyParser : public OriginParser
0023 {
0024 public:
0025     explicit OriginAnyParser(const std::string &fileName);
0026     bool parse() override;
0027 
0028 protected:
0029     unsigned int readObjectSize();
0030     std::string readObjectAsString(unsigned int);
0031     void readFileVersion();
0032     void readGlobalHeader();
0033     bool readDataSetElement();
0034     bool readWindowElement();
0035     bool readLayerElement();
0036     unsigned int readAnnotationList();
0037     bool readAnnotationElement();
0038     bool readCurveElement();
0039     bool readAxisBreakElement();
0040     bool readAxisParameterElement(unsigned int);
0041     bool readParameterElement();
0042     bool readNoteElement();
0043     void readProjectTree();
0044     unsigned int readFolderTree(tree<ProjectNode>::iterator, unsigned int);
0045     void readProjectLeaf(tree<ProjectNode>::iterator);
0046     void readAttachmentList();
0047     bool getColumnInfoAndData(const std::string &, unsigned int, const std::string &, unsigned int);
0048     void getMatrixValues(const std::string &, unsigned int, short, char, char,
0049                          std::vector<Origin::Matrix>::difference_type);
0050     void getWindowProperties(Origin::Window &, const std::string &, unsigned int);
0051     void getLayerProperties(const std::string &, unsigned int);
0052     Origin::Color getColor(const std::string &);
0053     void getAnnotationProperties(const std::string &, unsigned int, const std::string &,
0054                                  unsigned int, const std::string &, unsigned int,
0055                                  const std::string &, unsigned int);
0056     void getCurveProperties(const std::string &, unsigned int, const std::string &, unsigned int);
0057     void getAxisBreakProperties(const std::string &, unsigned int);
0058     void getAxisParameterProperties(const std::string &, unsigned int, int);
0059     void getNoteProperties(const std::string &, unsigned int, const std::string &, unsigned int,
0060                            const std::string &, unsigned int);
0061     void getColorMap(ColorMap &, const std::string &, unsigned int);
0062     void getZcolorsMap(ColorMap &, const std::string &, unsigned int);
0063     void getProjectLeafProperties(tree<ProjectNode>::iterator, const std::string &, unsigned int);
0064     void getProjectFolderProperties(tree<ProjectNode>::iterator, const std::string &, unsigned int);
0065     void outputProjectTree(std::ostream &);
0066 
0067     inline time_t doubleToPosixTime(double jdt)
0068     {
0069         /* 2440587.5 is julian date for the unixtime epoch */
0070         return (time_t)floor((jdt - 2440587) * 86400. + 0.5);
0071     }
0072 
0073     iendianfstream file;
0074     FILE *logfile;
0075 
0076     std::streamsize d_file_size;
0077     std::streamoff curpos;
0078     unsigned int objectIndex, parseError;
0079     std::vector<Origin::SpreadSheet>::difference_type ispread;
0080     std::vector<Origin::Matrix>::difference_type imatrix;
0081     std::vector<Origin::Excel>::difference_type iexcel;
0082     int igraph, ilayer;
0083 };
0084 
0085 #endif // ORIGIN_ANY_PARSER_H