Files Classes Functions Hierarchy
#include <vrmlshapeparse.h>
Public Member Functions | |
| vrmlshapetoken (stringc &id_) | |
| A token is identified through a string id. | |
| virtual | ~vrmlshapetoken () |
| Destructor. | |
| void | eval (bool &handled, vrmlshapeparse &p) const |
| If the current token in the parser is this token then the work is forwarded to eval( vrmlshapeparse& p). | |
| virtual void | eval (vrmlshapeparse &p) const =0 |
| The current token in the token stream is evaluated. | |
| void | consumescope (vrmlshapeparse &p, stringc &left, stringc &right) const |
| The scope between left and right tokens is consumed by incrementing the token stream when encountering these tokens, else forward to depth(vrmlshapeparse &). | |
| virtual void | depth (vrmlshapeparse &p) const |
| This is over ridden to interpret the scope. | |
Public Attributes | |
| stringc | id |
| A token identity. | |
This base class implements general behaviour and work is forwarded to the derived classes with virtual functions.
I would call this design a pattern but have no idea how to label it so I will describe it.
The eval(bool &, vrmlshapeparse &) calles eval(vrmlshapeparse &) if the current token in the parser is this token as matched with id. So a derived class overloads eval(vrmlshapeparse &) to capture this situation.
As the data is heirachical eval(vrmlshapeparse &) uses consumescope(..) to remove the scope tokens from the stream and interpret inside the scope by forwarding this to depth(vrmlshapeparse &).
Definition at line 35 of file vrmlshapeparse.h.
| vrmlshapetoken::vrmlshapetoken | ( | stringc & | id_ | ) | [inline] |
A token is identified through a string id.
Definition at line 43 of file vrmlshapeparse.h.
00044 : id(id_) {}
| virtual vrmlshapetoken::~vrmlshapetoken | ( | ) | [inline, virtual] |
| void vrmlshapetoken::consumescope | ( | vrmlshapeparse & | p, | |
| stringc & | left, | |||
| stringc & | right | |||
| ) | const |
The scope between left and right tokens is consumed by incrementing the token stream when encountering these tokens, else forward to depth(vrmlshapeparse &).
Definition at line 39 of file vrmlshapeparse.cpp.
References vrmlshapeparse::tokenstream.
Referenced by vrmlshapeShape::eval(), vrmlshapeIndexedLineSet::eval(), vrmlshapeMaterial::eval(), and vrmlshapeIndexedFaceSet::eval().
00044 { 00045 ++p.tokenstream; 00046 // Insist that client knows what they are 00047 // doing and is expecting the scope. 00048 assert(p.tokenstream()==left); 00049 00050 int count = 1; 00051 00052 ++p.tokenstream; 00053 while ((count>0) && !p.tokenstream) 00054 { 00055 stringc & s(p.tokenstream()); 00056 if (s==left) 00057 { 00058 ++count; 00059 ++p.tokenstream; 00060 } 00061 else 00062 { 00063 if (s==right) 00064 { 00065 --count; 00066 ++p.tokenstream; 00067 } 00068 else 00069 depth(p); 00070 }; 00071 } 00072 }
| void vrmlshapetoken::depth | ( | vrmlshapeparse & | p | ) | const [virtual] |
This is over ridden to interpret the scope.
You could see this as the meat in the sandwich. The token stream must be incremented.
Reimplemented in vrmlshapeShape, vrmlshapeIndexedLineSet, vrmlshapeIndexedFaceSet, and vrmlshapeMaterial.
Definition at line 33 of file vrmlshapeparse.cpp.
References vrmlshapeparse::tokenstream.
00034 { 00035 ++p.tokenstream; 00036 }
| virtual void vrmlshapetoken::eval | ( | vrmlshapeparse & | p | ) | const [pure virtual] |
The current token in the token stream is evaluated.
Implemented in vrmlshapeShape, vrmlshapeIndexedLineSet, vrmlshapeIndexedFaceSet, vrmlshapeMaterial, vrmlshapediffuseColor, vrmlshapeemissiveColor, vrmlshapeambientIntensity, vrmlshapepoint, vrmlshapeNormal, and vrmlshapecoordIndex.
| void vrmlshapetoken::eval | ( | bool & | handled, | |
| vrmlshapeparse & | p | |||
| ) | const |
If the current token in the parser is this token then the work is forwarded to eval( vrmlshapeparse& p).
Definition at line 76 of file vrmlshapeparse.cpp.
References dbg, and vrmlshapeparse::tokenstream.
00080 { 00081 assert(!p.tokenstream); 00082 00083 #ifdef DEBUG_VRMLSHAPEPARSE 00084 //messagefile("debug.txt")() << p.tokenstream() << "==" << id << endl; 00085 dbg() << p.tokenstream() << "==" << id << endl; 00086 #endif 00087 00088 if (p.tokenstream()==id) 00089 { 00090 handled = true; 00091 this->eval(p); 00092 } 00093 else 00094 handled = false; 00095 }
1.5.8