fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / ScanParseSkel / OSGScanParseSkel.h
blob02015b129f5b33fb9dba92bb0b395a257e1d6f60
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSCANPARSESKEL_H_
40 #define _OSGSCANPARSESKEL_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
46 #include "OSGSystemDef.h"
47 #include "OSGBaseTypes.h"
48 #include "OSGScanParseSkelParser.hpp"
49 #include "OSGImage.h"
51 // We have to prevent double inclusion of the scanner header file
52 #ifndef TOK_HEADER
53 #include "OSGScanParseSkelParser.hpp"
54 #endif
56 #include <string>
58 #ifdef OSG_FLEX_USE_IOSTREAM_INPUT
59 #include <iosfwd>
60 #endif
62 #ifdef OSG_USE_OSG2_NAMESPACE
63 # define OSGScanParseLexer OSG2ScanParseLexer
64 # define OSGScanParseSkel_parse OSG2ScanParseSkel_parse
65 #endif
67 class OSGScanParseLexer;
68 int OSGScanParseSkel_parse(void*);
70 OSG_BEGIN_NAMESPACE
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 =================================*/
83 public:
85 enum BuildInFieldType
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
152 enum
154 LastOption = 0x0001
157 /*---------------------------------------------------------------------*/
158 /*! \name Constructors */
159 /*! \{ */
161 ScanParseSkel(void);
163 /*! \} */
164 /*---------------------------------------------------------------------*/
165 /*! \name Destructor */
166 /*! \{ */
168 virtual ~ScanParseSkel(void);
170 /*! \} */
171 /*---------------------------------------------------------------------*/
172 /*! \name Scan */
173 /*! \{ */
175 #ifdef OSG_FLEX_USE_IOSTREAM_INPUT
176 void scanStream ( std::istream &is );
177 #endif
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);
187 /*! \} */
188 /*---------------------------------------------------------------------*/
189 /*! \name Prototypes */
190 /*! \{ */
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);
245 /*! \} */
246 /*---------------------------------------------------------------------*/
247 /*! \name Fields */
248 /*! \{ */
250 virtual void beginField(const Char8 *szFieldname,
251 const UInt32 uiFieldTypeId);
253 virtual void endField (void);
255 /*! \} */
256 /*---------------------------------------------------------------------*/
257 /*! \name Nodes */
258 /*! \{ */
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);
271 /*! \} */
272 /*---------------------------------------------------------------------*/
273 /*! \name Misc */
274 /*! \{ */
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 );
359 /*! \} */
360 /*---------------------------------------------------------------------*/
361 /*! \name Type Information */
362 /*! \{ */
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);
373 /*! \} */
374 /*---------------------------------------------------------------------*/
375 /*! \name Options */
376 /*! \{ */
378 void addOptions(UInt32 options);
379 void subOptions(UInt32 options);
380 UInt32 getOptions(void ) const;
382 /*! \} */
383 /*========================= PROTECTED ===============================*/
385 protected:
387 /*---------------------------------------------------------------------*/
388 /*! \name Member */
389 /*! \{ */
391 bool _bMapTypeIds;
392 Char8 *_szReferenceHeader;
393 OSGScanParseLexer *_pLexer;
395 void reset ( void);
397 void setMapTypeIds ( bool bVal);
399 void setReferenceHeader(const Char8 *szReferenceHeader);
401 /*! \} */
402 /*========================== PRIVATE ================================*/
404 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;
415 void beginValue();
417 void appendValue();
419 void beginImage(Int32 width, Int32 height, Int32 components);
421 void addImagePixel(Int32 pixel);
423 void endImage();
426 ImageUnrecPtr _image;
427 UInt8 *_imageDataPtr;
429 UInt32 _options;
432 //---------------------------------------------------------------------------
433 // Exported Types
434 //---------------------------------------------------------------------------
436 OSG_END_NAMESPACE
438 #endif /* _OSGSCANPARSESKEL_H_ */