-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvert.h
More file actions
73 lines (59 loc) · 1.99 KB
/
Convert.h
File metadata and controls
73 lines (59 loc) · 1.99 KB
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
#pragma once
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <limits>
#include <QString>
#include <QLocale>
#include <QVariant>
#include <QDebug>
#include <QPolygonF>
#include "Settings.h"
#include "Error.h"
#include "DataElement.h"
#include "Constants.h"
#include <QRegularExpression>
// convert and compare functions
// to change DataElement into float, int, or QString and to do string and
// numeric comparison (using epislon)
// forward error or warning to the error object
class Convert
{
public:
Convert(QLocale *);
~Convert();
void setdecimaldigits(int);
bool isNumeric(DataElement*);
int getInt(DataElement*);
unsigned int getUInt(DataElement*);
long getLong(DataElement*);
double getFloat(DataElement*);
QString getString(DataElement*);
QString getString(DataElement*, int);
double getMusicalNote(DataElement*);
int getBool(DataElement*);
QPolygonF *getPolygonF(DataElement*);
int compare(DataElement*, DataElement*);
int compareFloats(double, double);
static int getError() {
return getError(false);
}
static int getError(int clear) {
int olde = e;
if (clear) e = ERROR_NONE;
return olde;
}
private:
QLocale *locale;
QString isnumericexpression;
QRegularExpression isnumeric;
QRegularExpression musicalnote;
QMap<QString, int> notesmap{{"do", 0}, {"re", 2}, {"mi", 4}, {"fa", 5}, {"sol", 7}, {"la", 9}, {"si", 11}, {"c", 0}, {"d", 2}, {"e", 4}, {"f", 5}, {"g", 7}, {"a", 9}, {"b", 11}, {"h", 11}, {"ni", 0}, {"pa", 2}, {"vu", 4}, {"ga", 5}, {"di", 7}, {"ke", 9}, {"zo", 11},};
int ec(int, int);
int decimaldigits; // display n decinal digits 12 default - 8 to 15 valid
bool floattail; // display floats with a tail of ".0" if whole numbers
bool replaceDecimalPoint; // user can chose if INPUT and PRINT should use localized decimal point
QString decimalPoint;
static int e; // error number thrown - will be 0 if no error
};