File: DataElement.h

package info (click to toggle)
basic256 2.0.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 15,076 kB
  • sloc: cpp: 16,791; yacc: 3,979; lex: 1,446; makefile: 25
file content (96 lines) | stat: -rwxr-xr-x 1,899 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
92
93
94
95
96
#pragma once

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <limits>

#include <QString>


#include "Error.h"
#include "BasicTypes.h"

// the DataElement.h and DataElements.cpp define a class that is
// used in stack and variable to store  single element of data and the
// definitions of the various types of values that may be stored

// we will pass a pointer to a DataElement to the functions of the
// Convert class for all output

#define MAXARRAYSIZE 1048576
class DataElement;

class DataElementArray
{
    public:
        int xdim;
        int ydim;
        std::vector<DataElement> data;
};


class DataElementMap
{
    public:
        std::map<QString, DataElement> data;
};

class DataElement
{
	public:
		int type;	// type from BasicTypes.h
		QString stringval;
		double floatval;
		long intval;
		int level;
		DataElementArray *arr;
		DataElementMap *map;
        

		DataElement();
		~DataElement();
		
		DataElement(QString);
		DataElement(double);
		DataElement(long);
		DataElement(int);

		QString debug();
		void copy(DataElement *);
		
		void clear();
		
		void arrayDim(const int, const int, const bool);
		DataElement* arrayGetData(const int, const int);
		void arraySetData(const int, const int, DataElement *);
		void arrayUnassign(const int, const int);
		int arrayRows();
		int arrayCols();

		void mapDim();
		DataElement* mapGetData(QString);
		void mapSetData(QString, DataElement *);
		void mapUnassign(QString);
		int mapLength();
		bool mapKey(QString);
		
		static int getError() {
			return getError(false);
		}

		static int getError(int clear) {
			int olde = e;
			if (clear) e = ERROR_NONE;
			return olde;
		}

	private:
		static int e;		// error number thrown - will be 0 if no error
		void init();
};