From 9f3533632a34e765127881fdedf38fb38e9f64b5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 19 Jun 2017 12:04:03 +0100 Subject: [PATCH] Added ability for OSG serializers to get the file version number when writing out via the OutputStream object --- include/osgDB/StreamOperator | 8 +++++++- src/osgDB/OutputStream.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/osgDB/StreamOperator b/include/osgDB/StreamOperator index e317cae09..b50ebb43a 100644 --- a/include/osgDB/StreamOperator +++ b/include/osgDB/StreamOperator @@ -12,17 +12,22 @@ namespace osgDB // forward declare class InputStream; +class OutputStream; class OSGDB_EXPORT OutputIterator : public osg::Referenced { public: - OutputIterator() : _out(0), _supportBinaryBrackets(false) {} + OutputIterator() : _out(0), _outputStream(0), _supportBinaryBrackets(false) {} virtual ~OutputIterator() {} void setStream( std::ostream* ostream ) { _out = ostream; } std::ostream* getStream() { return _out; } const std::ostream* getStream() const { return _out; } + void setOutputStream( OutputStream* outputStream) { _outputStream = outputStream; } + OutputStream* getOutputStream() { return _outputStream; } + const OutputStream* getOutputStream() const { return _outputStream; } + void setSupportBinaryBrackets( bool b ) { _supportBinaryBrackets = b; } bool getSupportBinaryBrackets() const { return _supportBinaryBrackets; } @@ -69,6 +74,7 @@ protected: } std::ostream* _out; + osgDB::OutputStream* _outputStream; bool _supportBinaryBrackets; }; diff --git a/src/osgDB/OutputStream.cpp b/src/osgDB/OutputStream.cpp index 9849bfb2d..a21b74fa2 100644 --- a/src/osgDB/OutputStream.cpp +++ b/src/osgDB/OutputStream.cpp @@ -706,6 +706,8 @@ void OutputStream::start( OutputIterator* outIterator, OutputStream::WriteType t throwException( "OutputStream: Null stream specified." ); if ( getException() ) return; + _out->setOutputStream(this); + if ( isBinary() ) { *this << (unsigned int)type << (unsigned int)OPENSCENEGRAPH_SOVERSION;