Debian Codegraph @

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

raw
1 #include <QvInput.h>
2 #include <QvReadError.h>
3 #include <QvFieldData.h>
4 #include <QvChildList.h>
5 #include <QvGroup.h>
6
7 QV_NODE_SOURCE(QvGroup);
8
9 QvGroup::QvGroup()
10 {
11 children = new QvChildList();
12 QV_NODE_CONSTRUCTOR(QvGroup);
13 isBuiltIn = TRUE;
14 }
15
16 QvGroup::~QvGroup()
17 {
18 delete children;
19 }
20
21 QvNode *
22 QvGroup::getChild(int index) const
23 {
24 return(*children)[index];
25 }
26
27 int
28 QvGroup::getNumChildren() const
29 {
30 return children->getLength();
31 }
32
33 QvChildList *
34 QvGroup::getChildren() const
35 {
36 return children;
37 }
38
39 QvBool
40 QvGroup::readInstance(QvInput *in)
41 {
42 QvName typeString;
43 QvFieldData *fieldData = getFieldData();
44
45 if (! isBuiltIn) {
46 if (in->read(typeString, TRUE)) {
47 if (typeString == "fields") {
48 if (! fieldData->readFieldTypes(in, this)) {
49 QvReadError::post(in, "Bad field specifications for node");
50 return FALSE;
51 }
52 }
53 else
54 in->putBack(typeString.getString());
55 }
56 }
57
58 return (fieldData->read(in, this, FALSE) && readChildren(in));
59 }
60
61 QvBool
62 QvGroup::readChildren(QvInput *in)
63 {
64 QvNode *child;
65 QvBool ret = TRUE;
66
67 while (TRUE) {
68 if (read(in, child)) {
69 if (child != NULL)
70 children->append(child);
71 else
72 break;
73 }
74 else {
75 ret = FALSE;
76 break;
77 }
78 }
79
80 return ret;
81 }