1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSCANPARSESKEL_H_
40 #define _OSGSCANPARSESKEL_H_
46 #include "OSGSystemDef.h"
47 #include "OSGBaseTypes.h"
48 #include "OSGScanParseSkelParser.hpp"
51 // We have to prevent double inclusion of the scanner header file
53 #include "OSGScanParseSkelParser.hpp"
58 #ifdef OSG_FLEX_USE_IOSTREAM_INPUT
62 #ifdef OSG_USE_OSG2_NAMESPACE
63 # define OSGScanParseLexer OSG2ScanParseLexer
64 # define OSGScanParseSkel_parse OSG2ScanParseSkel_parse
67 class OSGScanParseLexer
;
68 int OSGScanParseSkel_parse(void*);
72 /*! Parser / Scanner Skeleton for VRML97 syntax based file formats
73 \ingroup GrpSystemFileIOScanParse
74 \ingroup GrpLibOSGSystem
77 class OSG_SYSTEM_DLLMAPPING ScanParseSkel
79 friend int ::OSGScanParseSkel_parse(void*);
81 /*========================== PUBLIC =================================*/
87 OSGsfBool
= TOK_SFBool
,
88 OSGsfColor
= TOK_SFColor
,
89 OSGsfColorRGBA
= TOK_SFColorRGBA
,
90 OSGsfDouble
= TOK_SFDouble
,
91 OSGsfFloat
= TOK_SFFloat
,
92 OSGsfImage
= TOK_SFImage
,
93 OSGsfInt32
= TOK_SFInt32
,
94 OSGsfMatrix3d
= TOK_SFMatrix3d
,
95 OSGsfMatrix3f
= TOK_SFMatrix3f
,
96 OSGsfMatrix4d
= TOK_SFMatrix4d
,
97 OSGsfMatrix4f
= TOK_SFMatrix4f
,
98 OSGsfNode
= TOK_SFNode
,
99 OSGsfRotation
= TOK_SFRotation
,
100 OSGsfString
= TOK_SFString
,
101 OSGsfTime
= TOK_SFTime
,
102 OSGsfVec2d
= TOK_SFVec2d
,
103 OSGsfVec2f
= TOK_SFVec2f
,
104 OSGsfVec3d
= TOK_SFVec3d
,
105 OSGsfVec3f
= TOK_SFVec3f
,
106 OSGsfVec4d
= TOK_SFVec4d
,
107 OSGsfVec4f
= TOK_SFVec4f
,
108 OSGmfBool
= TOK_MFBool
,
109 OSGmfColor
= TOK_MFColor
,
110 OSGmfColorRGBA
= TOK_MFColorRGBA
,
111 OSGmfDouble
= TOK_MFDouble
,
112 OSGmfFloat
= TOK_MFFloat
,
113 OSGmfImage
= TOK_MFImage
,
114 OSGmfInt32
= TOK_MFInt32
,
115 OSGmfMatrix3d
= TOK_MFMatrix3d
,
116 OSGmfMatrix3f
= TOK_MFMatrix3f
,
117 OSGmfMatrix4d
= TOK_MFMatrix4d
,
118 OSGmfMatrix4f
= TOK_MFMatrix4f
,
119 OSGmfNode
= TOK_MFNode
,
120 OSGmfRotation
= TOK_MFRotation
,
121 OSGmfString
= TOK_MFString
,
122 OSGmfTime
= TOK_MFTime
,
123 OSGmfVec2d
= TOK_MFVec2d
,
124 OSGmfVec2f
= TOK_MFVec2f
,
125 OSGmfVec3d
= TOK_MFVec3d
,
126 OSGmfVec3f
= TOK_MFVec3f
,
127 OSGmfVec4d
= TOK_MFVec4d
,
128 OSGmfVec4f
= TOK_MFVec4f
,
130 OSGmfColor4f
= TOK_MFColorRGBA
,
131 OSGmfColor4i
= TOK_MFColor4i
,
132 OSGmfColor3f
= TOK_MFColor
,
133 OSGmfMatrix
= TOK_MFMatrix4f
,
134 OSGmfPnt2f
= TOK_MFPnt2f
,
135 OSGmfPnt3f
= TOK_MFPnt3f
,
136 OSGmfPnt4f
= TOK_MFPnt4f
,
137 OSGmfPlane
= TOK_MFPlane
,
138 OSGsfColor4f
= TOK_SFColorRGBA
,
139 OSGsfColor4i
= TOK_SFColor4i
,
140 OSGsfColor3f
= TOK_SFColor
,
141 OSGsfMatrix
= TOK_SFMatrix4f
,
142 OSGsfPnt2f
= TOK_SFPnt2f
,
143 OSGsfPnt3f
= TOK_SFPnt3f
,
144 OSGsfPnt4f
= TOK_SFPnt4f
,
145 OSGsfVec2i
= TOK_SFVec2i
,
146 OSGsfVec3i
= TOK_SFVec3i
,
147 OSGmfVec2i
= TOK_MFVec2i
,
148 OSGsfPlane
= TOK_SFPlane
,
149 OSGsfVolume
= TOK_SFVolume
157 /*---------------------------------------------------------------------*/
158 /*! \name Constructors */
164 /*---------------------------------------------------------------------*/
165 /*! \name Destructor */
168 virtual ~ScanParseSkel(void);
171 /*---------------------------------------------------------------------*/
175 #ifdef OSG_FLEX_USE_IOSTREAM_INPUT
176 void scanStream ( std::istream
&is
);
179 void scanFile (const Char8
*szFilename
);
181 virtual Int32
lex ( YYSTYPE
*lvalp
);
182 virtual const Char8
*getText ( void );
184 virtual void handleError( void *pSelf
,
185 const Char8
*szErrorText
);
188 /*---------------------------------------------------------------------*/
189 /*! \name Prototypes */
192 virtual bool verifyHeader (const Char8
*szHeader
);
193 virtual bool checkHeader ( void );
195 virtual void beginProto (const Char8
*szProtoname
);
196 virtual void endProtoInterface (void);
197 virtual void endProto (void);
199 virtual void beginExternProto (const Char8
*szProtoname
);
200 virtual void endExternProtoInterface (void );
201 virtual void endExternProto (void );
203 virtual void beginScript (const Char8
*szProtoname
);
204 virtual void endScript (void);
206 virtual void beginEventInDecl (const Char8
*szEventType
,
207 const UInt32 uiFieldTypeId
,
208 const Char8
*szEventName
);
210 virtual void beginEventOutDecl (const Char8
*szEventType
,
211 const UInt32 uiFieldTypeId
,
212 const Char8
*szEventName
);
214 virtual void endEventDecl (void);
216 virtual void beginFieldDecl (const Char8
*szFieldType
,
217 const UInt32 uiFieldTypeId
,
218 const Char8
*szFieldName
);
220 virtual void endFieldDecl (void);
222 virtual void beginExposedFieldDecl (const Char8
*szFieldType
,
223 const UInt32 uiFieldTypeId
,
224 const Char8
*szFieldName
);
226 virtual void endExposedFieldDecl (void);
229 virtual void addExternEventInDecl (const Char8
*szEventType
,
230 const UInt32 uiFieldTypeId
,
231 const Char8
*szEventName
);
233 virtual void addExternEventOutDecl (const Char8
*szEventType
,
234 const UInt32 uiFieldTypeId
,
235 const Char8
*szEventName
);
237 virtual void addExternFieldDecl (const Char8
*szFieldType
,
238 const UInt32 uiFieldTypeId
,
239 const Char8
*szFieldName
);
241 virtual void addExternExposedFieldDecl(const Char8
*szFieldType
,
242 const UInt32 uiFieldTypeId
,
243 const Char8
*szFieldName
);
246 /*---------------------------------------------------------------------*/
250 virtual void beginField(const Char8
*szFieldname
,
251 const UInt32 uiFieldTypeId
);
253 virtual void endField (void);
256 /*---------------------------------------------------------------------*/
260 virtual void beginNode(const Char8
*szNodeTypename
,
261 const Char8
*szNodename
,
262 const BitVector bvLocalFlags
);
264 virtual void endNode (void);
266 virtual void nullNode (void);
268 virtual void use (const Char8
*szName
);
269 virtual void is (const Char8
*szName
);
272 /*---------------------------------------------------------------------*/
276 virtual void addBufferAsStringValue(void);
278 virtual void addFieldValue(const Char8
*szFieldVal
);
280 virtual void addBoolValue(bool b
);
282 virtual void addColorValue(const Color3f
&c
);
284 virtual void addColorRGBAValue(const Color4f
&c
);
286 virtual void addDoubleValue(Real64 d
);
288 virtual void addFloatValue(Real32 f
);
290 virtual void addImageValue(Image
*img
);
292 virtual void addInt32Value(Int32 i
);
294 virtual void addMatrix3dValue(Real64 m00
, Real64 m10
, Real64 m20
,
295 Real64 m01
, Real64 m11
, Real64 m21
,
296 Real64 m02
, Real64 m12
, Real64 m22
);
298 virtual void addMatrix3fValue(Real32 m00
, Real32 m10
, Real32 m20
,
299 Real32 m01
, Real32 m11
, Real32 m21
,
300 Real32 m02
, Real32 m12
, Real32 m22
);
302 virtual void addMatrix4dValue(const Matrix4d
&m
);
304 virtual void addMatrix4fValue(const Matrix4f
&m
);
306 virtual void addRotationValue(const Vec3f
&axis
, Real32 angle
);
308 virtual void addStringValue(const std::string
&s
);
310 virtual void addTimeValue(Time t
);
312 virtual void addVec2dValue(const Vec2d
&v
);
314 virtual void addVec2fValue(const Vec2f
&v
);
316 virtual void addVec3dValue(const Vec3d
&v
);
318 virtual void addVec3fValue(const Vec3f
&v
);
320 virtual void addVec4dValue(const Vec4d
&v
);
322 virtual void addVec4fValue(const Vec4f
&v
);
324 virtual void addColor4iValue(const Color4ub
&c
);
326 virtual void addPnt2fValue(const Pnt2f
&p
);
328 virtual void addPnt3fValue(const Pnt3f
&p
);
330 virtual void addPnt4fValue(const Pnt4f
&p
);
332 virtual void addVec2iValue(const Vec2i
&v
);
334 virtual void addVec3iValue(const Vec3i
&v
);
336 virtual void addPlaneValue(const Plane
&p
);
338 virtual void addVolumeValue(const BoxVolume
&v
);
340 virtual void addRoute (const Char8
*szOutNodename
,
341 const Char8
*szOutFieldname
,
342 const Char8
*szInNodename
,
343 const Char8
*szInFieldname
);
345 virtual void profileElement (const Char8
*szProfileName
);
347 virtual void componentElement (const Char8
*szComponentName
);
349 virtual void metaElement (const Char8
*szMetaKey
,
350 const Char8
*szMetaValue
);
352 virtual void importElement (const Char8
*szInlineName
,
353 const Char8
*szNodeName
,
354 const Char8
*szImportAs
);
356 virtual void exportElement (const Char8
*szNodeName
,
357 const Char8
*szExportAs
);
360 /*---------------------------------------------------------------------*/
361 /*! \name Type Information */
364 bool getMapFieldTypes (void);
366 virtual Int32
mapExtIntFieldType(const Char8
*szFieldname
,
367 const Int32 iFieldTypeId
);
369 virtual UInt32
getFieldType (const Char8
*szFieldname
);
371 OSGScanParseLexer
*getLexer(void);
374 /*---------------------------------------------------------------------*/
378 void addOptions(UInt32 options
);
379 void subOptions(UInt32 options
);
380 UInt32
getOptions(void ) const;
383 /*========================= PROTECTED ===============================*/
387 /*---------------------------------------------------------------------*/
392 Char8
*_szReferenceHeader
;
393 OSGScanParseLexer
*_pLexer
;
397 void setMapTypeIds ( bool bVal
);
399 void setReferenceHeader(const Char8
*szReferenceHeader
);
402 /*========================== PRIVATE ================================*/
406 /*!\brief prohibit default function (move to 'public' if needed) */
407 ScanParseSkel(const ScanParseSkel
&source
);
408 /*!\brief prohibit default function (move to 'public' if needed) */
409 void operator =(const ScanParseSkel
&source
);
411 std::string _tmpString1
, _tmpString2
, _tmpString3
;
412 Real32 _tmpFloat1
, _tmpFloat2
, _tmpFloat3
, _tmpFloat4
;
413 BitVector _tmpBitVector1
;
419 void beginImage(Int32 width
, Int32 height
, Int32 components
);
421 void addImagePixel(Int32 pixel
);
426 ImageUnrecPtr _image
;
427 UInt8
*_imageDataPtr
;
432 //---------------------------------------------------------------------------
434 //---------------------------------------------------------------------------
438 #endif /* _OSGSCANPARSESKEL_H_ */