// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 1999-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// commercial license or contractual agreement.
#include <FSD_CmpFile.hxx>
-
-#include <OSD.hxx>
#include <OSD_OpenFile.hxx>
-#include <Standard_PCharacter.hxx>
-#include <Storage_BaseDriver.hxx>
-#include <Storage_StreamExtCharParityError.hxx>
#include <Storage_StreamFormatError.hxx>
-#include <Storage_StreamModeError.hxx>
#include <Storage_StreamTypeMismatchError.hxx>
-#include <Storage_StreamUnknownTypeError.hxx>
#include <Storage_StreamWriteError.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
const Standard_CString MAGICNUMBER = "CMPFILE";
//=======================================================================
FSD_CmpFile::FSD_CmpFile()
-{
-
-}
+{}
//=======================================================================
//function : IsGoodFileType
FSD_CmpFile f;
Storage_Error s;
- s = f.Open(aName,Storage_VSRead);
+ s = f.Open(aName, Storage_VSRead);
if (s == Storage_VSOk) {
TCollection_AsciiString l;
- Standard_Size len = strlen(FSD_CmpFile::MagicNumber());
+ Standard_Size len = strlen(FSD_CmpFile::MagicNumber());
- f.ReadChar(l,len);
+ f.ReadChar(l, len);
f.Close();
- if (strncmp(FSD_CmpFile::MagicNumber(),l.ToCString(),len) != 0) {
+ if (strncmp(FSD_CmpFile::MagicNumber(), l.ToCString(), len) != 0) {
s = Storage_VSFormatError;
}
}
//function : Open
//purpose :
//=======================================================================
-
-Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode)
+Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName, const Storage_OpenMode aMode)
{
Storage_Error result = Storage_VSOk;
-
SetName(aName);
if (OpenMode() == Storage_VSNone) {
std::ios_base::openmode anOpenMode = std::ios_base::openmode(0);
switch (aMode)
{
- case Storage_VSNone:
- {
- break;
- }
- case Storage_VSRead:
- {
- // ios::nocreate is not portable
- #if !defined(IRIX) && !defined(DECOSF1)
- anOpenMode = ios::in | ios::binary;
- #else
- anOpenMode = ios::in;
- #endif
- break;
- }
- case Storage_VSWrite:
- {
- #if !defined(IRIX) && !defined(DECOSF1)
- anOpenMode = ios::out | ios::binary;
- #else
- anOpenMode = ios::out;
- #endif
- break;
- }
- case Storage_VSReadWrite:
- {
- #if !defined(IRIX) && !defined(DECOSF1)
- anOpenMode = ios::in | ios::out | ios::binary;
- #else
- anOpenMode = ios::in | ios::out;
- #endif
- break;
- }
+ case Storage_VSNone:
+ {
+ break;
+ }
+ case Storage_VSRead:
+ {
+ // ios::nocreate is not portable
+#if !defined(IRIX) && !defined(DECOSF1)
+ anOpenMode = ios::in | ios::binary;
+#else
+ anOpenMode = ios::in;
+#endif
+ break;
+ }
+ case Storage_VSWrite:
+ {
+#if !defined(IRIX) && !defined(DECOSF1)
+ anOpenMode = ios::out | ios::binary;
+#else
+ anOpenMode = ios::out;
+#endif
+ break;
+ }
+ case Storage_VSReadWrite:
+ {
+#if !defined(IRIX) && !defined(DECOSF1)
+ anOpenMode = ios::in | ios::out | ios::binary;
+#else
+ anOpenMode = ios::in | ios::out;
+#endif
+ break;
+ }
}
if (anOpenMode != 0)
{
- OSD_OpenStream (myStream, aName, anOpenMode);
+ OSD_OpenStream(myStream, aName, anOpenMode);
}
if (myStream.fail()) {
result = Storage_VSOpenError;
}
else {
myStream.precision(17);
- myStream.imbue (std::locale::classic()); // use always C locale
+ myStream.imbue(std::locale::classic()); // use always C locale
SetOpenMode(aMode);
}
- }
+ }
else {
result = Storage_VSAlreadyOpen;
}
return result;
-}
-
-//=======================================================================
-//function : IsEnd
-//purpose :
-//=======================================================================
-
-Standard_Boolean FSD_CmpFile::IsEnd()
-{
- return myStream.eof();
-}
-
-//=======================================================================
-//function : Close
-//purpose :
-//=======================================================================
-
-Storage_Error FSD_CmpFile::Close()
-{
- Storage_Error result = Storage_VSOk;
-
- if (OpenMode() != Storage_VSNone) {
- myStream.close();
- SetOpenMode(Storage_VSNone);
- }
- else {
- result = Storage_VSNotOpen;
- }
-
- return result;
-}
+ }
//=======================================================================
//function : MagicNumber
return MAGICNUMBER;
}
-//=======================================================================
-//function : FlushEndOfLine
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::FlushEndOfLine()
-{
- TCollection_AsciiString aDummy;
- 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_CmpFile::IsEnd()) {
- Buffer[0] = '\0';
- myStream.get(Buffer,8192,'\n');
-
- if (myStream.get(c) && c != '\r' && c != '\n') {
- }
- else {
- IsEnd = Standard_True;
- }
- }
- */
-}
-
//=======================================================================
//function : ReadLine
//purpose : read from the current position to the end of line.
void FSD_CmpFile::ReadLine(TCollection_AsciiString& buffer)
{
- char Buffer[8193];
- //char c;
- Standard_Boolean IsEnd = Standard_False;
-
buffer.Clear();
-
- while (!IsEnd && !FSD_CmpFile::IsEnd()) {
- Buffer[0] = '\0';
- //myStream.get(Buffer,8192,'\n');
- myStream.getline(Buffer,8192,'\n');
- for (Standard_Size lv = (strlen(Buffer)- 1); lv > 1 && (Buffer[lv] == '\r' || Buffer[lv] == '\n') ;lv--) {
- Buffer[lv] = '\0';
- }
-
-// if (myStream.get(c) && c != '\r' && c != '\n') {
-// buffer += Buffer;
-// buffer += c;
-// }
-// else {
- buffer += Buffer;
- IsEnd = Standard_True;
-// }
- }
+ TCollection_AsciiString aBuf('\0');
+ FSD_File::ReadLine(aBuf);
+ for (Standard_Integer lv = aBuf.Length(); lv >= 1 && (aBuf.Value(lv) == '\r' || (aBuf.Value(lv) == '\n')); lv--)
+ aBuf.SetValue(lv, '\0');
+ buffer = aBuf;
}
//=======================================================================
{
#if 0
Standard_ExtString extBuffer;
- Standard_Integer i,c,d;
+ Standard_Integer i, c, d;
extBuffer = buffer.ToExtString();
for (i = 0; i < buffer.Length(); i++) {
- c = (extBuffer[i] & 0x0000FF00 ) >> 8 ;
+ c = (extBuffer[i] & 0x0000FF00) >> 8;
d = extBuffer[i] & 0x000000FF;
myStream << (char)c << (char)d;
}
//=======================================================================
-//function : ReadChar
-//purpose : read <rsize> character from the current position.
+//function : ReadString
+//purpose : read from the first none space character position to the end of line.
//=======================================================================
-void FSD_CmpFile::ReadChar(TCollection_AsciiString& buffer, const Standard_Size rsize)
+void FSD_CmpFile::ReadString(TCollection_AsciiString& buffer)
{
- char c;
- Standard_Size ccount = 0;
-
buffer.Clear();
-
- while (!IsEnd() && (ccount < rsize)) {
- myStream.get(c);
- buffer += c;
- ccount++;
- }
+ TCollection_AsciiString aBuf('\0');
+ FSD_File::ReadString(aBuf);
+ for (Standard_Integer lv = aBuf.Length(); lv >= 1 && (aBuf.Value(lv) == '\r' || (aBuf.Value(lv) == '\n')); lv--)
+ aBuf.SetValue(lv, '\0');
+ buffer = aBuf;
}
//=======================================================================
-//function : ReadString
-//purpose : read from the first none space character position to the end of line.
+//function : Destroy
+//purpose :
//=======================================================================
-void FSD_CmpFile::ReadString(TCollection_AsciiString& buffer)
+void FSD_CmpFile::Destroy()
{
- char Buffer[8193];
- char *bpos;
- Standard_Boolean IsEnd = Standard_False,isFirstTime = Standard_True;
-
- buffer.Clear();
-
- while (!IsEnd && !FSD_CmpFile::IsEnd()) {
- Buffer[0] = '\0';
- //myStream.get(Buffer,8192,'\n');
- myStream.getline(Buffer,8192,'\n');
- for (Standard_Size lv = (strlen(Buffer)- 1); lv > 1 && (Buffer[lv] == '\r' || Buffer[lv] == '\n') ;lv--) {
- Buffer[lv] = '\0';
- }
- bpos = Buffer;
-
- // LeftAdjust
- //
- if (isFirstTime) {
- isFirstTime = Standard_False;
- while (*bpos == '\n' || *bpos == ' ') bpos++;
- }
-// char c;
-// if (myStream.get(c) && c != '\n') {
-// buffer += bpos;
-// buffer += c;
-// }
-// else {
- buffer += bpos;
- IsEnd = Standard_True;
-// }
+ if (OpenMode() != Storage_VSNone) {
+ Close();
}
}
//=======================================================================
-//function : ReadWord
-//purpose : read from the current position to the next white space or end of line.
+//function : BeginWriteInfoSection
+//purpose : -------------------------- INFO : WRITE
//=======================================================================
-void FSD_CmpFile::ReadWord(TCollection_AsciiString& buffer)
+Storage_Error FSD_CmpFile::BeginWriteInfoSection()
{
- char c = '\0';
- char b[8193],*tmpb;
- Standard_Boolean IsEnd = Standard_False;
- Standard_Integer i;
-
- tmpb = b;
- memset(b,'\0',8193);
- buffer.Clear();
-
- while (!IsEnd && !FSD_CmpFile::IsEnd()) {
- myStream.get(c);
- if ((c != ' ') && (c != '\n')) IsEnd = Standard_True;
- }
-
- IsEnd = Standard_False;
- i = 0;
-
- while (!IsEnd && !FSD_CmpFile::IsEnd()) {
- if (i == 8192) {
- buffer += b;
- tmpb = b;
- memset(b,'\0',8193);
- i = 0;
- }
- *tmpb = c;
- tmpb++; i++;
- myStream.get(c);
- if ((c == '\n') || (c == ' ')) IsEnd = Standard_True;
- }
+ myStream << FSD_CmpFile::MagicNumber() << '\n';
+ myStream << "BEGIN_INFO_SECTION\n";
+ if (myStream.bad()) throw Storage_StreamWriteError();
- buffer += b;
+ return Storage_VSOk;
}
//=======================================================================
-//function : FindTag
+//function : BeginReadInfoSection
//purpose :
//=======================================================================
-Storage_Error FSD_CmpFile::FindTag(const Standard_CString aTag)
+Storage_Error FSD_CmpFile::BeginReadInfoSection()
{
+ Storage_Error s;
TCollection_AsciiString l;
-
- ReadString(l);
+ Standard_Size len = strlen(FSD_CmpFile::MagicNumber());
- while ((strcmp(l.ToCString(),aTag) != 0) && !IsEnd()) {
- ReadString(l);
- }
+ ReadChar(l, len);
- if (IsEnd()) {
- return Storage_VSSectionNotFound;
+ if (strncmp(FSD_CmpFile::MagicNumber(), l.ToCString(), len) != 0) {
+ s = Storage_VSFormatError;
}
else {
- return Storage_VSOk;
+ s = FindTag("BEGIN_INFO_SECTION");
}
-}
-
-//=======================================================================
-//function : SkipObject
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::SkipObject()
-{
- FlushEndOfLine();
-}
-
-//=======================================================================
-//function : PutReference
-//purpose : ---------------------- PUBLIC : PUT
-//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::PutReference(const Standard_Integer aValue)
-{
- myStream << aValue << " ";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return *this;
+ return s;
}
//=======================================================================
-//function : PutCharacter
+//function : WritePersistentObjectHeader
//purpose :
//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::PutCharacter(const Standard_Character aValue)
+void FSD_CmpFile::WritePersistentObjectHeader(const Standard_Integer aRef,
+ const Standard_Integer aType)
{
- unsigned short i;
-
- i = aValue;
- myStream << i << " ";
+ myStream << "\n#" << aRef << "%" << aType << " ";
if (myStream.bad()) throw Storage_StreamWriteError();
- return *this;
}
//=======================================================================
-//function : PutExtCharacter
+//function : BeginWritePersistentObjectData
//purpose :
//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::PutExtCharacter(const Standard_ExtCharacter aValue)
+void FSD_CmpFile::BeginWritePersistentObjectData()
{
- myStream << (short )aValue << " ";
if (myStream.bad()) throw Storage_StreamWriteError();
- return *this;
}
//=======================================================================
-//function : PutInteger
+//function : BeginWriteObjectData
//purpose :
//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::PutInteger(const Standard_Integer aValue)
+void FSD_CmpFile::BeginWriteObjectData()
{
- myStream << aValue << " ";
if (myStream.bad()) throw Storage_StreamWriteError();
- return *this;
}
//=======================================================================
-//function : PutBoolean
+//function : EndWriteObjectData
//purpose :
//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::PutBoolean(const Standard_Boolean aValue)
+void FSD_CmpFile::EndWriteObjectData()
{
- myStream << ((Standard_Integer)aValue) << " ";
if (myStream.bad()) throw Storage_StreamWriteError();
- return *this;
}
//=======================================================================
-//function : PutReal
+//function : EndWritePersistentObjectData
//purpose :
//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::PutReal(const Standard_Real aValue)
+void FSD_CmpFile::EndWritePersistentObjectData()
{
- myStream << ((Standard_Real)aValue) << " ";
if (myStream.bad()) throw Storage_StreamWriteError();
- return *this;
}
//=======================================================================
-//function : PutShortReal
+//function : ReadPersistentObjectHeader
//purpose :
//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::PutShortReal(const Standard_ShortReal aValue)
-{
- myStream << aValue << " ";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return *this;
-}
-
-//=======================================================================
-//function : GetReference
-//purpose : ----------------- PUBLIC : GET
-//=======================================================================
-
-Storage_BaseDriver& FSD_CmpFile::GetReference(Standard_Integer& aValue)
+void FSD_CmpFile::ReadPersistentObjectHeader(Standard_Integer& aRef,
+ Standard_Integer& aType)
{
- if (!(myStream >> aValue)) throw Storage_StreamTypeMismatchError();
-
- return *this;
-}
+ char c;
-//=======================================================================
-//function : GetCharacter
-//purpose :
-//=======================================================================
+ myStream.get(c);
-Storage_BaseDriver& FSD_CmpFile::GetCharacter(Standard_Character& aValue)
-{
- unsigned short i = 0;
- if (!(myStream >> i)) {
- // SGI : donne une erreur mais a une bonne valeur pour les caracteres ecrits
- // signes (-80 fait ios::badbit, mais la variable i est initialisee)
- //
- if (i == 0) throw Storage_StreamTypeMismatchError();
- myStream.clear(ios::goodbit);
+ while (c != '#') {
+ if (IsEnd() || (c != ' ') || (c == '\r') || (c == '\n')) {
+ throw Storage_StreamFormatError();
+ }
+ myStream.get(c);
}
- aValue = (char)i;
-
- return *this;
-}
-
-//=======================================================================
-//function : GetExtCharacter
-//purpose :
-//=======================================================================
-
-Storage_BaseDriver& FSD_CmpFile::GetExtCharacter(Standard_ExtCharacter& aValue)
-{
- short aChar = 0;
- if (!(myStream >> aChar)) throw Storage_StreamTypeMismatchError();
- aValue = aChar;
- return *this;
-}
-
-//=======================================================================
-//function : GetInteger
-//purpose :
-//=======================================================================
-
-Storage_BaseDriver& FSD_CmpFile::GetInteger(Standard_Integer& aValue)
-{
- if (!(myStream >> aValue)) throw Storage_StreamTypeMismatchError();
-
- return *this;
-}
-
-//=======================================================================
-//function : GetBoolean
-//purpose :
-//=======================================================================
-
-Storage_BaseDriver& FSD_CmpFile::GetBoolean(Standard_Boolean& aValue)
-{
- if (!(myStream >> aValue)) throw Storage_StreamTypeMismatchError();
-
- return *this;
-}
-//=======================================================================
-//function : GetReal
-//purpose :
-//=======================================================================
+ if (!(myStream >> aRef)) throw Storage_StreamTypeMismatchError();
-Storage_BaseDriver& FSD_CmpFile::GetReal(Standard_Real& aValue)
-{
- char realbuffer[100];
+ myStream.get(c);
- realbuffer[0] = '\0';
- if (!(myStream >> realbuffer)) {
-#ifdef OCCT_DEBUG
- cerr << "%%%ERROR: read error of double at offset " << myStream.tellg() << endl;
- cerr << "\t buffer is" << realbuffer<< endl;
-#endif
- throw Storage_StreamTypeMismatchError();
- }
- if (!OSD::CStringToReal(realbuffer,aValue)) {
-#ifdef OCCT_DEBUG
- cerr << "%%%ERROR: read error of double at offset " << myStream.tellg() << endl;
- cerr << "\t buffer is" << realbuffer<< endl;
-#endif
- throw Storage_StreamTypeMismatchError();
+ while (c != '%') {
+ if (IsEnd() || (c != ' ') || (c == '\r') || (c == '\n')) {
+ throw Storage_StreamFormatError();
+ }
+ myStream.get(c);
}
- return *this;
+ if (!(myStream >> aType)) throw Storage_StreamTypeMismatchError();
+ // cout << "REF:" << aRef << " TYPE:"<< aType << endl;
}
//=======================================================================
-//function : GetShortReal
+//function : BeginReadPersistentObjectData
//purpose :
//=======================================================================
-Storage_BaseDriver& FSD_CmpFile::GetShortReal(Standard_ShortReal& aValue)
+void FSD_CmpFile::BeginReadPersistentObjectData()
{
- char realbuffer[100];
- Standard_Real r = 0.0;
-
- realbuffer[0] = '\0';
- if (!(myStream >> realbuffer)) throw Storage_StreamTypeMismatchError();
- if (!OSD::CStringToReal(realbuffer,r))
- throw Storage_StreamTypeMismatchError();
-
- aValue = (Standard_ShortReal)r;
-
- return *this;
+ //cout << "BeginReadPersistentObjectData" << endl;
}
//=======================================================================
-//function : Destroy
+//function : BeginReadObjectData
//purpose :
//=======================================================================
-void FSD_CmpFile::Destroy()
-{
- if (OpenMode() != Storage_VSNone) {
- Close();
- }
-}
-
-//=======================================================================
-//function : BeginWriteInfoSection
-//purpose : -------------------------- INFO : WRITE
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginWriteInfoSection()
+void FSD_CmpFile::BeginReadObjectData()
{
- myStream << FSD_CmpFile::MagicNumber() << '\n';
- myStream << "BEGIN_INFO_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-
- return Storage_VSOk;
+ // cout << "BeginReadObjectData" << endl;
}
//=======================================================================
-//function : WriteInfo
+//function : EndReadObjectData
//purpose :
//=======================================================================
-void FSD_CmpFile::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& dataType,
- const TColStd_SequenceOfAsciiString& userInfo)
-{
- Standard_Integer i;
-
- myStream << nbObj;
- myStream << "\n";
- myStream << dbVersion.ToCString() << "\n";
- myStream << date.ToCString() << "\n";
- myStream << schemaName.ToCString() << "\n";
- myStream << schemaVersion.ToCString() << "\n";
- WriteExtendedLine(appName);
- myStream << appVersion.ToCString() << "\n";
- WriteExtendedLine(dataType);
- myStream << userInfo.Length() << "\n";
-
- if (myStream.bad()) throw Storage_StreamWriteError();
-
- for (i = 1; i <= userInfo.Length(); i++) {
- myStream << userInfo.Value(i).ToCString() << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- }
-}
-
-//=======================================================================
-//function : EndWriteInfoSection
-//purpose : read
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndWriteInfoSection()
+void FSD_CmpFile::EndReadObjectData()
{
- myStream << "END_INFO_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
+ // cout << "EndReadObjectData" << endl;
}
//=======================================================================
-//function : BeginReadInfoSection
+//function : EndReadPersistentObjectData
//purpose :
//=======================================================================
-Storage_Error FSD_CmpFile::BeginReadInfoSection()
-{
- Storage_Error s;
- TCollection_AsciiString l;
- Standard_Size len = strlen(FSD_CmpFile::MagicNumber());
-
- ReadChar(l,len);
-
- if (strncmp(FSD_CmpFile::MagicNumber(),l.ToCString(),len) != 0) {
- s = Storage_VSFormatError;
- }
- else {
- s = FindTag("BEGIN_INFO_SECTION");
- }
-
- return s;
-}
-
-//=======================================================================
-//function : ReadInfo
-//purpose : ------------------- INFO : READ
-//=======================================================================
-
-void FSD_CmpFile::ReadInfo(Standard_Integer& nbObj,
- TCollection_AsciiString& dbVersion,
- TCollection_AsciiString& date,
- TCollection_AsciiString& schemaName,
- TCollection_AsciiString& schemaVersion,
- TCollection_ExtendedString& appName,
- TCollection_AsciiString& appVersion,
- TCollection_ExtendedString& dataType,
- TColStd_SequenceOfAsciiString& userInfo)
+void FSD_CmpFile::EndReadPersistentObjectData()
{
- if (!(myStream >> nbObj)) throw Storage_StreamTypeMismatchError();
-
- FlushEndOfLine();
-
- ReadLine(dbVersion);
- ReadLine(date);
- ReadLine(schemaName);
- ReadLine(schemaVersion);
- ReadExtendedLine(appName);
- ReadLine(appVersion);
- ReadExtendedLine(dataType);
-
- Standard_Integer i,len = 0;
-
- if (!(myStream >> len)) throw Storage_StreamTypeMismatchError();
-
- FlushEndOfLine();
-
- TCollection_AsciiString line;
+ char c;
- for (i = 1; i <= len && !IsEnd(); i++) {
- ReadLine(line);
- userInfo.Append(line);
- line.Clear();
+ myStream.get(c);
+ while (c != '\n' && (c != '\r')) {
+ if (IsEnd() || (c != ' ')) {
+ throw Storage_StreamFormatError();
+ }
+ myStream.get(c);
}
-}
-
-//=======================================================================
-//function : ReadCompleteInfo
-//purpose :
-//
-//=======================================================================
-void FSD_CmpFile::ReadCompleteInfo( Standard_IStream& /*theIStream*/, Handle(Storage_Data)& /*theData*/)
-{
-
-}
-
-//=======================================================================
-//function : EndReadInfoSection
-//purpose : COMMENTS SECTION
-// write
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndReadInfoSection()
-{
- return FindTag("END_INFO_SECTION");
-}
-
-//=======================================================================
-//function : BeginWriteCommentSection
-//purpose : ---------------- COMMENTS : WRITE
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginWriteCommentSection()
-{
- myStream << "BEGIN_COMMENT_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : WriteComment
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::WriteComment(const TColStd_SequenceOfExtendedString& aCom)
-{
- Standard_Integer i,aSize;
-
- aSize = aCom.Length();
- myStream << aSize << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-
- for (i = 1; i <= aSize; i++) {
- WriteExtendedLine(aCom.Value(i));
- if (myStream.bad()) throw Storage_StreamWriteError();
- }
-}
-
-//=======================================================================
-//function : EndWriteCommentSection
-//purpose : read
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndWriteCommentSection()
-{
- myStream << "END_COMMENT_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : BeginReadCommentSection
-//purpose : ---------------- COMMENTS : READ
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginReadCommentSection()
-{
- return FindTag("BEGIN_COMMENT_SECTION");
-}
-
-//=======================================================================
-//function : ReadComment
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::ReadComment(TColStd_SequenceOfExtendedString& aCom)
-{
- TCollection_ExtendedString line;
- Standard_Integer len,i;
-
- if (!(myStream >> len)) throw Storage_StreamTypeMismatchError();
-
- FlushEndOfLine();
-
- for (i = 1; i <= len && !IsEnd(); i++) {
- ReadExtendedLine(line);
- aCom.Append(line);
- line.Clear();
- }
-}
-
-//=======================================================================
-//function : EndReadCommentSection
-//purpose :
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndReadCommentSection()
-{
- return FindTag("END_COMMENT_SECTION");
-}
-
-//=======================================================================
-//function : BeginWriteTypeSection
-//purpose : --------------- TYPE : WRITE
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginWriteTypeSection()
-{
- myStream << "BEGIN_TYPE_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : SetTypeSectionSize
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::SetTypeSectionSize(const Standard_Integer aSize)
-{
- myStream << aSize << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : WriteTypeInformations
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::WriteTypeInformations(const Standard_Integer typeNum,
- const TCollection_AsciiString& typeName)
-{
- myStream << typeNum << " " << typeName.ToCString() << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : EndWriteTypeSection
-//purpose : read
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndWriteTypeSection()
-{
- myStream << "END_TYPE_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : BeginReadTypeSection
-//purpose : ------------------- TYPE : READ
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginReadTypeSection()
-{
- return FindTag("BEGIN_TYPE_SECTION");
-}
-
-//=======================================================================
-//function : TypeSectionSize
-//purpose :
-//=======================================================================
-
-Standard_Integer FSD_CmpFile::TypeSectionSize()
-{
- Standard_Integer i;
-
- if (!(myStream >> i)) throw Storage_StreamTypeMismatchError();
-
- FlushEndOfLine();
-
- return i;
-}
-
-//=======================================================================
-//function : ReadTypeInformations
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::ReadTypeInformations(Standard_Integer& typeNum,
- TCollection_AsciiString& typeName)
-{
- if (!(myStream >> typeNum)) throw Storage_StreamTypeMismatchError();
- if (!(myStream >> typeName)) throw Storage_StreamTypeMismatchError();
- FlushEndOfLine();
-}
-
-//=======================================================================
-//function : EndReadTypeSection
-//purpose : ROOT SECTION
-// write
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndReadTypeSection()
-{
- return FindTag("END_TYPE_SECTION");
-}
-
-//=======================================================================
-//function : BeginWriteRootSection
-//purpose : -------------------- ROOT : WRITE
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginWriteRootSection()
-{
- myStream << "BEGIN_ROOT_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : SetRootSectionSize
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::SetRootSectionSize(const Standard_Integer aSize)
-{
- myStream << aSize << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : WriteRoot
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::WriteRoot(const TCollection_AsciiString& rootName, const Standard_Integer aRef, const TCollection_AsciiString& rootType)
-{
- myStream << aRef << " " << rootName.ToCString() << " " << rootType.ToCString() << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : EndWriteRootSection
-//purpose : read
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndWriteRootSection()
-{
- myStream << "END_ROOT_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : BeginReadRootSection
-//purpose : ----------------------- ROOT : READ
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginReadRootSection()
-{
- return FindTag("BEGIN_ROOT_SECTION");
-}
-
-//=======================================================================
-//function : RootSectionSize
-//purpose :
-//=======================================================================
-
-Standard_Integer FSD_CmpFile::RootSectionSize()
-{
- Standard_Integer i;
-
- if (!(myStream >> i)) throw Storage_StreamTypeMismatchError();
-
- FlushEndOfLine();
-
- return i;
-}
-
-//=======================================================================
-//function : ReadRoot
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::ReadRoot(TCollection_AsciiString& rootName, Standard_Integer& aRef,TCollection_AsciiString& rootType)
-{
- if (!(myStream >> aRef)) throw Storage_StreamTypeMismatchError();
- ReadWord(rootName);
- ReadWord(rootType);
-}
-
-//=======================================================================
-//function : EndReadRootSection
-//purpose : REF SECTION
-// write
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndReadRootSection()
-{
- return FindTag("END_ROOT_SECTION");
-}
-
-//=======================================================================
-//function : BeginWriteRefSection
-//purpose : -------------------------- REF : WRITE
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginWriteRefSection()
-{
- myStream << "BEGIN_REF_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : SetRefSectionSize
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::SetRefSectionSize(const Standard_Integer aSize)
-{
- myStream << aSize << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : WriteReferenceType
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::WriteReferenceType(const Standard_Integer reference,
- const Standard_Integer typeNum)
-{
- myStream << reference << " " << typeNum << "\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : EndWriteRefSection
-//purpose : read
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndWriteRefSection()
-{
- myStream << "END_REF_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : BeginReadRefSection
-//purpose : ----------------------- REF : READ
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginReadRefSection()
-{
- return FindTag("BEGIN_REF_SECTION");
-}
-
-//=======================================================================
-//function : RefSectionSize
-//purpose :
-//=======================================================================
-
-Standard_Integer FSD_CmpFile::RefSectionSize()
-{
- Standard_Integer i;
-
- if (!(myStream >> i)) throw Storage_StreamTypeMismatchError();
- FlushEndOfLine();
-
- return i;
-}
-
-//=======================================================================
-//function : ReadReferenceType
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::ReadReferenceType(Standard_Integer& reference,
- Standard_Integer& typeNum)
-{
- if (!(myStream >> reference)) throw Storage_StreamTypeMismatchError();
- if (!(myStream >> typeNum)) throw Storage_StreamTypeMismatchError();
- FlushEndOfLine();
-}
-
-//=======================================================================
-//function : EndReadRefSection
-//purpose : DATA SECTION
-// write
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndReadRefSection()
-{
- return FindTag("END_REF_SECTION");
-}
-
-//=======================================================================
-//function : BeginWriteDataSection
-//purpose : -------------------- DATA : WRITE
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginWriteDataSection()
-{
- myStream << "BEGIN_DATA_SECTION";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : WritePersistentObjectHeader
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::WritePersistentObjectHeader(const Standard_Integer aRef,
- const Standard_Integer aType)
-{
- myStream << "\n#" << aRef << "%" << aType << " ";
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : BeginWritePersistentObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::BeginWritePersistentObjectData()
-{
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : BeginWriteObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::BeginWriteObjectData()
-{
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : EndWriteObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::EndWriteObjectData()
-{
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : EndWritePersistentObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::EndWritePersistentObjectData()
-{
- if (myStream.bad()) throw Storage_StreamWriteError();
-}
-
-//=======================================================================
-//function : EndWriteDataSection
-//purpose : read
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndWriteDataSection()
-{
- myStream << "\nEND_DATA_SECTION\n";
- if (myStream.bad()) throw Storage_StreamWriteError();
- return Storage_VSOk;
-}
-
-//=======================================================================
-//function : BeginReadDataSection
-//purpose : ---------------------- DATA : READ
-//=======================================================================
-
-Storage_Error FSD_CmpFile::BeginReadDataSection()
-{
- return FindTag("BEGIN_DATA_SECTION");
-}
-
-//=======================================================================
-//function : ReadPersistentObjectHeader
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::ReadPersistentObjectHeader(Standard_Integer& aRef,
- Standard_Integer& aType)
-{
- char c;
-
- myStream.get(c);
-
- while (c != '#') {
- if (IsEnd() || (c != ' ') || (c == '\r')|| (c == '\n')) {
- throw Storage_StreamFormatError();
- }
+ if (c == '\r') {
myStream.get(c);
}
-
- if (!(myStream >> aRef)) throw Storage_StreamTypeMismatchError();
-
- myStream.get(c);
-
- while (c != '%') {
- if (IsEnd() || (c != ' ') || (c == '\r')|| (c == '\n')) {
- throw Storage_StreamFormatError();
- }
- myStream.get(c);
- }
-
- if (!(myStream >> aType)) throw Storage_StreamTypeMismatchError();
-// cout << "REF:" << aRef << " TYPE:"<< aType << endl;
-}
-
-//=======================================================================
-//function : BeginReadPersistentObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::BeginReadPersistentObjectData()
-{
-//cout << "BeginReadPersistentObjectData" << endl;
-}
-
-//=======================================================================
-//function : BeginReadObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::BeginReadObjectData()
-{
-// cout << "BeginReadObjectData" << endl;
-}
-
-//=======================================================================
-//function : EndReadObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::EndReadObjectData()
-{
-// cout << "EndReadObjectData" << endl;
-}
-
-//=======================================================================
-//function : EndReadPersistentObjectData
-//purpose :
-//=======================================================================
-
-void FSD_CmpFile::EndReadPersistentObjectData()
-{
- char c;
-
- myStream.get(c);
- while (c != '\n' && (c != '\r')) {
- if (IsEnd() || (c != ' ')) {
- throw Storage_StreamFormatError();
- }
- myStream.get(c);
- }
- if (c == '\r') {
- myStream.get(c);
- }
-// cout << "EndReadPersistentObjectData" << endl;
-}
-
-//=======================================================================
-//function : EndReadDataSection
-//purpose :
-//=======================================================================
-
-Storage_Error FSD_CmpFile::EndReadDataSection()
-{
- return FindTag("END_DATA_SECTION");
-}
-
-//=======================================================================
-//function : Tell
-//purpose : return position in the file. Return -1 upon error.
-//=======================================================================
-
-Storage_Position FSD_CmpFile::Tell()
-{
- switch (OpenMode()) {
- case Storage_VSRead:
- return (Storage_Position) myStream.tellp();
- case Storage_VSWrite:
- return (Storage_Position) myStream.tellg();
- case Storage_VSReadWrite: {
- Storage_Position aPosR = (Storage_Position) myStream.tellp();
- Storage_Position aPosW = (Storage_Position) myStream.tellg();
- if (aPosR < aPosW)
- return aPosW;
- else
- return aPosR;
- }
- default: return -1;
- }
+ // cout << "EndReadPersistentObjectData" << endl;
}
#ifndef _FSD_CmpFile_HeaderFile
#define _FSD_CmpFile_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <FSD_FStream.hxx>
+#include <FSD_File.hxx>
#include <Storage_BaseDriver.hxx>
#include <Storage_Error.hxx>
#include <Storage_OpenMode.hxx>
#include <Standard_Boolean.hxx>
-#include <Storage_Position.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_Type.hxx>
-class Storage_StreamTypeMismatchError;
-class Storage_StreamFormatError;
-class Storage_StreamWriteError;
-class Storage_StreamExtCharParityError;
class TCollection_AsciiString;
class TCollection_ExtendedString;
class Storage_BaseDriver;
-
-
-class FSD_CmpFile : public Storage_BaseDriver
+class FSD_CmpFile : public FSD_File
{
public:
DEFINE_STANDARD_ALLOC
-
+
Standard_EXPORT FSD_CmpFile();
-
- Standard_EXPORT Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode);
-
- Standard_EXPORT Standard_Boolean IsEnd();
-
- //! 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 Open(const TCollection_AsciiString& aName, const Storage_OpenMode aMode);
+
+ Standard_EXPORT static Storage_Error IsGoodFileType(const TCollection_AsciiString& aName);
+
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 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 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 WritePersistentObjectHeader(const Standard_Integer aRef, const Standard_Integer aType);
+
Standard_EXPORT void BeginWritePersistentObjectData();
-
+
Standard_EXPORT void BeginWriteObjectData();
-
+
Standard_EXPORT void EndWriteObjectData();
-
+
Standard_EXPORT void EndWritePersistentObjectData();
-
- Standard_EXPORT Storage_Error EndWriteDataSection();
-
- Standard_EXPORT Storage_Error BeginReadDataSection();
-
- Standard_EXPORT void ReadPersistentObjectHeader (Standard_Integer& aRef, Standard_Integer& aType);
-
+
+ Standard_EXPORT void ReadPersistentObjectHeader(Standard_Integer& aRef, Standard_Integer& aType);
+
Standard_EXPORT void BeginReadPersistentObjectData();
-
+
Standard_EXPORT void BeginReadObjectData();
-
+
Standard_EXPORT void EndReadObjectData();
-
+
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();
-~FSD_CmpFile()
-{
- Destroy();
-}
+ ~FSD_CmpFile()
+ {
+ Destroy();
+ }
Standard_EXPORT static Standard_CString MagicNumber();
protected:
-
+
//! read from the current position to the end of line.
- 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);
-
+ Standard_EXPORT void ReadLine(TCollection_AsciiString& buffer);
+
//! read extended chars (unicode) from the current position to the end of line.
- Standard_EXPORT void ReadExtendedLine (TCollection_ExtendedString& buffer);
-
- //! write from the current position to the end of line.
- 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.
- Standard_EXPORT void ReadString (TCollection_AsciiString& buffer);
-
- Standard_EXPORT void FlushEndOfLine();
-
- Standard_EXPORT Storage_Error FindTag (const Standard_CString aTag);
+ Standard_EXPORT void ReadExtendedLine(TCollection_ExtendedString& buffer);
-private:
-
- void RaiseError (const Handle(Standard_Type)& theFailure);
+ //! write from the current position to the end of line.
+ Standard_EXPORT void WriteExtendedLine(const TCollection_ExtendedString& buffer);
-private:
+ //! read from the first none space character position to the end of line.
+ Standard_EXPORT void ReadString(TCollection_AsciiString& buffer);
- FSD_FStream myStream;
};
#endif // _FSD_CmpFile_HeaderFile
//! The function returns Storage_VSOk if the file
//! is opened correctly, or any other value of the
//! 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.
- Standard_EXPORT Storage_Position Tell();
+ Standard_EXPORT virtual Storage_Position Tell();
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);
-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 virtual Storage_BaseDriver& PutCharacter (const Standard_Character aValue);
+
+ Storage_BaseDriver& operator << (const Standard_Character aValue)
+ {
+ return PutCharacter(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& PutExtCharacter (const Standard_ExtCharacter aValue);
+ Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue)
+ {
+ return PutExtCharacter(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& PutInteger (const Standard_Integer aValue);
+ Storage_BaseDriver& operator << (const Standard_Integer aValue)
+ {
+ return PutInteger(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue);
+ Storage_BaseDriver& operator << (const Standard_Boolean aValue)
+ {
+ return PutBoolean(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& PutReal (const Standard_Real aValue);
+ Storage_BaseDriver& operator << (const Standard_Real aValue)
+ {
+ return PutReal(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue);
+ Storage_BaseDriver& operator << (const Standard_ShortReal aValue)
+ {
+ return PutShortReal(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& GetReference (Standard_Integer& aValue);
+
+ Standard_EXPORT virtual Storage_BaseDriver& GetCharacter (Standard_Character& aValue);
+ Storage_BaseDriver& operator >> (Standard_Character& aValue)
+ {
+ return GetCharacter(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue);
+ Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue)
+ {
+ return GetExtCharacter(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& GetInteger (Standard_Integer& aValue);
+ Storage_BaseDriver& operator >> (Standard_Integer& aValue)
+ {
+ return GetInteger(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue);
+ Storage_BaseDriver& operator >> (Standard_Boolean& aValue)
+ {
+ return GetBoolean(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& GetReal (Standard_Real& aValue);
+ Storage_BaseDriver& operator >> (Standard_Real& aValue)
+ {
+ return GetReal(aValue);
+ }
+
+ Standard_EXPORT virtual Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue);
+ Storage_BaseDriver& operator >> (Standard_ShortReal& aValue)
+ {
+ return GetShortReal(aValue);
+ }
//! Closes the file driven by this driver. This file was
//! The function returns Storage_VSOk if the
//! closure is correctly done, or any other value of
//! the Storage_Error enumeration which specifies the problem encountered.
- Standard_EXPORT Storage_Error Close();
+ Standard_EXPORT virtual Storage_Error Close();
Standard_EXPORT void Destroy();
~FSD_File()
Standard_EXPORT static Standard_CString MagicNumber();
-
-protected:
+ protected:
//! 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.
- 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.
- 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.
- Standard_EXPORT void WriteExtendedLine (const TCollection_ExtendedString& buffer);
+ Standard_EXPORT virtual void WriteExtendedLine (const TCollection_ExtendedString& buffer);
//! 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.
- Standard_EXPORT void ReadString (TCollection_AsciiString& buffer);
+ Standard_EXPORT virtual void ReadString (TCollection_AsciiString& buffer);
- Standard_EXPORT void FlushEndOfLine();
-
- Standard_EXPORT Storage_Error FindTag (const Standard_CString aTag);
-
-private:
+ Standard_EXPORT virtual void FlushEndOfLine();
+ Standard_EXPORT virtual Storage_Error FindTag (const Standard_CString aTag);
FSD_FStream myStream;