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
|
#include <QvDebugError.h>
#include <QvReadError.h>
#include <QvSFBitMask.h>
// Special characters when reading or writing value in ASCII
#define OPEN_PAREN '('
#define CLOSE_PAREN ')'
#define BITWISE_OR '|'
QV_SFIELD_SOURCE(QvSFBitMask);
QvBool
QvSFBitMask::readValue(QvInput *in)
{
char c;
QvName n;
int v;
#ifdef DEBUG
if (enumValues == NULL) {
QvDebugError::post("QvSFBitMask::readValue",
"Enum values were never initialized");
QvReadError::post(in, "Couldn't read QvSFBitMask values");
return FALSE;
}
#endif /* DEBUG */
value = 0;
// Read first character
if (! in->read(c))
return FALSE;
// Check for parenthesized list of bitwise-or'ed flags
if (c == OPEN_PAREN) {
// Read names separated by BITWISE_OR
while (TRUE) {
if (in->read(n, TRUE) && ! (! n) ) {
if (findEnumValue(n, v))
value |= v;
else {
QvReadError::post(in, "Unknown QvSFBitMask bit "
"mask value \"%s\"", n.getString());
return FALSE;
}
}
if (! in->read(c)) {
QvReadError::post(in, "EOF reached before '%c' "
"in QvSFBitMask value", CLOSE_PAREN);
return FALSE;
}
if (c == CLOSE_PAREN)
break;
else if (c != BITWISE_OR) {
QvReadError::post(in, "Expected '%c' or '%c', got '%c' ",
"in QvSFBitMask value",
BITWISE_OR, CLOSE_PAREN, c);
return FALSE;
}
}
}
else {
in->putBack(c);
// Read mnemonic value as a character string identifier
if (! in->read(n, TRUE))
return FALSE;
if (! findEnumValue(n, value)) {
QvReadError::post(in, "Unknown QvSFBitMask bit "
"mask value \"%s\"", n.getString());
return FALSE;
}
}
return TRUE;
}
|