From 66e3fd29c73f442bffbd5358b748bd36b67a0456 Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 1 Jul 2015 14:03:50 +0300 Subject: [PATCH] Allow to use one stream object for several documents. --- src/CDM/CDM_MetaData.cxx | 10 ++++++---- src/Storage/Storage_IStream.cxx | 4 +--- src/Storage/Storage_OStream.cxx | 15 ++++----------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/CDM/CDM_MetaData.cxx b/src/CDM/CDM_MetaData.cxx index ad89a915aa..ca848d6ae1 100644 --- a/src/CDM/CDM_MetaData.cxx +++ b/src/CDM/CDM_MetaData.cxx @@ -73,9 +73,10 @@ Handle(CDM_MetaData) CDM_MetaData::LookUp(const Handle(Storage_IODevice)& aDevic if ( !aDevice.IsNull() ) aSig = aDevice->Signature(); - if( !getLookUpTable().IsBound(aSig) ) { + if ( aSig.IsEmpty() || !getLookUpTable().IsBound(aSig) ) { theMetaData = new CDM_MetaData(aDevice, ReadOnly); - getLookUpTable().Bind(aSig, theMetaData); + if ( !aSig.IsEmpty() ) + getLookUpTable().Bind(aSig, theMetaData); } else theMetaData = getLookUpTable()(aSig); @@ -89,9 +90,10 @@ Handle(CDM_MetaData) CDM_MetaData::LookUp(const Handle(Storage_IODevice)& aDevic if ( !aDevice.IsNull() ) aSig = aDevice->Signature(); - if( !getLookUpTable().IsBound(aSig) ) { + if ( aSig.IsEmpty() || !getLookUpTable().IsBound(aSig) ) { theMetaData = new CDM_MetaData(aDevice, aVersion, ReadOnly); - getLookUpTable().Bind(aSig, theMetaData); + if ( !aSig.IsEmpty() ) + getLookUpTable().Bind(aSig, theMetaData); } else theMetaData = getLookUpTable()(aSig); diff --git a/src/Storage/Storage_IStream.cxx b/src/Storage/Storage_IStream.cxx index d3db5caa22..62b4594969 100644 --- a/src/Storage/Storage_IStream.cxx +++ b/src/Storage/Storage_IStream.cxx @@ -177,9 +177,7 @@ Standard_Size Storage_IStream::Write (const Standard_Address /*theBuffer*/, cons //======================================================================= TCollection_AsciiString Storage_IStream::Signature() const { - Standard_Character buf[256]; - sprintf( buf, "%lx", (unsigned long)myStream ); - return TCollection_AsciiString( buf ); + return TCollection_AsciiString(); } //======================================================================= diff --git a/src/Storage/Storage_OStream.cxx b/src/Storage/Storage_OStream.cxx index 193ef8f754..62236cf47d 100644 --- a/src/Storage/Storage_OStream.cxx +++ b/src/Storage/Storage_OStream.cxx @@ -167,14 +167,9 @@ Standard_Size Storage_OStream::Read( const Standard_Address /*theBuffer*/, const //purpose : //======================================================================= Standard_Size Storage_OStream::Write (const Standard_Address theBuffer, const Standard_Size theSize) -{ - Storage_Position aPosBefore = Tell(); - - myStream->write ((char*)theBuffer, theSize); - - Storage_Position aPosAfter = Tell(); - - return aPosAfter - aPosBefore; +{ + myStream->write((char*)theBuffer, theSize); + return theSize; } //======================================================================= @@ -183,9 +178,7 @@ Standard_Size Storage_OStream::Write (const Standard_Address theBuffer, const St //======================================================================= TCollection_AsciiString Storage_OStream::Signature() const { - Standard_Character buf[256]; - sprintf( buf, "%lx", (unsigned long)myStream ); - return TCollection_AsciiString( buf ); + return TCollection_AsciiString(); } //======================================================================= -- 2.39.5