1
0
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:
ibs
2015-11-27 13:03:25 +03:00
committed by bugmaster
parent 77dbd1f155
commit 4ff92abe44
72 changed files with 2011 additions and 2462 deletions

View File

@@ -17,10 +17,15 @@
#include <OSD.hxx>
#include <OSD_OpenFile.hxx>
#include <Storage_BaseDriver.hxx>
#include <Storage_HArrayOfCallBack.hxx>
#include <Storage_HeaderData.hxx>
#include <Storage_InternalData.hxx>
#include <Storage_RootData.hxx>
#include <Storage_StreamExtCharParityError.hxx>
#include <Storage_StreamFormatError.hxx>
#include <Storage_StreamTypeMismatchError.hxx>
#include <Storage_StreamWriteError.hxx>
#include <Storage_TypeData.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_Assert.hxx>
@@ -246,6 +251,32 @@ Storage_BaseDriver& FSD_BinaryFile::PutInteger(const Standard_Integer aValue)
return *this;
}
//=======================================================================
//function : PutInteger
//purpose :
//=======================================================================
Standard_Integer FSD_BinaryFile::PutInteger (Standard_OStream& theOStream,
const Standard_Integer theValue,
const Standard_Boolean theOnlyCount)
{
#if OCCT_BINARY_FILE_DO_INVERSE
Standard_Integer t = InverseInt (theValue);
#else
Standard_Integer t = theValue;
#endif
if (!theOnlyCount)
{
theOStream.write ((char*)&t, sizeof(Standard_Integer));
if (theOStream.fail())
{
Storage_StreamWriteError::Raise();
}
}
return sizeof(Standard_Integer);
}
//=======================================================================
//function : PutBoolean
//purpose :
@@ -312,6 +343,24 @@ Storage_BaseDriver& FSD_BinaryFile::GetReference(Standard_Integer& aValue)
return *this;
}
//=======================================================================
//function : GetReference
//purpose : ----------------- PUBLIC : GET
//=======================================================================
void FSD_BinaryFile::GetReference(Standard_IStream& theIStream, Standard_Integer& aValue)
{
theIStream.read ((char*)&aValue, sizeof(Standard_Integer));
if (theIStream.gcount() != sizeof(Standard_Integer))
{
Storage_StreamTypeMismatchError::Raise();
}
#if OCCT_BINARY_FILE_DO_INVERSE
aValue = InverseInt (aValue);
#endif
}
//=======================================================================
//function : GetCharacter
//purpose :
@@ -354,6 +403,25 @@ Storage_BaseDriver& FSD_BinaryFile::GetInteger(Standard_Integer& aValue)
return *this;
}
//=======================================================================
//function : GetInteger
//purpose :
//=======================================================================
void FSD_BinaryFile::GetInteger (Standard_IStream& theIStream, Standard_Integer& theValue)
{
theIStream.read ((char*)&theValue, sizeof(Standard_Integer));
if (theIStream.gcount() != sizeof(Standard_Integer))
{
Storage_StreamTypeMismatchError::Raise();
}
#if OCCT_BINARY_FILE_DO_INVERSE
theValue = InverseInt (theValue);
#endif
}
//=======================================================================
//function : GetBoolean
//purpose :
@@ -475,6 +543,43 @@ void FSD_BinaryFile::WriteInfo(const Standard_Integer nbObj,
}
}
//=======================================================================
//function : WriteInfo
//purpose :
//=======================================================================
Standard_Integer FSD_BinaryFile::WriteInfo (Standard_OStream& theOStream,
const Standard_Integer theObjNb,
const TCollection_AsciiString& theStoreVer,
const TCollection_AsciiString& theCreationDate,
const TCollection_AsciiString& theSchemaName,
const TCollection_AsciiString& theSchemaVersion,
const TCollection_ExtendedString& theAppName,
const TCollection_AsciiString& theAppVer,
const TCollection_ExtendedString& theDataType,
const TColStd_SequenceOfAsciiString& theUserInfo,
const Standard_Boolean theOnlyCount)
{
Standard_Integer anInfoSize = 0;
anInfoSize += PutInteger (theOStream, theObjNb, theOnlyCount);
anInfoSize += WriteString(theOStream, theStoreVer, theOnlyCount);
anInfoSize += WriteString(theOStream, theCreationDate, theOnlyCount);
anInfoSize += WriteString(theOStream, theSchemaName, theOnlyCount);
anInfoSize += WriteString(theOStream, theSchemaVersion, theOnlyCount);
anInfoSize += WriteExtendedString(theOStream, theAppName, theOnlyCount);
anInfoSize += WriteString(theOStream, theAppVer, theOnlyCount);
anInfoSize += WriteExtendedString(theOStream, theDataType, theOnlyCount);
Standard_Integer i = theUserInfo.Length();
anInfoSize += PutInteger(theOStream, i, theOnlyCount);
for (i = 1; i <= theUserInfo.Length(); i++) {
anInfoSize += WriteString (theOStream, theUserInfo.Value(i), theOnlyCount);
}
return anInfoSize;
}
//=======================================================================
//function : EndWriteInfoSection
//purpose : read
@@ -487,6 +592,17 @@ Storage_Error FSD_BinaryFile::EndWriteInfoSection()
return Storage_VSOk;
}
//=======================================================================
//function : EndWriteInfoSection
//purpose : read
//=======================================================================
Storage_Error FSD_BinaryFile::EndWriteInfoSection(Standard_OStream& theOStream)
{
myHeader.einfo = (Standard_Integer)theOStream.tellp();
return Storage_VSOk;
}
//=======================================================================
//function : BeginReadInfoSection
//purpose :
@@ -545,6 +661,118 @@ void FSD_BinaryFile::ReadInfo(Standard_Integer& nbObj,
}
}
//=======================================================================
//function : ReadInfo
//purpose :
//=======================================================================
void FSD_BinaryFile::ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData)
{
FSD_FileHeader aHeaderPos;
ReadHeader(theIStream, aHeaderPos);
if (theData.IsNull())
{
theData = new Storage_Data();
}
Handle(Storage_InternalData) iData = theData->InternalData();
Handle(Storage_TypeData) tData = theData->TypeData();
Handle(Storage_RootData) rData = theData->RootData();
Handle(Storage_HeaderData) hData = theData->HeaderData();
ReadHeaderData (theIStream, hData);
Handle(Storage_HArrayOfCallBack) theCallBack;
while (theIStream.good() && !theIStream.eof())
{
Standard_Integer aPos = (Standard_Integer)theIStream.tellg();
if (aPos >= aHeaderPos.edata)
{
break;
}
else if (aPos == aHeaderPos.bcomment)
{
TColStd_SequenceOfExtendedString mComment;
ReadComment (theIStream, mComment);
for (Standard_Integer i = 1; i <= mComment.Length(); i++)
{
hData->AddToComments (mComment.Value(i));
}
iData->ReadArray() = new Storage_HPArray(1, theData->NumberOfObjects());
}
else if (aPos == aHeaderPos.btype)
{
Standard_Integer aTypeSectionSize = TypeSectionSize (theIStream);
theCallBack = new Storage_HArrayOfCallBack (1, aTypeSectionSize);
TCollection_AsciiString aTypeName;
Standard_Integer aTypeNum;
for (Standard_Integer i = 1; i <= aTypeSectionSize; i++)
{
ReadTypeInformations (theIStream, aTypeNum, aTypeName);
tData->AddType (aTypeName,aTypeNum);
theCallBack->SetValue (aTypeNum, NULL);
}
}
else if (aPos == aHeaderPos.broot)
{
Standard_Integer aRootSectionSize = RootSectionSize(theIStream);
Standard_Integer aRef;
TCollection_AsciiString aRootName, aTypeName;
Handle(Storage_Root) aRoot;
Handle(Standard_Persistent) aPer;
for (Standard_Integer i = 1; i <= aRootSectionSize; i++)
{
ReadRoot (theIStream, aRootName, aRef, aTypeName);
aRoot = new Storage_Root(aRootName, aPer);
aRoot->SetReference(aRef);
aRoot->SetType(aTypeName);
rData->AddRoot(aRoot);
}
}
else if (aPos == aHeaderPos.bref)
{
Standard_Integer aRefSectionSize = RefSectionSize (theIStream);
Standard_Integer aTypeNum, aRef = 0;
for (Standard_Integer i = 1; i <= aRefSectionSize; i++)
{
ReadReferenceType (theIStream, aRef, aTypeNum);
iData->ReadArray()->ChangeValue(aRef) = theCallBack->Value(aTypeNum)->New();
if (!iData->ReadArray()->ChangeValue(aRef).IsNull())
{
iData->ReadArray()->ChangeValue(aRef)->TypeNum() = aTypeNum;
}
}
}
else if (aPos == aHeaderPos.bdata)
{
//
}
}
Handle(Storage_HSeqOfRoot) aRoots = rData->Roots();
for(Standard_Integer i = 1; i <= theData->NumberOfRoots(); i++)
{
const Handle(Storage_Root)& aCurRoot = aRoots->Value(i);
rData->UpdateRoot (aCurRoot->Name(), iData->ReadArray()->Value (aCurRoot->Reference()));
}
iData->Clear();
}
//=======================================================================
//function : EndReadInfoSection
//purpose : COMMENTS SECTION
@@ -568,6 +796,16 @@ Storage_Error FSD_BinaryFile::BeginWriteCommentSection()
return Storage_VSOk;
}
//=======================================================================
//function : BeginWriteCommentSection
//purpose :
//=======================================================================
Storage_Error FSD_BinaryFile::BeginWriteCommentSection(Standard_OStream& theOStream)
{
myHeader.bcomment = (Standard_Integer)theOStream.tellp();
return Storage_VSOk;
}
//=======================================================================
//function : WriteComment
//purpose :
@@ -584,6 +822,26 @@ void FSD_BinaryFile::WriteComment(const TColStd_SequenceOfExtendedString& aCom)
}
}
//=======================================================================
//function : WriteComment
//purpose :
//=======================================================================
Standard_Integer FSD_BinaryFile::WriteComment (Standard_OStream& theOStream,
const TColStd_SequenceOfExtendedString& theComments,
const Standard_Boolean theOnlyCount)
{
Standard_Integer aCommentSize = 0;
Standard_Integer aSize = theComments.Length();
aCommentSize += PutInteger(theOStream, aSize, theOnlyCount);
for (Standard_Integer i = 1; i <= aSize; i++) {
aCommentSize += WriteExtendedString (theOStream, theComments.Value(i), theOnlyCount);
}
return aCommentSize;
}
//=======================================================================
//function : EndWriteCommentSection
//purpose : read
@@ -596,6 +854,17 @@ Storage_Error FSD_BinaryFile::EndWriteCommentSection()
return Storage_VSOk;
}
//=======================================================================
//function : EndWriteCommentSection
//purpose : read
//=======================================================================
Storage_Error FSD_BinaryFile::EndWriteCommentSection (Standard_OStream& theOStream)
{
myHeader.ecomment = (Standard_Integer)theOStream.tellp();
return Storage_VSOk;
}
//=======================================================================
//function : BeginReadCommentSection
//purpose : ---------------- COMMENTS : READ
@@ -624,6 +893,23 @@ void FSD_BinaryFile::ReadComment(TColStd_SequenceOfExtendedString& aCom)
}
}
//=======================================================================
//function : ReadComment
//purpose :
//=======================================================================
void FSD_BinaryFile::ReadComment (Standard_IStream& theIStream, TColStd_SequenceOfExtendedString& aCom)
{
TCollection_ExtendedString line;
Standard_Integer len,i;
GetInteger(theIStream, len);
for (i = 1; i <= len && theIStream.good(); i++)
{
ReadExtendedString(theIStream, line);
aCom.Append(line);
}
}
//=======================================================================
//function : EndReadCommentSection
//purpose :
@@ -705,6 +991,18 @@ Standard_Integer FSD_BinaryFile::TypeSectionSize()
return i;
}
//=======================================================================
//function : TypeSectionSize
//purpose :
//=======================================================================
Standard_Integer FSD_BinaryFile::TypeSectionSize(Standard_IStream& theIStream)
{
Standard_Integer i;
GetInteger(theIStream, i);
return i;
}
//=======================================================================
//function : ReadTypeInformations
//purpose :
@@ -716,6 +1014,16 @@ void FSD_BinaryFile::ReadTypeInformations(Standard_Integer& typeNum,TCollection_
ReadString(typeName);
}
//=======================================================================
//function : ReadTypeInformations
//purpose :
//=======================================================================
void FSD_BinaryFile::ReadTypeInformations(Standard_IStream& theIStream, Standard_Integer& typeNum,TCollection_AsciiString& typeName)
{
GetInteger(theIStream, typeNum);
ReadString(theIStream, typeName);
}
//=======================================================================
//function : EndReadTypeSection
//purpose : ROOT SECTION
@@ -798,6 +1106,18 @@ Standard_Integer FSD_BinaryFile::RootSectionSize()
return i;
}
//=======================================================================
//function : RootSectionSize
//purpose :
//=======================================================================
Standard_Integer FSD_BinaryFile::RootSectionSize (Standard_IStream& theIStream)
{
Standard_Integer i;
GetInteger(theIStream, i);
return i;
}
//=======================================================================
//function : ReadRoot
//purpose :
@@ -810,6 +1130,17 @@ void FSD_BinaryFile::ReadRoot(TCollection_AsciiString& rootName, Standard_Intege
ReadString(rootType);
}
//=======================================================================
//function : ReadRoot
//purpose :
//=======================================================================
void FSD_BinaryFile::ReadRoot (Standard_IStream& theIStream, TCollection_AsciiString& rootName, Standard_Integer& aRef,TCollection_AsciiString& rootType)
{
GetReference(theIStream, aRef);
ReadString(theIStream, rootName);
ReadString(theIStream, rootType);
}
//=======================================================================
//function : EndReadRootSection
//purpose : REF SECTION
@@ -891,6 +1222,18 @@ Standard_Integer FSD_BinaryFile::RefSectionSize()
return i;
}
//=======================================================================
//function : RefSectionSize
//purpose :
//=======================================================================
Standard_Integer FSD_BinaryFile::RefSectionSize (Standard_IStream& theIStream)
{
Standard_Integer i;
GetInteger(theIStream, i);
return i;
}
//=======================================================================
//function : ReadReferenceType
//purpose :
@@ -903,6 +1246,16 @@ void FSD_BinaryFile::ReadReferenceType(Standard_Integer& reference,
GetInteger(typeNum);
}
//=======================================================================
//function : ReadReferenceType
//purpose :
//=======================================================================
void FSD_BinaryFile::ReadReferenceType (Standard_IStream& theIStream, Standard_Integer& reference, Standard_Integer& typeNum)
{
GetReference (theIStream, reference);
GetInteger (theIStream, typeNum);
}
//=======================================================================
//function : EndReadRefSection
//purpose : DATA SECTION
@@ -1077,6 +1430,32 @@ void FSD_BinaryFile::WriteString(const TCollection_AsciiString& aString)
}
}
//=======================================================================
//function : WriteString
//purpose : write string at the current position.
//=======================================================================
Standard_Integer FSD_BinaryFile::WriteString (Standard_OStream& theOStream,
const TCollection_AsciiString& theString,
const Standard_Boolean theOnlyCount)
{
Standard_Integer aNumAndStrLen, anAsciiStrLen;
anAsciiStrLen = aNumAndStrLen = theString.Length();
aNumAndStrLen += PutInteger (theOStream, anAsciiStrLen, theOnlyCount);
if (anAsciiStrLen > 0 && !theOnlyCount)
{
theOStream.write (theString.ToCString(), theString.Length());
if (theOStream.fail())
{
Storage_StreamWriteError::Raise();
}
}
return aNumAndStrLen;
}
//=======================================================================
//function : ReadString
//purpose : read string from the current position.
@@ -1099,6 +1478,44 @@ void FSD_BinaryFile::ReadString(TCollection_AsciiString& aString)
}
}
//=======================================================================
//function : ReadString
//purpose : read string from the current position.
//=======================================================================
void FSD_BinaryFile::ReadString (Standard_IStream& theIStream, TCollection_AsciiString& aString)
{
Standard_Integer size = 0;
GetInteger(theIStream, size);
if (size > 0)
{
Standard_Character *c = (Standard_Character *)Standard::Allocate((size+1) * sizeof(Standard_Character));
if (!theIStream.good())
{
Storage_StreamReadError::Raise();
}
theIStream.read (c, size);
if (theIStream.gcount() != size)
{
Storage_StreamReadError::Raise();
}
c[size] = '\0';
aString = c;
Standard::Free(c);
}
else
{
aString.Clear();
}
}
//=======================================================================
//function : WriteExtendedString
//purpose : write string at the current position.
@@ -1132,6 +1549,49 @@ void FSD_BinaryFile::WriteExtendedString(const TCollection_ExtendedString& aStri
}
}
//=======================================================================
//function : WriteExtendedString
//purpose : write string at the current position.
//=======================================================================
Standard_Integer FSD_BinaryFile::WriteExtendedString (Standard_OStream& theOStream,
const TCollection_ExtendedString& theString,
const Standard_Boolean theOnlyCount)
{
Standard_Integer aNumAndStrLen, anExtStrLen;
anExtStrLen = theString.Length();
aNumAndStrLen = anExtStrLen * sizeof(Standard_ExtCharacter);
aNumAndStrLen += PutInteger (theOStream, anExtStrLen, theOnlyCount);
if (anExtStrLen > 0 && !theOnlyCount)
{
Standard_ExtString anExtStr;
#if OCCT_BINARY_FILE_DO_INVERSE
TCollection_ExtendedString aCopy = theString;
anExtStr = aCopy.ToExtString();
Standard_PExtCharacter pChar;
//
pChar = (Standard_PExtCharacter)anExtStr;
for (Standard_Integer i = 0; i < anExtStrLen; i++)
{
pChar[i] = InverseExtChar (pChar[i]);
}
#else
anExtStr = theString.ToExtString();
#endif
theOStream.write((char*)anExtStr, sizeof(Standard_ExtCharacter)*theString.Length());
if (theOStream.fail())
{
Storage_StreamWriteError::Raise();
}
}
return aNumAndStrLen;
}
//=======================================================================
//function : ReadExtendedString
//purpose : read string from the current position.
@@ -1160,6 +1620,49 @@ void FSD_BinaryFile::ReadExtendedString(TCollection_ExtendedString& aString)
}
}
//=======================================================================
//function : ReadExtendedString
//purpose : read string from the current position.
//=======================================================================
void FSD_BinaryFile::ReadExtendedString (Standard_IStream& theIStream, TCollection_ExtendedString& aString)
{
Standard_Integer size = 0;
GetInteger (theIStream, size);
if (size > 0)
{
Standard_ExtCharacter *c = (Standard_ExtCharacter *)Standard::Allocate((size+1) * sizeof(Standard_ExtCharacter));
if (!theIStream.good())
{
Storage_StreamReadError::Raise();
}
theIStream.read ((char *)c, size*sizeof(Standard_ExtCharacter));
if (theIStream.gcount() != size)
{
Storage_StreamReadError::Raise();
}
c[size] = '\0';
#if OCCT_BINARY_FILE_DO_INVERSE
for (Standard_Integer i=0; i < size; i++)
{
c[i] = InverseExtChar (c[i]);
}
#endif
aString = c;
Standard::Free(c);
}
else
{
aString.Clear();
}
}
//=======================================================================
//function : WriteHeader
//purpose :
@@ -1182,6 +1685,33 @@ void FSD_BinaryFile::WriteHeader()
PutInteger(myHeader.edata);
}
//=======================================================================
//function : WriteHeader
//purpose :
//=======================================================================
Standard_Integer FSD_BinaryFile::WriteHeader (Standard_OStream& theOStream,
const FSD_FileHeader& theHeader,
const Standard_Boolean theOnlyCount)
{
Standard_Integer aHeaderSize = 0;
aHeaderSize += PutInteger (theOStream, theHeader.testindian, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.binfo, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.einfo, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.bcomment, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.ecomment, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.btype, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.etype, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.broot, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.eroot, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.bref, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.eref, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.bdata, theOnlyCount);
aHeaderSize += PutInteger (theOStream, theHeader.edata, theOnlyCount);
return aHeaderSize;
}
//=======================================================================
//function : ReadHeader
//purpose :
@@ -1204,6 +1734,73 @@ void FSD_BinaryFile::ReadHeader()
GetInteger(myHeader.edata);
}
//=======================================================================
//function : ReadHeader
//purpose :
//=======================================================================
void FSD_BinaryFile::ReadHeader(Standard_IStream& theIStream, FSD_FileHeader& theFileHeader)
{
GetInteger (theIStream, theFileHeader.testindian);
GetInteger (theIStream, theFileHeader.binfo);
GetInteger (theIStream, theFileHeader.einfo);
GetInteger (theIStream, theFileHeader.bcomment);
GetInteger (theIStream, theFileHeader.ecomment);
GetInteger (theIStream, theFileHeader.btype);
GetInteger (theIStream, theFileHeader.etype);
GetInteger (theIStream, theFileHeader.broot);
GetInteger (theIStream, theFileHeader.eroot);
GetInteger (theIStream, theFileHeader.bref);
GetInteger (theIStream, theFileHeader.eref);
GetInteger (theIStream, theFileHeader.bdata);
GetInteger (theIStream, theFileHeader.edata);
}
//=======================================================================
//function : ReadHeaderData
//purpose :
//=======================================================================
void FSD_BinaryFile::ReadHeaderData( Standard_IStream& theIStream, const Handle(Storage_HeaderData)& theHeaderData )
{
// read info
TCollection_AsciiString uinfo,mStorageVersion,mDate,mSchemaName,mSchemaVersion,mApplicationVersion;
TCollection_ExtendedString mApplicationName,mDataType;
TColStd_SequenceOfAsciiString mUserInfo;
Standard_Integer mNBObj;
FSD_BinaryFile::GetInteger (theIStream, mNBObj);
FSD_BinaryFile::ReadString (theIStream, mStorageVersion);
FSD_BinaryFile::ReadString (theIStream, mDate);
FSD_BinaryFile::ReadString (theIStream, mSchemaName);
FSD_BinaryFile::ReadString (theIStream, mSchemaVersion);
FSD_BinaryFile::ReadExtendedString(theIStream, mApplicationName);
FSD_BinaryFile::ReadString (theIStream, mApplicationVersion);
FSD_BinaryFile::ReadExtendedString(theIStream, mDataType);
Standard_Integer len = 0;
TCollection_AsciiString line;
FSD_BinaryFile::GetInteger(theIStream, len);
for (Standard_Integer i = 1; i <= len && theIStream.good(); i++)
{
FSD_BinaryFile::ReadString (theIStream, line);
mUserInfo.Append(line);
}
theHeaderData->SetNumberOfObjects(mNBObj);
theHeaderData->SetStorageVersion(mStorageVersion);
theHeaderData->SetCreationDate(mDate);
theHeaderData->SetSchemaName(mSchemaName);
theHeaderData->SetSchemaVersion(mSchemaVersion);
theHeaderData->SetApplicationName(mApplicationName);
theHeaderData->SetApplicationVersion(mApplicationVersion);
theHeaderData->SetDataType(mDataType);
for (Standard_Integer i = 1; i <= mUserInfo.Length(); i++) {
theHeaderData->AddToUserInfo(mUserInfo.Value(i));
}
}
//=======================================================================
//function : Tell

