Debian Codegraph @

src/bin/geomutil/vrml2oogl/lib/QvSFBitMask.c++

raw
1 #include <QvDebugError.h>
2 #include <QvReadError.h>
3 #include <QvSFBitMask.h>
4
5 // Special characters when reading or writing value in ASCII
6 #define OPEN_PAREN '('
7 #define CLOSE_PAREN ')'
8 #define BITWISE_OR '|'
9
10 QV_SFIELD_SOURCE(QvSFBitMask);
11
12 QvBool
13 QvSFBitMask::readValue(QvInput *in)
14 {
15 char c;
16 QvName n;
17 int v;
18
19 #ifdef DEBUG
20 if (enumValues == NULL) {
21 QvDebugError::post("QvSFBitMask::readValue",
22 "Enum values were never initialized");
23 QvReadError::post(in, "Couldn't read QvSFBitMask values");
24 return FALSE;
25 }
26 #endif /* DEBUG */
27
28 value = 0;
29
30 // Read first character
31 if (! in->read(c))
32 return FALSE;
33
34 // Check for parenthesized list of bitwise-or'ed flags
35 if (c == OPEN_PAREN) {
36
37 // Read names separated by BITWISE_OR
38 while (TRUE) {
39 if (in->read(n, TRUE) && ! (! n) ) {
40
41 if (findEnumValue(n, v))
42 value |= v;
43
44 else {
45 QvReadError::post(in, "Unknown QvSFBitMask bit "
46 "mask value \"%s\"", n.getString());
47 return FALSE;
48 }
49 }
50
51 if (! in->read(c)) {
52 QvReadError::post(in, "EOF reached before '%c' "
53 "in QvSFBitMask value", CLOSE_PAREN);
54 return FALSE;
55 }
56
57 if (c == CLOSE_PAREN)
58 break;
59
60 else if (c != BITWISE_OR) {
61 QvReadError::post(in, "Expected '%c' or '%c', got '%c' ",
62 "in QvSFBitMask value",
63 BITWISE_OR, CLOSE_PAREN, c);
64 return FALSE;
65 }
66 }
67 }
68
69 else {
70 in->putBack(c);
71
72 // Read mnemonic value as a character string identifier
73 if (! in->read(n, TRUE))
74 return FALSE;
75
76 if (! findEnumValue(n, value)) {
77 QvReadError::post(in, "Unknown QvSFBitMask bit "
78 "mask value \"%s\"", n.getString());
79 return FALSE;
80 }
81 }
82
83 return TRUE;
84 }