mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0026229: Add the possibility in OCAF to open/save a document from/to a stream object
TDocStd_Application class extended to open/save a document of XmlOcaf and BinOcaf format from/to standard SEEKABLE stream object which should support SEEK functionality. Open and SaveAs DRAW commands got new additional argument "-stream" to turn on using of stream functionality. The main changes for BinOcaf format applied in: FSD_BinaryFile class (static method using standard stream added) BinLDrivers_DocumentRetrievalDriver and BinLDrivers_DocumentStorageDriver classes use standard stream object as an argument The main changes for XmlOcaf format applied in: LDOMParser and LDOM_XmlWriter classes use standard stream object as an argument Unused class FSD_Archive and its siblings removed from MFC samples.
This commit is contained in:
@@ -383,6 +383,67 @@ Handle(PCDM_Reader) CDF_Application::Reader (const TCollection_ExtendedString& a
|
||||
return ReaderFromFormat (theFormat);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(CDM_Document) CDF_Application::Read (Standard_IStream& theIStream)
|
||||
{
|
||||
Handle(CDM_Document) aDoc;
|
||||
Handle(Storage_Data) dData;
|
||||
|
||||
TCollection_ExtendedString aFormat;
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
|
||||
aFormat = PCDM_ReadWriter::FileFormat (theIStream, dData);
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
myRetrievableStatus = PCDM_RS_FormatFailure;
|
||||
|
||||
Standard_SStream aMsg;
|
||||
aMsg << Standard_Failure::Caught() << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
|
||||
if (aFormat.IsEmpty())
|
||||
{
|
||||
myRetrievableStatus = PCDM_RS_FormatFailure;
|
||||
return aDoc;
|
||||
}
|
||||
|
||||
// 1. use a format name to detect plugin corresponding to the format to continue reading
|
||||
Handle(PCDM_Reader) aReader = ReaderFromFormat (aFormat);
|
||||
|
||||
// 2. create document with the detected reader
|
||||
aDoc = aReader->CreateDocument();
|
||||
|
||||
// 3. read the content of theIStream to aDoc
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
|
||||
aReader->Read (theIStream, dData, aDoc, this);
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
myRetrievableStatus = aReader->GetStatus();
|
||||
if (myRetrievableStatus > PCDM_RS_AlreadyRetrieved)
|
||||
{
|
||||
Standard_SStream aMsg;
|
||||
aMsg << Standard_Failure::Caught() << endl;
|
||||
Standard_Failure::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
myRetrievableStatus = aReader->GetStatus();
|
||||
|
||||
return aDoc;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindReaderFromFormat
|
||||
//purpose :
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#include <CDF_TypeOfActivation.hxx>
|
||||
#include <Standard_ExtString.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
|
||||
class Standard_NoSuchObject;
|
||||
class CDF_Session;
|
||||
class Standard_GUID;
|
||||
@@ -119,7 +121,11 @@ public:
|
||||
Standard_EXPORT Standard_Boolean FindReader (const TCollection_ExtendedString& aFileName);
|
||||
|
||||
Standard_EXPORT Handle(PCDM_Reader) Reader (const TCollection_ExtendedString& aFileName);
|
||||
|
||||
|
||||
//! Reads aDoc from standard SEEKABLE stream theIStream,
|
||||
//! the stream should support SEEK fuctionality
|
||||
Standard_EXPORT Handle(CDM_Document) Read (Standard_IStream& theIStream);
|
||||
|
||||
Standard_EXPORT Standard_Boolean FindReaderFromFormat (const TCollection_ExtendedString& aFormat);
|
||||
|
||||
Standard_EXPORT Handle(PCDM_Reader) ReaderFromFormat (const TCollection_ExtendedString& aFormat);
|
||||
|
Reference in New Issue
Block a user