2005-04-15 05:41:28 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2001-10-04 23:12:57 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
#ifndef OSGDB_FIELDREADERITERATOR
|
|
|
|
#define OSGDB_FIELDREADERITERATOR 1
|
|
|
|
|
2004-05-20 18:15:48 +08:00
|
|
|
#include <osg/Vec2f>
|
|
|
|
#include <osg/Vec2f>
|
|
|
|
#include <osg/Vec4f>
|
2004-05-20 20:57:06 +08:00
|
|
|
#include <osg/Vec2d>
|
|
|
|
#include <osg/Vec2d>
|
|
|
|
#include <osg/Vec4d>
|
2003-01-08 22:32:13 +08:00
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
#include <osgDB/Field>
|
|
|
|
#include <osgDB/FieldReader>
|
|
|
|
|
|
|
|
namespace osgDB {
|
|
|
|
|
|
|
|
|
|
|
|
class OSGDB_EXPORT FieldReaderIterator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MINIMUM_FIELD_READER_QUEUE_SIZE = 10
|
|
|
|
};
|
|
|
|
|
|
|
|
FieldReaderIterator();
|
|
|
|
FieldReaderIterator(const FieldReaderIterator& ic);
|
|
|
|
virtual ~FieldReaderIterator();
|
|
|
|
|
2002-02-23 01:12:10 +08:00
|
|
|
FieldReaderIterator& operator = (const FieldReaderIterator& ic);
|
2001-09-20 05:08:56 +08:00
|
|
|
|
2001-12-15 07:18:28 +08:00
|
|
|
void attach(std::istream* input);
|
2001-09-20 05:08:56 +08:00
|
|
|
void detach();
|
|
|
|
|
|
|
|
virtual bool eof() const;
|
|
|
|
|
|
|
|
FieldReader& getFieldReader() { return _reader; }
|
|
|
|
|
|
|
|
void insert(int pos,Field* field);
|
|
|
|
void insert(int pos,const char* str);
|
|
|
|
|
|
|
|
Field& operator [] (int pos);
|
|
|
|
Field& field (int pos);
|
|
|
|
|
|
|
|
FieldReaderIterator& operator ++ ();
|
|
|
|
FieldReaderIterator& operator += (int no);
|
|
|
|
|
2001-09-28 20:36:40 +08:00
|
|
|
/** increments the iterator of the next simple field or
|
|
|
|
* whole block if the current field[0] is an open bracket */
|
2001-09-20 05:08:56 +08:00
|
|
|
void advanceOverCurrentFieldOrBlock();
|
|
|
|
void advanceToEndOfCurrentBlock();
|
|
|
|
void advanceToEndOfBlock(int noNestBrackets);
|
|
|
|
|
|
|
|
bool matchSequence(const char* str);
|
2003-01-08 22:32:13 +08:00
|
|
|
|
|
|
|
bool readSequence(const char* keyword,std::string& value);
|
|
|
|
bool readSequence(const char* keyword,unsigned int& value);
|
|
|
|
bool readSequence(const char* keyword,int& value);
|
|
|
|
bool readSequence(const char* keyword,float& value);
|
2004-05-20 18:15:48 +08:00
|
|
|
bool readSequence(const char* keyword,osg::Vec2f& value);
|
|
|
|
bool readSequence(const char* keyword,osg::Vec3f& value);
|
|
|
|
bool readSequence(const char* keyword,osg::Vec4f& value);
|
2004-05-20 20:57:06 +08:00
|
|
|
bool readSequence(const char* keyword,osg::Vec2d& value);
|
|
|
|
bool readSequence(const char* keyword,osg::Vec3d& value);
|
|
|
|
bool readSequence(const char* keyword,osg::Vec4d& value);
|
2003-01-08 22:32:13 +08:00
|
|
|
|
|
|
|
bool readSequence(std::string& value);
|
|
|
|
bool readSequence(unsigned int& value);
|
|
|
|
bool readSequence(int& value);
|
|
|
|
bool readSequence(float& value);
|
2004-05-20 18:15:48 +08:00
|
|
|
bool readSequence(osg::Vec2f& value);
|
|
|
|
bool readSequence(osg::Vec3f& value);
|
|
|
|
bool readSequence(osg::Vec4f& value);
|
2004-05-20 20:57:06 +08:00
|
|
|
bool readSequence(osg::Vec2d& value);
|
|
|
|
bool readSequence(osg::Vec3d& value);
|
|
|
|
bool readSequence(osg::Vec4d& value);
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void _init();
|
|
|
|
void _free();
|
|
|
|
void _copy(const FieldReaderIterator& ic);
|
|
|
|
|
|
|
|
FieldReader _reader;
|
|
|
|
|
|
|
|
Field _blank;
|
|
|
|
|
|
|
|
Field* _previousField;
|
|
|
|
|
|
|
|
Field** _fieldQueue;
|
|
|
|
int _fieldQueueSize;
|
|
|
|
int _fieldQueueCapacity;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
#endif // __OSGDB_FIELD_READER_QUEUE_H
|