File: OriginAnyParser.h

package info (click to toggle)
labplot 2.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 51,864 kB
  • sloc: cpp: 122,588; ansic: 4,287; python: 808; yacc: 536; xml: 227; sh: 179; awk: 35; makefile: 7
file content (91 lines) | stat: -rw-r--r-- 3,431 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * OriginAnyParser.h
 *
 * Copyright 2017 Miquel Garriga <gbmiquel@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Parser for all versions. Based mainly on Origin750Parser.h
 */
#ifndef ORIGIN_ANY_PARSER_H
#define ORIGIN_ANY_PARSER_H

#include "OriginParser.h"
#include "endianfstream.hh"
#include <string>
#include <cmath> // for floor()

using namespace std;
using namespace Origin;

class OriginAnyParser : public OriginParser
{
public:
	explicit OriginAnyParser(const string& fileName);
	bool parse() override;

protected:
	unsigned int readObjectSize();
	string readObjectAsString(unsigned int);
	void readFileVersion();
	void readGlobalHeader();
	bool readDataSetElement();
	bool readWindowElement();
	bool readLayerElement();
	unsigned int readAnnotationList();
	bool readAnnotationElement();
	bool readCurveElement();
	bool readAxisBreakElement();
	bool readAxisParameterElement(unsigned int);
	bool readParameterElement();
	bool readNoteElement();
	void readProjectTree();
	unsigned int readFolderTree(tree<ProjectNode>::iterator, unsigned int);
	void readProjectLeaf(tree<ProjectNode>::iterator);
	void readAttachmentList();
	bool getColumnInfoAndData(const string&, unsigned int, const string&, unsigned int);
	void getMatrixValues(const string&, unsigned int, short, char, char, vector<Origin::Matrix>::difference_type);
	void getWindowProperties(Origin::Window&, const string&, unsigned int);
	void getLayerProperties(const string&, unsigned int);
	Origin::Color getColor(const string&);
	void getAnnotationProperties(const string&, unsigned int, const string&, unsigned int, const string&, unsigned int, const string&, unsigned int);
	void getCurveProperties(const string&, unsigned int, const string&, unsigned int);
	void getAxisBreakProperties(const string&, unsigned int);
	void getAxisParameterProperties(const string&, unsigned int, int);
	void getNoteProperties(const string&, unsigned int, const string&, unsigned int, const string&, unsigned int);
	void getColorMap(ColorMap&, const string&, unsigned int);
	void getZcolorsMap(ColorMap&, const string&, unsigned int);
	void getProjectLeafProperties(tree<ProjectNode>::iterator, const string&, unsigned int);
	void getProjectFolderProperties(tree<ProjectNode>::iterator, const string&, unsigned int);
	void outputProjectTree(std::ostream &);

	inline time_t doubleToPosixTime(double jdt)
	{
		/* 2440587.5 is julian date for the unixtime epoch */
		return (time_t) floor((jdt - 2440587) * 86400. + 0.5);
	}

	iendianfstream file;
	FILE *logfile;

	streamsize d_file_size;
	streamoff curpos;
	unsigned int objectIndex, parseError;
	vector<Origin::SpreadSheet>::difference_type ispread;
	vector<Origin::Matrix>::difference_type imatrix;
	vector<Origin::Excel>::difference_type iexcel;
	int igraph, ilayer;
};

#endif // ORIGIN_ANY_PARSER_H