View File

@@ -26,6 +26,7 @@
#include <Storage_BaseDriver.hxx>
#include <Storage_Error.hxx>
#include <Storage_OpenMode.hxx>
#include <Storage_Data.hxx>
#include <Standard_Boolean.hxx>
#include <Storage_Position.hxx>
#include <Standard_Integer.hxx>
@@ -44,6 +45,7 @@ class Storage_StreamExtCharParityError;
class TCollection_AsciiString;
class TCollection_ExtendedString;
class Storage_BaseDriver;
class Storage_HeaderData;
// Macro that tells if bytes must be reversed when read/write
@@ -78,26 +80,52 @@ public:
Standard_EXPORT static Storage_Error IsGoodFileType (const TCollection_AsciiString& aName);
Standard_EXPORT Storage_Error BeginWriteInfoSection();
Standard_EXPORT static Standard_Integer WriteInfo (Standard_OStream& theOStream,
const Standard_Integer nbObj,
const TCollection_AsciiString& dbVersion,
const TCollection_AsciiString& date,
const TCollection_AsciiString& schemaName,
const TCollection_AsciiString& schemaVersion,
const TCollection_ExtendedString& appName,
const TCollection_AsciiString& appVersion,
const TCollection_ExtendedString& objectType,
const TColStd_SequenceOfAsciiString& userInfo,
const Standard_Boolean theOnlyCount = Standard_False);
Standard_EXPORT void WriteInfo (const Standard_Integer nbObj, const TCollection_AsciiString& dbVersion, const TCollection_AsciiString& date, const TCollection_AsciiString& schemaName, const TCollection_AsciiString& schemaVersion, const TCollection_ExtendedString& appName, const TCollection_AsciiString& appVersion, const TCollection_ExtendedString& objectType, const TColStd_SequenceOfAsciiString& userInfo);
Standard_EXPORT Storage_Error EndWriteInfoSection();
Standard_EXPORT Storage_Error EndWriteInfoSection(Standard_OStream& theOStream);
Standard_EXPORT Storage_Error BeginReadInfoSection();
Standard_EXPORT void ReadInfo (Standard_Integer& nbObj, TCollection_AsciiString& dbVersion, TCollection_AsciiString& date, TCollection_AsciiString& schemaName, TCollection_AsciiString& schemaVersion, TCollection_ExtendedString& appName, TCollection_AsciiString& appVersion, TCollection_ExtendedString& objectType, TColStd_SequenceOfAsciiString& userInfo);
Standard_EXPORT void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData);
Standard_EXPORT Storage_Error EndReadInfoSection();
Standard_EXPORT Storage_Error BeginWriteCommentSection();
Standard_EXPORT Storage_Error BeginWriteCommentSection (Standard_OStream& theOStream);
Standard_EXPORT void WriteComment (const TColStd_SequenceOfExtendedString& userComments);
Standard_EXPORT static Standard_Integer WriteComment (Standard_OStream& theOStream,
const TColStd_SequenceOfExtendedString& theComments,
const Standard_Boolean theOnlyCount = Standard_False);
Standard_EXPORT Storage_Error EndWriteCommentSection();
Standard_EXPORT Storage_Error EndWriteCommentSection (Standard_OStream& theOStream);
Standard_EXPORT Storage_Error BeginReadCommentSection();
Standard_EXPORT void ReadComment (TColStd_SequenceOfExtendedString& userComments);
Standard_EXPORT static void ReadComment (Standard_IStream& theIStream, TColStd_SequenceOfExtendedString& userComments);
Standard_EXPORT Storage_Error EndReadCommentSection();
@@ -112,8 +140,12 @@ public:
Standard_EXPORT Storage_Error BeginReadTypeSection();
Standard_EXPORT Standard_Integer TypeSectionSize();
Standard_EXPORT static Standard_Integer TypeSectionSize(Standard_IStream& theIStream);
Standard_EXPORT void ReadTypeInformations (Standard_Integer& typeNum, TCollection_AsciiString& typeName);
Standard_EXPORT static void ReadTypeInformations (Standard_IStream& theIStream, Standard_Integer& typeNum, TCollection_AsciiString& typeName);
Standard_EXPORT Storage_Error EndReadTypeSection();
@@ -129,7 +161,11 @@ public:
Standard_EXPORT Standard_Integer RootSectionSize();
Standard_EXPORT static Standard_Integer RootSectionSize(Standard_IStream& theIStream);
Standard_EXPORT void ReadRoot (TCollection_AsciiString& rootName, Standard_Integer& aRef, TCollection_AsciiString& aType);
Standard_EXPORT static void ReadRoot (Standard_IStream& theIStream, TCollection_AsciiString& rootName, Standard_Integer& aRef, TCollection_AsciiString& aType);
Standard_EXPORT Storage_Error EndReadRootSection();
@@ -144,8 +180,12 @@ public:
Standard_EXPORT Storage_Error BeginReadRefSection();
Standard_EXPORT Standard_Integer RefSectionSize();
Standard_EXPORT static Standard_Integer RefSectionSize(Standard_IStream& theIStream);
Standard_EXPORT void ReadReferenceType (Standard_Integer& reference, Standard_Integer& typeNum);
Standard_EXPORT static void ReadReferenceType (Standard_IStream& theIStream, Standard_Integer& reference, Standard_Integer& typeNum);
Standard_EXPORT Storage_Error EndReadRefSection();
@@ -193,6 +233,10 @@ Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue)
return PutExtCharacter(aValue);
}
Standard_EXPORT static Standard_Integer PutInteger (Standard_OStream& theOStream,
const Standard_Integer aValue,
const Standard_Boolean theOnlyCount = Standard_False);
Standard_EXPORT Storage_BaseDriver& PutInteger (const Standard_Integer aValue);
Storage_BaseDriver& operator << (const Standard_Integer aValue)
{
@@ -224,6 +268,8 @@ Storage_BaseDriver& operator >> (Standard_Character& aValue)
{
return GetCharacter(aValue);
}
Standard_EXPORT static void GetReference (Standard_IStream& theIStream, Standard_Integer& aValue);
Standard_EXPORT Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue);
Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue)
@@ -236,6 +282,8 @@ Storage_BaseDriver& operator >> (Standard_Integer& aValue)
{
return GetInteger(aValue);
}
Standard_EXPORT static void GetInteger (Standard_IStream& theIStream, Standard_Integer& aValue);
Standard_EXPORT Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue);
Storage_BaseDriver& operator >> (Standard_Boolean& aValue)
@@ -288,6 +336,20 @@ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
///Inverse bytes in size value
Standard_EXPORT static Standard_Size InverseSize(const Standard_Size theValue);
Standard_EXPORT static void ReadHeader (Standard_IStream& theIStream, FSD_FileHeader& theFileHeader);
Standard_EXPORT static void ReadHeaderData (Standard_IStream& theIStream, const Handle(Storage_HeaderData)& theHeaderData);
Standard_EXPORT static void ReadString (Standard_IStream& theIStream, TCollection_AsciiString& buffer);
Standard_EXPORT static void ReadExtendedString (Standard_IStream& theIStream, TCollection_ExtendedString& buffer);
Standard_EXPORT static Standard_Integer WriteHeader (Standard_OStream& theOStream,
const FSD_FileHeader& theHeader,
const Standard_Boolean theOnlyCount = Standard_False);
Standard_EXPORT static Standard_CString MagicNumber();
protected:
@@ -299,12 +361,22 @@ protected:
//! write string at the current position.
Standard_EXPORT void WriteString (const TCollection_AsciiString& buffer);
//! write string at the current position.
Standard_EXPORT static Standard_Integer WriteString (Standard_OStream& theOStream,
const TCollection_AsciiString& theString,
const Standard_Boolean theOnlyCount = Standard_False);
//! read string from the current position.
Standard_EXPORT void ReadExtendedString (TCollection_ExtendedString& buffer);
//! write string at the current position.
Standard_EXPORT void WriteExtendedString (const TCollection_ExtendedString& buffer);
//! write string at the current position.
Standard_EXPORT static Standard_Integer WriteExtendedString (Standard_OStream& theOStream,
const TCollection_ExtendedString& theString,
const Standard_Boolean theOnlyCount = Standard_False);
private:
@@ -312,7 +384,6 @@ private:
void ReadHeader();
static Standard_CString MagicNumber();
private:

