-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathword.h
64 lines (47 loc) · 1.46 KB
/
word.h
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
#ifndef WORD_H
#define WORD_H
#include <climits>
#include <cfloat>
#include <QString>
#include <QMap>
#include <QHash>
class Word
{
public:
Word(const QChar& c);
Word(const char c, const int intVal = INT_MAX, const double doubleVal= DBL_MAX);
Word(const Word* other);
~Word();
// TODO: make these private...
QChar _char;
double _double;
int _int;
QMap<QChar, Word*> _parameters;
void setValue(QString& value);
bool isCommand() const;
bool acceptsParameter(const QChar& c) const;
bool acceptsParameter(const Word* other) const;
bool canBeImplied() const;
void addParameter(const Word* other);
void addParameter(const Word& other);
void removeParameter(const QChar& c);
double doubleValue() const;
int intValue() const;
bool parameterAsDouble(const QChar& c, double* value) const;
bool parameterAsInt(const QChar& c, int* value) const;
QString toString() const;
QString toCommandString() const;
QString getCommandError() const;
bool operator==(const Word& other) const;
bool operator!=(const Word& other) const;
bool operator<(const Word& other) const;
inline uint qHash(uint seed = 0) const { return ::qHash(_char, seed) + _int; }
private:
bool _wantsInt;
bool _isCommand;
QString _requiredParams;
QString _optionalParams;
int commandOrder() const;
};
inline uint qHash(const Word& word, uint seed = 0) { return word.qHash(seed); }
#endif // WORD_H