Added s/getByteSwap to teh InputStreamOperator base class and use of this method in the InputStream::start(InputStreamOperator*) method to ensure the bytes are swapped consistently.

This commit is contained in:
Robert Osfield
2012-02-24 21:07:02 +00:00
parent c3fb8dc714
commit e8ac276451
5 changed files with 52 additions and 16 deletions

View File

@@ -140,6 +140,9 @@ public:
osg::Object* readObject( osg::Object* existingObj=0 );
osg::Object* readObjectFields( const std::string& className, unsigned int id, osg::Object* existingObj=0);
void setByteSwap(int byteSwap) { _byteSwap = byteSwap; }
int getByteSwap() const { return _byteSwap; }
/// set an input iterator, used directly when not using InputStream with a traditional file releated stream.
void setInputIterator( InputIterator* ii ) { _in = ii; }

View File

@@ -69,7 +69,7 @@ protected:
class OSGDB_EXPORT InputIterator : public osg::Referenced
{
public:
InputIterator() : _in(0), _inputStream(0), _failed(false) {}
InputIterator() : _in(0), _inputStream(0), _byteSwap(0), _failed(false) {}
virtual ~InputIterator() {}
void setStream( std::istream* istream ) { _in = istream; }
@@ -79,7 +79,10 @@ public:
void setInputStream( InputStream* inputStream) { _inputStream = inputStream; }
InputStream* getInputStream() { return _inputStream; }
const InputStream* getInputStream() const { return _inputStream; }
void setByteSwap(int byteSwap) { _byteSwap = byteSwap; }
int getByteSwap() const { return _byteSwap; }
void checkStream() const { if (_in->rdstate()&_in->failbit) _failed = true; }
bool isFailed() const { return _failed; }
@@ -115,7 +118,8 @@ public:
protected:
std::istream* _in;
osgDB::InputStream* _inputStream;
mutable bool _failed;
int _byteSwap;
mutable bool _failed;
};
}