View File

@@ -755,6 +755,16 @@ void FSD_CmpFile::ReadInfo(Standard_Integer& nbObj,
}
}
//=======================================================================
//function : ReadCompleteInfo
//purpose :
//
//=======================================================================
void FSD_CmpFile::ReadCompleteInfo( Standard_IStream& /*theIStream*/, Handle(Storage_Data)& /*theData*/)
{
}
//=======================================================================
//function : EndReadInfoSection
//purpose : COMMENTS SECTION

View File

@@ -75,6 +75,8 @@ public:
Standard_EXPORT void ReadInfo (Standard_Integer& nbObj, TCollection_AsciiString& dbVersion, TCollection_AsciiString& date, TCollection_AsciiString& schemaName, TCollection_AsciiString& schemaVersion, TCollection_ExtendedString& appName, TCollection_AsciiString& appVersion, TCollection_ExtendedString& objectType, TColStd_SequenceOfAsciiString& userInfo);
Standard_EXPORT void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData);
Standard_EXPORT Storage_Error EndReadInfoSection();
Standard_EXPORT Storage_Error BeginWriteCommentSection();
@@ -251,6 +253,7 @@ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
Destroy();
}
Standard_EXPORT static Standard_CString MagicNumber();
@@ -281,8 +284,6 @@ protected:
private:
static Standard_CString MagicNumber();
void RaiseError (const Handle(Standard_Type)& theFailure);
private:

