1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0026256: FSD_File and FSD_CmpFile are almost twins.

This commit is contained in:
szy 2017-09-13 16:43:32 +03:00 committed by bugmaster
parent bfd69b5f7b
commit 4621622641
5 changed files with 278 additions and 1418 deletions

File diff suppressed because it is too large Load Diff

View File

@ -17,241 +17,59 @@
#ifndef _FSD_CmpFile_HeaderFile #ifndef _FSD_CmpFile_HeaderFile
#define _FSD_CmpFile_HeaderFile #define _FSD_CmpFile_HeaderFile
#include <Standard.hxx> #include <FSD_File.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <FSD_FStream.hxx>
#include <Storage_BaseDriver.hxx> #include <Storage_BaseDriver.hxx>
#include <Storage_Error.hxx> #include <Storage_Error.hxx>
#include <Storage_OpenMode.hxx> #include <Storage_OpenMode.hxx>
#include <Standard_Boolean.hxx> #include <Standard_Boolean.hxx>
#include <Storage_Position.hxx>
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
#include <Standard_Character.hxx>
#include <Standard_ExtCharacter.hxx>
#include <Standard_Real.hxx>
#include <Standard_ShortReal.hxx>
#include <Standard_Size.hxx>
#include <Standard_CString.hxx> #include <Standard_CString.hxx>
#include <Standard_Type.hxx>
class Storage_StreamTypeMismatchError;
class Storage_StreamFormatError;
class Storage_StreamWriteError;
class Storage_StreamExtCharParityError;
class TCollection_AsciiString; class TCollection_AsciiString;
class TCollection_ExtendedString; class TCollection_ExtendedString;
class Storage_BaseDriver; class Storage_BaseDriver;
class FSD_CmpFile : public FSD_File
class FSD_CmpFile : public Storage_BaseDriver
{ {
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
Standard_EXPORT FSD_CmpFile(); Standard_EXPORT FSD_CmpFile();
Standard_EXPORT Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode); Standard_EXPORT Storage_Error Open(const TCollection_AsciiString& aName, const Storage_OpenMode aMode);
Standard_EXPORT Standard_Boolean IsEnd(); Standard_EXPORT static Storage_Error IsGoodFileType(const TCollection_AsciiString& aName);
//! return position in the file. Return -1 upon error.
Standard_EXPORT Storage_Position Tell();
Standard_EXPORT static Storage_Error IsGoodFileType (const TCollection_AsciiString& aName);
Standard_EXPORT Storage_Error BeginWriteInfoSection(); Standard_EXPORT Storage_Error BeginWriteInfoSection();
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 BeginReadInfoSection(); 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 WritePersistentObjectHeader(const Standard_Integer aRef, const Standard_Integer aType);
Standard_EXPORT void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData);
Standard_EXPORT Storage_Error EndReadInfoSection();
Standard_EXPORT Storage_Error BeginWriteCommentSection();
Standard_EXPORT void WriteComment (const TColStd_SequenceOfExtendedString& userComments);
Standard_EXPORT Storage_Error EndWriteCommentSection();
Standard_EXPORT Storage_Error BeginReadCommentSection();
Standard_EXPORT void ReadComment (TColStd_SequenceOfExtendedString& userComments);
Standard_EXPORT Storage_Error EndReadCommentSection();
Standard_EXPORT Storage_Error BeginWriteTypeSection();
Standard_EXPORT void SetTypeSectionSize (const Standard_Integer aSize);
Standard_EXPORT void WriteTypeInformations (const Standard_Integer typeNum, const TCollection_AsciiString& typeName);
Standard_EXPORT Storage_Error EndWriteTypeSection();
Standard_EXPORT Storage_Error BeginReadTypeSection();
Standard_EXPORT Standard_Integer TypeSectionSize();
Standard_EXPORT void ReadTypeInformations (Standard_Integer& typeNum, TCollection_AsciiString& typeName);
Standard_EXPORT Storage_Error EndReadTypeSection();
Standard_EXPORT Storage_Error BeginWriteRootSection();
Standard_EXPORT void SetRootSectionSize (const Standard_Integer aSize);
Standard_EXPORT void WriteRoot (const TCollection_AsciiString& rootName, const Standard_Integer aRef, const TCollection_AsciiString& aType);
Standard_EXPORT Storage_Error EndWriteRootSection();
Standard_EXPORT Storage_Error BeginReadRootSection();
Standard_EXPORT Standard_Integer RootSectionSize();
Standard_EXPORT void ReadRoot (TCollection_AsciiString& rootName, Standard_Integer& aRef, TCollection_AsciiString& aType);
Standard_EXPORT Storage_Error EndReadRootSection();
Standard_EXPORT Storage_Error BeginWriteRefSection();
Standard_EXPORT void SetRefSectionSize (const Standard_Integer aSize);
Standard_EXPORT void WriteReferenceType (const Standard_Integer reference, const Standard_Integer typeNum);
Standard_EXPORT Storage_Error EndWriteRefSection();
Standard_EXPORT Storage_Error BeginReadRefSection();
Standard_EXPORT Standard_Integer RefSectionSize();
Standard_EXPORT void ReadReferenceType (Standard_Integer& reference, Standard_Integer& typeNum);
Standard_EXPORT Storage_Error EndReadRefSection();
Standard_EXPORT Storage_Error BeginWriteDataSection();
Standard_EXPORT void WritePersistentObjectHeader (const Standard_Integer aRef, const Standard_Integer aType);
Standard_EXPORT void BeginWritePersistentObjectData(); Standard_EXPORT void BeginWritePersistentObjectData();
Standard_EXPORT void BeginWriteObjectData(); Standard_EXPORT void BeginWriteObjectData();
Standard_EXPORT void EndWriteObjectData(); Standard_EXPORT void EndWriteObjectData();
Standard_EXPORT void EndWritePersistentObjectData(); Standard_EXPORT void EndWritePersistentObjectData();
Standard_EXPORT Storage_Error EndWriteDataSection(); Standard_EXPORT void ReadPersistentObjectHeader(Standard_Integer& aRef, Standard_Integer& aType);
Standard_EXPORT Storage_Error BeginReadDataSection();
Standard_EXPORT void ReadPersistentObjectHeader (Standard_Integer& aRef, Standard_Integer& aType);
Standard_EXPORT void BeginReadPersistentObjectData(); Standard_EXPORT void BeginReadPersistentObjectData();
Standard_EXPORT void BeginReadObjectData(); Standard_EXPORT void BeginReadObjectData();
Standard_EXPORT void EndReadObjectData(); Standard_EXPORT void EndReadObjectData();
Standard_EXPORT void EndReadPersistentObjectData(); Standard_EXPORT void EndReadPersistentObjectData();
Standard_EXPORT Storage_Error EndReadDataSection();
Standard_EXPORT void SkipObject();
Standard_EXPORT Storage_BaseDriver& PutReference (const Standard_Integer aValue);
Standard_EXPORT Storage_BaseDriver& PutCharacter (const Standard_Character aValue);
Storage_BaseDriver& operator << (const Standard_Character aValue)
{
return PutCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutExtCharacter (const Standard_ExtCharacter aValue);
Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue)
{
return PutExtCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutInteger (const Standard_Integer aValue);
Storage_BaseDriver& operator << (const Standard_Integer aValue)
{
return PutInteger(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue);
Storage_BaseDriver& operator << (const Standard_Boolean aValue)
{
return PutBoolean(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutReal (const Standard_Real aValue);
Storage_BaseDriver& operator << (const Standard_Real aValue)
{
return PutReal(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue);
Storage_BaseDriver& operator << (const Standard_ShortReal aValue)
{
return PutShortReal(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetReference (Standard_Integer& aValue);
Standard_EXPORT Storage_BaseDriver& GetCharacter (Standard_Character& aValue);
Storage_BaseDriver& operator >> (Standard_Character& aValue)
{
return GetCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue);
Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue)
{
return GetExtCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetInteger (Standard_Integer& aValue);
Storage_BaseDriver& operator >> (Standard_Integer& aValue)
{
return GetInteger(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue);
Storage_BaseDriver& operator >> (Standard_Boolean& aValue)
{
return GetBoolean(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetReal (Standard_Real& aValue);
Storage_BaseDriver& operator >> (Standard_Real& aValue)
{
return GetReal(aValue);
}
Standard_EXPORT Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue);
Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
{
return GetShortReal(aValue);
}
Standard_EXPORT Storage_Error Close();
Standard_EXPORT void Destroy(); Standard_EXPORT void Destroy();
~FSD_CmpFile() ~FSD_CmpFile()
{ {
Destroy(); Destroy();
} }
Standard_EXPORT static Standard_CString MagicNumber(); Standard_EXPORT static Standard_CString MagicNumber();
@ -259,36 +77,19 @@ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
protected: protected:
//! read from the current position to the end of line. //! read from the current position to the end of line.
Standard_EXPORT void ReadLine (TCollection_AsciiString& buffer); Standard_EXPORT void ReadLine(TCollection_AsciiString& buffer);
//! read from the current position to the next white space or end of line.
Standard_EXPORT void ReadWord (TCollection_AsciiString& buffer);
//! read extended chars (unicode) from the current position to the end of line. //! read extended chars (unicode) from the current position to the end of line.
Standard_EXPORT void ReadExtendedLine (TCollection_ExtendedString& buffer); Standard_EXPORT void ReadExtendedLine(TCollection_ExtendedString& buffer);
//! write from the current position to the end of line. //! write from the current position to the end of line.
Standard_EXPORT void WriteExtendedLine (const TCollection_ExtendedString& buffer); Standard_EXPORT void WriteExtendedLine(const TCollection_ExtendedString& buffer);
//! read <rsize> character from the current position.
Standard_EXPORT void ReadChar (TCollection_AsciiString& buffer, const Standard_Size rsize);
//! read from the first none space character position to the end of line. //! read from the first none space character position to the end of line.
Standard_EXPORT void ReadString (TCollection_AsciiString& buffer); Standard_EXPORT void ReadString(TCollection_AsciiString& buffer);
Standard_EXPORT void FlushEndOfLine();
Standard_EXPORT Storage_Error FindTag (const Standard_CString aTag);
private:
void RaiseError (const Handle(Standard_Type)& theFailure);
private:
FSD_FStream myStream;
}; };
#endif // _FSD_CmpFile_HeaderFile #endif // _FSD_CmpFile_HeaderFile

View File

@ -28,7 +28,7 @@ const Standard_CString MAGICNUMBER = "FSDFILE";
const Standard_CString ENDOFNORMALEXTENDEDSECTION = "BEGIN_REF_SECTION"; const Standard_CString ENDOFNORMALEXTENDEDSECTION = "BEGIN_REF_SECTION";
const Standard_Integer SIZEOFNORMALEXTENDEDSECTION = 16; const Standard_Integer SIZEOFNORMALEXTENDEDSECTION = 16;
//#define USEOSDREAL 1 #define USEOSDREAL 1
//======================================================================= //=======================================================================
//function : FSD_File //function : FSD_File
@ -175,20 +175,6 @@ void FSD_File::FlushEndOfLine()
{ {
TCollection_AsciiString aDummy; TCollection_AsciiString aDummy;
ReadLine (aDummy); // flush is nothing more than to read till the line-break ReadLine (aDummy); // flush is nothing more than to read till the line-break
/* static char Buffer[8192];
char c;
Standard_Boolean IsEnd = Standard_False;
while (!IsEnd && !FSD_File::IsEnd()) {
Buffer[0] = '\0';
myStream.get(Buffer,8192,'\n');
if (myStream.get(c) && c != '\n') {
}
else {
IsEnd = Standard_True;
}
}*/
} }
//======================================================================= //=======================================================================
@ -609,7 +595,7 @@ Storage_BaseDriver& FSD_File::GetShortReal(Standard_ShortReal& aValue)
if (!(myStream >> realbuffer)) throw Storage_StreamTypeMismatchError(); if (!(myStream >> realbuffer)) throw Storage_StreamTypeMismatchError();
if (!OSD::CStringToReal(realbuffer,r)) throw Storage_StreamTypeMismatchError(); if (!OSD::CStringToReal(realbuffer,r)) throw Storage_StreamTypeMismatchError();
aValue = r; aValue = (Standard_ShortReal)r;
return *this; return *this;
#else #else

View File

@ -68,194 +68,195 @@ public:
//! The function returns Storage_VSOk if the file //! The function returns Storage_VSOk if the file
//! is opened correctly, or any other value of the //! is opened correctly, or any other value of the
//! Storage_Error enumeration which specifies the problem encountered. //! Storage_Error enumeration which specifies the problem encountered.
Standard_EXPORT Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode); Standard_EXPORT virtual Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode);
Standard_EXPORT Standard_Boolean IsEnd(); Standard_EXPORT virtual Standard_Boolean IsEnd();
//! return position in the file. Return -1 upon error. //! return position in the file. Return -1 upon error.
Standard_EXPORT Storage_Position Tell(); Standard_EXPORT virtual Storage_Position Tell();
Standard_EXPORT static Storage_Error IsGoodFileType (const TCollection_AsciiString& aName); Standard_EXPORT static Storage_Error IsGoodFileType (const TCollection_AsciiString& aName);
Standard_EXPORT Storage_Error BeginWriteInfoSection(); Standard_EXPORT virtual Storage_Error BeginWriteInfoSection();
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 virtual 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 virtual Storage_Error EndWriteInfoSection();
Standard_EXPORT Storage_Error BeginReadInfoSection(); Standard_EXPORT virtual 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 virtual 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 virtual void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData);
Standard_EXPORT Storage_Error EndReadInfoSection(); Standard_EXPORT virtual Storage_Error EndReadInfoSection();
Standard_EXPORT Storage_Error BeginWriteCommentSection(); Standard_EXPORT virtual Storage_Error BeginWriteCommentSection();
Standard_EXPORT void WriteComment (const TColStd_SequenceOfExtendedString& userComments); Standard_EXPORT virtual void WriteComment (const TColStd_SequenceOfExtendedString& userComments);
Standard_EXPORT Storage_Error EndWriteCommentSection(); Standard_EXPORT virtual Storage_Error EndWriteCommentSection();
Standard_EXPORT Storage_Error BeginReadCommentSection(); Standard_EXPORT virtual Storage_Error BeginReadCommentSection();
Standard_EXPORT void ReadComment (TColStd_SequenceOfExtendedString& userComments); Standard_EXPORT virtual void ReadComment (TColStd_SequenceOfExtendedString& userComments);
Standard_EXPORT Storage_Error EndReadCommentSection(); Standard_EXPORT virtual Storage_Error EndReadCommentSection();
Standard_EXPORT Storage_Error BeginWriteTypeSection(); Standard_EXPORT virtual Storage_Error BeginWriteTypeSection();
Standard_EXPORT void SetTypeSectionSize (const Standard_Integer aSize); Standard_EXPORT virtual void SetTypeSectionSize (const Standard_Integer aSize);
Standard_EXPORT void WriteTypeInformations (const Standard_Integer typeNum, const TCollection_AsciiString& typeName); Standard_EXPORT virtual void WriteTypeInformations (const Standard_Integer typeNum, const TCollection_AsciiString& typeName);
Standard_EXPORT Storage_Error EndWriteTypeSection(); Standard_EXPORT virtual Storage_Error EndWriteTypeSection();
Standard_EXPORT Storage_Error BeginReadTypeSection(); Standard_EXPORT virtual Storage_Error BeginReadTypeSection();
Standard_EXPORT Standard_Integer TypeSectionSize(); Standard_EXPORT virtual Standard_Integer TypeSectionSize();
Standard_EXPORT void ReadTypeInformations (Standard_Integer& typeNum, TCollection_AsciiString& typeName); Standard_EXPORT virtual void ReadTypeInformations (Standard_Integer& typeNum, TCollection_AsciiString& typeName);
Standard_EXPORT Storage_Error EndReadTypeSection(); Standard_EXPORT virtual Storage_Error EndReadTypeSection();
Standard_EXPORT Storage_Error BeginWriteRootSection(); Standard_EXPORT virtual Storage_Error BeginWriteRootSection();
Standard_EXPORT void SetRootSectionSize (const Standard_Integer aSize); Standard_EXPORT virtual void SetRootSectionSize (const Standard_Integer aSize);
Standard_EXPORT void WriteRoot (const TCollection_AsciiString& rootName, const Standard_Integer aRef, const TCollection_AsciiString& aType); Standard_EXPORT virtual void WriteRoot (const TCollection_AsciiString& rootName, const Standard_Integer aRef, const TCollection_AsciiString& aType);
Standard_EXPORT Storage_Error EndWriteRootSection(); Standard_EXPORT virtual Storage_Error EndWriteRootSection();
Standard_EXPORT Storage_Error BeginReadRootSection(); Standard_EXPORT virtual Storage_Error BeginReadRootSection();
Standard_EXPORT Standard_Integer RootSectionSize(); Standard_EXPORT virtual Standard_Integer RootSectionSize();
Standard_EXPORT void ReadRoot (TCollection_AsciiString& rootName, Standard_Integer& aRef, TCollection_AsciiString& aType); Standard_EXPORT virtual void ReadRoot (TCollection_AsciiString& rootName, Standard_Integer& aRef, TCollection_AsciiString& aType);
Standard_EXPORT Storage_Error EndReadRootSection(); Standard_EXPORT virtual Storage_Error EndReadRootSection();
Standard_EXPORT Storage_Error BeginWriteRefSection(); Standard_EXPORT virtual Storage_Error BeginWriteRefSection();
Standard_EXPORT void SetRefSectionSize (const Standard_Integer aSize); Standard_EXPORT virtual void SetRefSectionSize (const Standard_Integer aSize);
Standard_EXPORT void WriteReferenceType (const Standard_Integer reference, const Standard_Integer typeNum); Standard_EXPORT virtual void WriteReferenceType (const Standard_Integer reference, const Standard_Integer typeNum);
Standard_EXPORT Storage_Error EndWriteRefSection(); Standard_EXPORT virtual Storage_Error EndWriteRefSection();
Standard_EXPORT Storage_Error BeginReadRefSection(); Standard_EXPORT virtual Storage_Error BeginReadRefSection();
Standard_EXPORT Standard_Integer RefSectionSize(); Standard_EXPORT virtual Standard_Integer RefSectionSize();
Standard_EXPORT void ReadReferenceType (Standard_Integer& reference, Standard_Integer& typeNum); Standard_EXPORT virtual void ReadReferenceType (Standard_Integer& reference, Standard_Integer& typeNum);
Standard_EXPORT Storage_Error EndReadRefSection(); Standard_EXPORT virtual Storage_Error EndReadRefSection();
Standard_EXPORT Storage_Error BeginWriteDataSection(); Standard_EXPORT virtual Storage_Error BeginWriteDataSection();
Standard_EXPORT void WritePersistentObjectHeader (const Standard_Integer aRef, const Standard_Integer aType); Standard_EXPORT virtual void WritePersistentObjectHeader (const Standard_Integer aRef, const Standard_Integer aType);
Standard_EXPORT void BeginWritePersistentObjectData(); Standard_EXPORT virtual void BeginWritePersistentObjectData();
Standard_EXPORT void BeginWriteObjectData(); Standard_EXPORT virtual void BeginWriteObjectData();
Standard_EXPORT void EndWriteObjectData(); Standard_EXPORT virtual void EndWriteObjectData();
Standard_EXPORT void EndWritePersistentObjectData(); Standard_EXPORT virtual void EndWritePersistentObjectData();
Standard_EXPORT Storage_Error EndWriteDataSection(); Standard_EXPORT virtual Storage_Error EndWriteDataSection();
Standard_EXPORT Storage_Error BeginReadDataSection(); Standard_EXPORT virtual Storage_Error BeginReadDataSection();
Standard_EXPORT void ReadPersistentObjectHeader (Standard_Integer& aRef, Standard_Integer& aType); Standard_EXPORT virtual void ReadPersistentObjectHeader (Standard_Integer& aRef, Standard_Integer& aType);
Standard_EXPORT void BeginReadPersistentObjectData(); Standard_EXPORT virtual void BeginReadPersistentObjectData();
Standard_EXPORT void BeginReadObjectData(); Standard_EXPORT virtual void BeginReadObjectData();
Standard_EXPORT void EndReadObjectData(); Standard_EXPORT virtual void EndReadObjectData();
Standard_EXPORT void EndReadPersistentObjectData(); Standard_EXPORT virtual void EndReadPersistentObjectData();
Standard_EXPORT Storage_Error EndReadDataSection(); Standard_EXPORT virtual Storage_Error EndReadDataSection();
Standard_EXPORT void SkipObject(); Standard_EXPORT virtual void SkipObject();
Standard_EXPORT Storage_BaseDriver& PutReference (const Standard_Integer aValue); Standard_EXPORT virtual Storage_BaseDriver& PutReference (const Standard_Integer aValue);
Standard_EXPORT Storage_BaseDriver& PutCharacter (const Standard_Character aValue); Standard_EXPORT virtual Storage_BaseDriver& PutCharacter (const Standard_Character aValue);
Storage_BaseDriver& operator << (const Standard_Character aValue)
{ Storage_BaseDriver& operator << (const Standard_Character aValue)
return PutCharacter(aValue); {
} return PutCharacter(aValue);
}
Standard_EXPORT Storage_BaseDriver& PutExtCharacter (const Standard_ExtCharacter aValue); Standard_EXPORT virtual Storage_BaseDriver& PutExtCharacter (const Standard_ExtCharacter aValue);
Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue) Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue)
{ {
return PutExtCharacter(aValue); return PutExtCharacter(aValue);
} }
Standard_EXPORT Storage_BaseDriver& PutInteger (const Standard_Integer aValue); Standard_EXPORT virtual Storage_BaseDriver& PutInteger (const Standard_Integer aValue);
Storage_BaseDriver& operator << (const Standard_Integer aValue) Storage_BaseDriver& operator << (const Standard_Integer aValue)
{ {
return PutInteger(aValue); return PutInteger(aValue);
} }
Standard_EXPORT Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue); Standard_EXPORT virtual Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue);
Storage_BaseDriver& operator << (const Standard_Boolean aValue) Storage_BaseDriver& operator << (const Standard_Boolean aValue)
{ {
return PutBoolean(aValue); return PutBoolean(aValue);
} }
Standard_EXPORT Storage_BaseDriver& PutReal (const Standard_Real aValue); Standard_EXPORT virtual Storage_BaseDriver& PutReal (const Standard_Real aValue);
Storage_BaseDriver& operator << (const Standard_Real aValue) Storage_BaseDriver& operator << (const Standard_Real aValue)
{ {
return PutReal(aValue); return PutReal(aValue);
} }
Standard_EXPORT Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue); Standard_EXPORT virtual Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue);
Storage_BaseDriver& operator << (const Standard_ShortReal aValue) Storage_BaseDriver& operator << (const Standard_ShortReal aValue)
{ {
return PutShortReal(aValue); return PutShortReal(aValue);
} }
Standard_EXPORT Storage_BaseDriver& GetReference (Standard_Integer& aValue); Standard_EXPORT virtual Storage_BaseDriver& GetReference (Standard_Integer& aValue);
Standard_EXPORT Storage_BaseDriver& GetCharacter (Standard_Character& aValue); Standard_EXPORT virtual Storage_BaseDriver& GetCharacter (Standard_Character& aValue);
Storage_BaseDriver& operator >> (Standard_Character& aValue) Storage_BaseDriver& operator >> (Standard_Character& aValue)
{ {
return GetCharacter(aValue); return GetCharacter(aValue);
} }
Standard_EXPORT Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue); Standard_EXPORT virtual Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue);
Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue) Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue)
{ {
return GetExtCharacter(aValue); return GetExtCharacter(aValue);
} }
Standard_EXPORT Storage_BaseDriver& GetInteger (Standard_Integer& aValue); Standard_EXPORT virtual Storage_BaseDriver& GetInteger (Standard_Integer& aValue);
Storage_BaseDriver& operator >> (Standard_Integer& aValue) Storage_BaseDriver& operator >> (Standard_Integer& aValue)
{ {
return GetInteger(aValue); return GetInteger(aValue);
} }
Standard_EXPORT Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue); Standard_EXPORT virtual Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue);
Storage_BaseDriver& operator >> (Standard_Boolean& aValue) Storage_BaseDriver& operator >> (Standard_Boolean& aValue)
{ {
return GetBoolean(aValue); return GetBoolean(aValue);
} }
Standard_EXPORT Storage_BaseDriver& GetReal (Standard_Real& aValue); Standard_EXPORT virtual Storage_BaseDriver& GetReal (Standard_Real& aValue);
Storage_BaseDriver& operator >> (Standard_Real& aValue) Storage_BaseDriver& operator >> (Standard_Real& aValue)
{ {
return GetReal(aValue); return GetReal(aValue);
} }
Standard_EXPORT Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue); Standard_EXPORT virtual Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue);
Storage_BaseDriver& operator >> (Standard_ShortReal& aValue) Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
{ {
return GetShortReal(aValue); return GetShortReal(aValue);
} }
//! Closes the file driven by this driver. This file was //! Closes the file driven by this driver. This file was
@ -263,7 +264,7 @@ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
//! The function returns Storage_VSOk if the //! The function returns Storage_VSOk if the
//! closure is correctly done, or any other value of //! closure is correctly done, or any other value of
//! the Storage_Error enumeration which specifies the problem encountered. //! the Storage_Error enumeration which specifies the problem encountered.
Standard_EXPORT Storage_Error Close(); Standard_EXPORT virtual Storage_Error Close();
Standard_EXPORT void Destroy(); Standard_EXPORT void Destroy();
~FSD_File() ~FSD_File()
@ -274,34 +275,30 @@ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
Standard_EXPORT static Standard_CString MagicNumber(); Standard_EXPORT static Standard_CString MagicNumber();
protected:
protected:
//! read from the current position to the end of line. //! read from the current position to the end of line.
Standard_EXPORT void ReadLine (TCollection_AsciiString& buffer); Standard_EXPORT virtual void ReadLine (TCollection_AsciiString& buffer);
//! read from the current position to the next white space or end of line. //! read from the current position to the next white space or end of line.
Standard_EXPORT void ReadWord (TCollection_AsciiString& buffer); Standard_EXPORT virtual void ReadWord (TCollection_AsciiString& buffer);
//! read extended chars (unicode) from the current position to the end of line. //! read extended chars (unicode) from the current position to the end of line.
Standard_EXPORT void ReadExtendedLine (TCollection_ExtendedString& buffer); Standard_EXPORT virtual void ReadExtendedLine (TCollection_ExtendedString& buffer);
//! write from the current position to the end of line. //! write from the current position to the end of line.
Standard_EXPORT void WriteExtendedLine (const TCollection_ExtendedString& buffer); Standard_EXPORT virtual void WriteExtendedLine (const TCollection_ExtendedString& buffer);
//! read <rsize> character from the current position. //! read <rsize> character from the current position.
Standard_EXPORT void ReadChar (TCollection_AsciiString& buffer, const Standard_Size rsize); Standard_EXPORT virtual void ReadChar (TCollection_AsciiString& buffer, const Standard_Size rsize);
//! read from the first none space character position to the end of line. //! read from the first none space character position to the end of line.
Standard_EXPORT void ReadString (TCollection_AsciiString& buffer); Standard_EXPORT virtual void ReadString (TCollection_AsciiString& buffer);
Standard_EXPORT void FlushEndOfLine(); Standard_EXPORT virtual void FlushEndOfLine();
Standard_EXPORT Storage_Error FindTag (const Standard_CString aTag);
private:
Standard_EXPORT virtual Storage_Error FindTag (const Standard_CString aTag);
FSD_FStream myStream; FSD_FStream myStream;

35
tests/persist/fsd/B1 Normal file
View File

@ -0,0 +1,35 @@
# check read / write shape to FSD archive and reading its back
set file2 "bug26256.cmp"
set driver "cmp"
set file [locate_data_file ${file2}]
# restore shape from a file
if {[catch {fsdread ${file} shapein}]} {
puts "Error reading fsd file - ${file}"}
return
}
# check base shape
checkshape shapein
# write shape to a file
fsdwrite shapein ${imagedir}/${file2} ${driver}
# restore shape from a file
if {[catch {fsdread ${imagedir}/${file2} result}]} {
puts "Error reading fsd file - ${imagedir}/${file2}"}
return
}
# check result shape
checkshape result
# check the number of subshapes
checknbshapes result -ref [nbshapes shapein]
# check properties
checkprops result -l -equal shapein
checkprops result -s -equal shapein
checkprops result -v -equal shapein