View File

@@ -749,6 +749,16 @@ void FSD_File::ReadInfo(Standard_Integer& nbObj,
}
}
//=======================================================================
//function : ReadCompleteInfo
//purpose :
//
//=======================================================================
void FSD_File::ReadCompleteInfo( Standard_IStream& /*theIStream*/, Handle(Storage_Data)& /*theData*/)
{
}
//=======================================================================
//function : EndReadInfoSection
//purpose : COMMENTS SECTION

View File

@@ -86,6 +86,8 @@ public:
Standard_EXPORT Storage_Error BeginReadInfoSection();
Standard_EXPORT void ReadInfo (Standard_Integer& nbObj, TCollection_AsciiString& dbVersion, TCollection_AsciiString& date, TCollection_AsciiString& schemaName, TCollection_AsciiString& schemaVersion, TCollection_ExtendedString& appName, TCollection_AsciiString& appVersion, TCollection_ExtendedString& objectType, TColStd_SequenceOfAsciiString& userInfo);
Standard_EXPORT void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData);
Standard_EXPORT Storage_Error EndReadInfoSection();
@@ -269,6 +271,7 @@ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
Destroy();
}
Standard_EXPORT static Standard_CString MagicNumber();
@@ -299,9 +302,7 @@ protected:
private:
static Standard_CString MagicNumber();
private:
FSD_FStream myStream;
};