4 #include "FSD_CArchive.hxx"
5 #include "FSD_Archive.ixx"
7 #include <FSD_CFile.hxx>
18 const Standard_CString MAGICNUMBER = "FSDARCH";
20 FSD_Archive::FSD_Archive()
23 myEof = Standard_False;
24 myExternFlag = Standard_False;
26 myFormat = Standard_False;
29 FSD_Archive::FSD_Archive(const FSD_CArchive& anArchive)
32 myEof = Standard_False;
33 myExternFlag = Standard_True;
35 myFormat = Standard_False;
36 if (myStream->IsLoading()) SetOpenMode(Storage_VSRead);
37 else SetOpenMode(Storage_VSWrite);
40 Storage_Error FSD_Archive::IsGoodFileType(const TCollection_AsciiString& aName)
44 s = f.Open(aName,Storage_VSRead);
46 if (s == Storage_VSOk) {
47 TCollection_AsciiString l;
48 Standard_Integer len = (int)strlen(FSD_Archive::MagicNumber());
54 if (strncmp(FSD_Archive::MagicNumber(),l.ToCString(),len) != 0) {
55 s = Storage_VSFormatError;
61 Storage_Error FSD_Archive::Open(const TCollection_AsciiString& theName,
62 const Storage_OpenMode aMode)
64 Storage_Error result = Storage_VSOk;
65 CString aName = theName.ToCString();
67 if (OpenMode() == Storage_VSNone) {
68 if (aMode == Storage_VSRead) {
69 if (!((FSD_CFile*)myCFile)->Open(aName, CFile::modeRead))
70 result = Storage_VSOpenError;
72 else if (aMode == Storage_VSWrite) {
73 if (!((FSD_CFile*)myCFile)->Open(aName, CFile::modeCreate | CFile::modeWrite))
74 result = Storage_VSOpenError;
76 else if (aMode == Storage_VSReadWrite) {
77 if (!((FSD_CFile*)myCFile)->Open(aName, CFile::modeReadWrite))
78 result = Storage_VSOpenError;
80 if (result == Storage_VSOk) {
81 if (aMode == Storage_VSRead) {
82 myStream = new CArchive( ((FSD_CFile*)myCFile), CArchive::load);
85 myStream = new CArchive( ((FSD_CFile*)myCFile), CArchive::store);
91 myEof = Standard_False;
95 result = Storage_VSAlreadyOpen;
100 Standard_Boolean FSD_Archive::IsEnd()
105 Storage_Error FSD_Archive::Close()
107 Storage_Error result = Storage_VSOk;
109 myEof = Standard_False;
111 if (OpenMode() != Storage_VSNone) {
114 ((FSD_CFile*)myCFile)->Close();
117 myExternFlag = Standard_False;
119 SetOpenMode(Storage_VSNone);
122 result = Storage_VSNotOpen;
128 // ------------------ PROTECTED
130 const Standard_CString FSD_Archive::MagicNumber()
136 void FSD_Archive::ReadLine(TCollection_AsciiString& buffer)
140 Standard_Boolean IsEnd = Standard_False;
152 IsEnd = Standard_True;
156 CATCH(CArchiveException,e) {
157 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
162 void FSD_Archive::WriteLine(const TCollection_AsciiString& buffer)
165 for (i = 1; i <= buffer.Length(); i++) {
166 (*myStream) << buffer.Value(i);
168 (*myStream) << (Standard_Character)0;
171 void FSD_Archive::WriteExtendedLine(const TCollection_ExtendedString& buffer)
173 Standard_ExtString extBuffer;
176 extBuffer = buffer.ToExtString();
178 for (i = 0; i < buffer.Length(); i++) {
179 (*myStream) << extBuffer[i];
182 (*myStream) << (Standard_ExtCharacter)0;
185 void FSD_Archive::ReadExtendedLine(TCollection_ExtendedString& buffer)
188 Standard_ExtCharacter i = 0;
189 Standard_Boolean fin = Standard_False;
195 if (i == 0) fin = Standard_True;
196 else buffer += (Standard_ExtCharacter)i;
199 CATCH(CArchiveException,e) {
200 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
205 void FSD_Archive::ReadChar(TCollection_AsciiString& buffer, const Standard_Integer rsize)
209 Standard_Integer ccount = 0;
213 while (ccount < rsize) {
219 CATCH(CArchiveException,e) {
220 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
226 Storage_Error FSD_Archive::FindTag(const Standard_CString aTag)
228 TCollection_AsciiString l;
229 Standard_CString str;
234 Standard_Integer aNum = 0;
239 while ((strcmp(&str[aNum],aTag) != 0) && !IsEnd()) {
240 // while ((strcmp(&str[1],aTag) != 0) && !IsEnd()) {
246 return Storage_VSSectionNotFound;
253 void FSD_Archive::SkipObject()
255 Standard_Boolean errorStatus = Standard_False;
258 Standard_Boolean IsEnd = Standard_False;
259 Standard_Integer rtmp,itmp;
261 Standard_ShortReal stmp;
262 Standard_Integer btmp;
263 Standard_Character ctmp;
264 Standard_ExtCharacter etmp;
266 ReadPersistentObjectHeader(rtmp,itmp);
294 IsEnd = Standard_True;
297 errorStatus = Standard_True;
298 IsEnd = Standard_True;
303 CATCH(CArchiveException,e) {
304 if ((e->m_cause != CArchiveException::endOfFile) &&
305 (e->m_cause != CArchiveException::none)) errorStatus = Standard_True;
306 else if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
311 // ---------------------- PUBLIC : PUT
313 Storage_BaseDriver& FSD_Archive::PutReference(const Standard_Integer aValue)
315 Standard_Boolean errorStatus = Standard_False;
318 (*myStream) << FSD_REF << aValue;
320 CATCH(CArchiveException,e) {
321 errorStatus = Standard_True;
325 if (errorStatus) Storage_StreamWriteError::Raise();
329 Storage_BaseDriver& FSD_Archive::PutCharacter(const Standard_Character aValue)
331 Standard_Boolean errorStatus = Standard_False;
334 //unsigned short i = aValue;
335 //(*myStream) << FSD_CHA << i;
336 (*myStream) << FSD_CHA << aValue;
338 CATCH(CArchiveException,e) {
339 errorStatus = Standard_True;
343 if (errorStatus) Storage_StreamWriteError::Raise();
347 Storage_BaseDriver& FSD_Archive::PutExtCharacter(const Standard_ExtCharacter aValue)
349 Standard_Boolean errorStatus = Standard_False;
351 (*myStream) << FSD_EXT << aValue;
353 CATCH(CArchiveException,e) {
354 errorStatus = Standard_True;
358 if (errorStatus) Storage_StreamWriteError::Raise();
362 Storage_BaseDriver& FSD_Archive::PutInteger(const Standard_Integer aValue)
364 Standard_Boolean errorStatus = Standard_False;
366 (*myStream) << FSD_INT << aValue;
368 CATCH(CArchiveException,e) {
369 errorStatus = Standard_True;
373 if (errorStatus) Storage_StreamWriteError::Raise();
377 Storage_BaseDriver& FSD_Archive::PutBoolean(const Standard_Boolean aValue)
379 Standard_Boolean errorStatus = Standard_False;
381 (*myStream) << FSD_BOO << ((Standard_Integer)aValue);
383 CATCH(CArchiveException,e) {
384 errorStatus = Standard_True;
388 if (errorStatus) Storage_StreamWriteError::Raise();
392 Storage_BaseDriver& FSD_Archive::PutReal(const Standard_Real aValue)
394 Standard_Boolean errorStatus = Standard_False;
396 (*myStream) << FSD_REA << ((Standard_Real)aValue);
398 CATCH(CArchiveException,e) {
399 errorStatus = Standard_True;
403 if (errorStatus) Storage_StreamWriteError::Raise();
407 Storage_BaseDriver& FSD_Archive::PutShortReal(const Standard_ShortReal aValue)
409 Standard_Boolean errorStatus = Standard_False;
411 (*myStream) << FSD_SHO << aValue;
413 CATCH(CArchiveException,e) {
414 errorStatus = Standard_True;
418 if (errorStatus) Storage_StreamWriteError::Raise();
422 // ----------------- PUBLIC : GET
424 Storage_BaseDriver& FSD_Archive::GetReference(Standard_Integer& aValue)
426 Standard_Boolean errorStatus = Standard_False;
429 (*myStream) >> ptype;
430 if (ptype == FSD_REF)
431 (*myStream) >> aValue;
432 else errorStatus = Standard_True;
434 CATCH(CArchiveException,e) {
435 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
436 else errorStatus = Standard_True;
440 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
444 Storage_BaseDriver& FSD_Archive::GetCharacter(Standard_Character& aValue)
446 Standard_Boolean errorStatus = Standard_False;
449 Standard_Character i;
451 (*myStream) >> ptype;
452 if (ptype == FSD_CHA) {
456 else errorStatus = Standard_True;
458 CATCH(CArchiveException,e) {
459 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
460 else errorStatus = Standard_True;
464 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
468 Storage_BaseDriver& FSD_Archive::GetExtCharacter(Standard_ExtCharacter& aValue)
470 Standard_Boolean errorStatus = Standard_False;
473 (*myStream) >> ptype;
474 if (ptype == FSD_EXT)
475 (*myStream) >> aValue;
476 else errorStatus = Standard_True;
478 CATCH(CArchiveException,e) {
479 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
480 else errorStatus = Standard_True;
484 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
488 Storage_BaseDriver& FSD_Archive::GetInteger(Standard_Integer& aValue)
490 Standard_Boolean errorStatus = Standard_False;
493 (*myStream) >> ptype;
494 if (ptype == FSD_INT)
495 (*myStream) >> aValue;
496 else errorStatus = Standard_True;
498 CATCH(CArchiveException,e) {
499 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
500 else errorStatus = Standard_True;
504 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
508 Storage_BaseDriver& FSD_Archive::GetBoolean(Standard_Boolean& aValue)
510 Standard_Boolean errorStatus = Standard_False;
513 (*myStream) >> ptype;
514 if (ptype == FSD_BOO)
515 (*myStream) >> aValue;
516 else errorStatus = Standard_True;
518 CATCH(CArchiveException,e) {
519 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
520 else errorStatus = Standard_True;
524 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
528 Storage_BaseDriver& FSD_Archive::GetReal(Standard_Real& aValue)
530 Standard_Boolean errorStatus = Standard_False;
533 (*myStream) >> ptype;
534 if (ptype == FSD_REA)
535 (*myStream) >> aValue;
536 else errorStatus = Standard_True;
538 CATCH(CArchiveException,e) {
539 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
540 else errorStatus = Standard_True;
544 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
548 Storage_BaseDriver& FSD_Archive::GetShortReal(Standard_ShortReal& aValue)
550 Standard_Boolean errorStatus = Standard_False;
553 (*myStream) >> ptype;
554 if (ptype == FSD_SHO)
555 (*myStream) >> aValue;
556 else errorStatus = Standard_True;
558 CATCH(CArchiveException,e) {
559 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
560 else errorStatus = Standard_True;
564 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
568 // -------------------------- DESTROY
570 void FSD_Archive::Destroy()
572 if (OpenMode() != Storage_VSNone) {
575 delete ((FSD_CFile*)myCFile);
582 // -------------------------- INFO : WRITE
584 Storage_Error FSD_Archive::BeginWriteInfoSection()
586 Standard_Boolean errorStatus = Standard_False;
588 //(*myStream) << FSD_Archive::MagicNumber();
589 WriteLine(TCollection_AsciiString(FSD_Archive::MagicNumber()));
590 //(*myStream) << "BEGIN_INFO_SECTION" << '\0';
591 WriteLine(TCollection_AsciiString("BEGIN_INFO_SECTION"));
593 CATCH(CArchiveException,e) {
594 errorStatus = Standard_True;
598 if (errorStatus) Storage_StreamWriteError::Raise();
602 void FSD_Archive::WriteInfo(const Standard_Integer nbObj,
603 const TCollection_AsciiString& dbVersion,
604 const TCollection_AsciiString& date,
605 const TCollection_AsciiString& schemaName,
606 const TCollection_AsciiString& schemaVersion,
607 const TCollection_ExtendedString& appName,
608 const TCollection_AsciiString& appVersion,
609 const TCollection_ExtendedString& dataType,
610 const TColStd_SequenceOfAsciiString& userInfo)
612 Standard_Boolean errorStatus = Standard_False;
616 (*myStream) << nbObj;
617 //(*myStream) << dbVersion.ToCString() << '\0';
618 WriteLine(dbVersion);
619 //(*myStream) << date.ToCString() << '\0';
621 //(*myStream) << schemaName.ToCString() << '\0';
622 WriteLine(schemaName);
623 //(*myStream) << schemaVersion.ToCString() << '\0';
624 WriteLine(schemaVersion);
625 WriteExtendedLine(appName);
626 //(*myStream) << appVersion.ToCString() << '\0';
627 WriteLine(appVersion);
628 WriteExtendedLine(dataType);
629 (*myStream) << userInfo.Length();
631 for (i = 1; i <= userInfo.Length(); i++) {
632 //(*myStream) << userInfo.Value(i).ToCString() << '\0';
633 WriteLine(userInfo.Value(i));
636 CATCH(CArchiveException,e) {
637 errorStatus = Standard_True;
641 if (errorStatus) Storage_StreamWriteError::Raise();
645 Storage_Error FSD_Archive::EndWriteInfoSection()
648 Standard_Boolean errorStatus = Standard_False;
650 //(*myStream) << "END_INFO_SECTION" << '\0';
651 WriteLine(TCollection_AsciiString("END_INFO_SECTION"));
653 CATCH(CArchiveException,e) {
654 errorStatus = Standard_True;
658 if (errorStatus) Storage_StreamWriteError::Raise();
662 Storage_Error FSD_Archive::BeginReadInfoSection()
666 TCollection_AsciiString l;
667 Standard_Integer len = (int)strlen(FSD_Archive::MagicNumber());
669 // first character is length of the magic number
672 if(l.ToCString()[0] != (Standard_Character) len)
673 myFormat = Standard_True;
676 TCollection_AsciiString ll;
682 if (strncmp(FSD_Archive::MagicNumber(),l.ToCString(),len) != 0) {
683 s = Storage_VSFormatError;
686 s = FindTag("BEGIN_INFO_SECTION");
691 // ------------------- INFO : READ
693 void FSD_Archive::ReadInfo(Standard_Integer& nbObj,
694 TCollection_AsciiString& dbVersion,
695 TCollection_AsciiString& date,
696 TCollection_AsciiString& schemaName,
697 TCollection_AsciiString& schemaVersion,
698 TCollection_ExtendedString& appName,
699 TCollection_AsciiString& appVersion,
700 TCollection_ExtendedString& dataType,
701 TColStd_SequenceOfAsciiString& userInfo)
703 Standard_Boolean errorStatus = Standard_False;
705 (*myStream) >> nbObj;
709 ReadLine(schemaName);
710 ReadLine(schemaVersion);
711 ReadExtendedLine(appName);
712 ReadLine(appVersion);
713 ReadExtendedLine(dataType);
715 Standard_Integer i,len = 0;
719 TCollection_AsciiString line;
721 for (i = 1; i <= len && !IsEnd(); i++) {
723 userInfo.Append(line);
727 CATCH(CArchiveException,e) {
728 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
729 else errorStatus = Standard_True;
734 Storage_StreamTypeMismatchError::Raise();
737 Storage_Error FSD_Archive::EndReadInfoSection()
739 return FindTag("END_INFO_SECTION");
742 // ---------------- COMMENTS : WRITE
744 Storage_Error FSD_Archive::BeginWriteCommentSection()
746 Standard_Boolean errorStatus = Standard_False;
748 //(*myStream) << "BEGIN_COMMENT_SECTION" << '\0';
749 WriteLine(TCollection_AsciiString("BEGIN_COMMENT_SECTION"));
751 CATCH(CArchiveException,e) {
752 errorStatus = Standard_True;
756 if (errorStatus) Storage_StreamWriteError::Raise();
760 void FSD_Archive::WriteComment(const TColStd_SequenceOfExtendedString& aCom)
762 Standard_Boolean errorStatus = Standard_False;
764 Standard_Integer i,aSize;
766 aSize = aCom.Length();
767 (*myStream) << aSize;
768 for (i = 1; i <= aSize; i++) {
769 WriteExtendedLine(aCom.Value(i));
772 CATCH(CArchiveException,e) {
773 errorStatus = Standard_True;
778 Storage_StreamWriteError::Raise();
781 Storage_Error FSD_Archive::EndWriteCommentSection()
783 Standard_Boolean errorStatus = Standard_False;
785 //(*myStream) << "END_COMMENT_SECTION" << '\0';
786 WriteLine(TCollection_AsciiString("END_COMMENT_SECTION"));
788 CATCH(CArchiveException,e) {
789 errorStatus = Standard_True;
793 if (errorStatus) Storage_StreamWriteError::Raise();
797 // ---------------- COMMENTS : READ
799 Storage_Error FSD_Archive::BeginReadCommentSection()
801 return FindTag("BEGIN_COMMENT_SECTION");
804 void FSD_Archive::ReadComment(TColStd_SequenceOfExtendedString& aCom)
806 Standard_Boolean errorStatus = Standard_False;
808 TCollection_ExtendedString line;
809 Standard_Integer len,i;
813 for (i = 1; i <= len && !IsEnd(); i++) {
814 ReadExtendedLine(line);
819 CATCH(CArchiveException,e) {
820 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
821 else errorStatus = Standard_True;
826 Storage_StreamTypeMismatchError::Raise();
829 Storage_Error FSD_Archive::EndReadCommentSection()
831 return FindTag("END_COMMENT_SECTION");
834 // --------------- TYPE : WRITE
836 Storage_Error FSD_Archive::BeginWriteTypeSection()
838 Standard_Boolean errorStatus = Standard_False;
840 //(*myStream) << "BEGIN_TYPE_SECTION" << '\0';
841 WriteLine(TCollection_AsciiString("BEGIN_TYPE_SECTION"));
843 CATCH(CArchiveException,e) {
844 errorStatus = Standard_True;
848 if (errorStatus) Storage_StreamWriteError::Raise();
852 void FSD_Archive::SetTypeSectionSize(const Standard_Integer aSize)
854 Standard_Boolean errorStatus = Standard_False;
856 (*myStream) << aSize;
858 CATCH(CArchiveException,e) {
859 errorStatus = Standard_True;
864 Storage_StreamWriteError::Raise();
867 void FSD_Archive::WriteTypeInformations (const Standard_Integer typeNum,
868 const TCollection_AsciiString& typeName)
870 Standard_Boolean errorStatus = Standard_False;
872 //(*myStream) << typeNum << typeName.ToCString() << '\0';
873 (*myStream) << typeNum;
876 CATCH(CArchiveException,e) {
877 errorStatus = Standard_True;
882 Storage_StreamWriteError::Raise();
885 Storage_Error FSD_Archive::EndWriteTypeSection()
887 Standard_Boolean errorStatus = Standard_False;
889 //(*myStream) << "END_TYPE_SECTION" << '\0';
890 WriteLine(TCollection_AsciiString("END_TYPE_SECTION"));
892 CATCH(CArchiveException,e) {
893 errorStatus = Standard_True;
897 if (errorStatus) Storage_StreamWriteError::Raise();
901 // ------------------- TYPE : READ
903 Storage_Error FSD_Archive::BeginReadTypeSection()
905 return FindTag("BEGIN_TYPE_SECTION");
908 Standard_Integer FSD_Archive::TypeSectionSize()
910 Standard_Integer i = 0;
911 Standard_Boolean errorStatus = Standard_False;
915 CATCH(CArchiveException,e) {
916 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
917 else errorStatus = Standard_True;
921 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
925 void FSD_Archive::ReadTypeInformations(Standard_Integer& typeNum, TCollection_AsciiString& typeName)
927 Standard_Boolean errorStatus = Standard_False;
930 (*myStream) >> typeNum;
933 TCollection_AsciiString tn;
934 typeName = (Standard_Character) c;
941 CATCH(CArchiveException,e) {
942 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
943 else errorStatus = Standard_True;
948 Storage_StreamTypeMismatchError::Raise();
951 Storage_Error FSD_Archive::EndReadTypeSection()
953 return FindTag("END_TYPE_SECTION");
956 // -------------------- ROOT : WRITE
958 Storage_Error FSD_Archive::BeginWriteRootSection()
960 Standard_Boolean errorStatus = Standard_False;
962 //(*myStream) << "BEGIN_ROOT_SECTION" << '\0';
963 WriteLine(TCollection_AsciiString("BEGIN_ROOT_SECTION"));
965 CATCH(CArchiveException,e) {
966 errorStatus = Standard_True;
970 if (errorStatus) Storage_StreamWriteError::Raise();
974 void FSD_Archive::SetRootSectionSize(const Standard_Integer aSize)
976 Standard_Boolean errorStatus = Standard_False;
978 (*myStream) << aSize;
980 CATCH(CArchiveException,e) {
981 errorStatus = Standard_True;
986 Storage_StreamWriteError::Raise();
989 void FSD_Archive::WriteRoot (const TCollection_AsciiString& rootName,
990 const Standard_Integer aRef,
991 const TCollection_AsciiString& rootType)
993 Standard_Boolean errorStatus = Standard_False;
995 //(*myStream) << aRef << rootName.ToCString() << '\0' << rootType.ToCString() << '\0';
1001 CATCH(CArchiveException,e) {
1002 errorStatus = Standard_True;
1007 Storage_StreamWriteError::Raise();
1010 Storage_Error FSD_Archive::EndWriteRootSection()
1012 Standard_Boolean errorStatus = Standard_False;
1014 //(*myStream) << "END_ROOT_SECTION" << '\0';
1015 WriteLine(TCollection_AsciiString("END_ROOT_SECTION"));
1017 CATCH(CArchiveException,e) {
1018 errorStatus = Standard_True;
1022 if (errorStatus) Storage_StreamWriteError::Raise();
1023 return Storage_VSOk;
1026 // ----------------------- ROOT : READ
1028 Storage_Error FSD_Archive::BeginReadRootSection()
1030 return FindTag("BEGIN_ROOT_SECTION");
1033 Standard_Integer FSD_Archive::RootSectionSize()
1035 Standard_Integer i = 0;
1036 Standard_Boolean errorStatus = Standard_False;
1040 CATCH(CArchiveException,e) {
1041 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1042 else errorStatus = Standard_True;
1046 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
1050 void FSD_Archive::ReadRoot(TCollection_AsciiString& rootName,
1051 Standard_Integer& aRef,
1052 TCollection_AsciiString& rootType)
1054 Standard_Boolean errorStatus = Standard_False;
1056 (*myStream) >> aRef;
1060 CATCH(CArchiveException,e) {
1061 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1062 else errorStatus = Standard_True;
1067 Storage_StreamTypeMismatchError::Raise();
1070 Storage_Error FSD_Archive::EndReadRootSection()
1072 return FindTag("END_ROOT_SECTION");
1075 // -------------------------- REF : WRITE
1077 Storage_Error FSD_Archive::BeginWriteRefSection()
1079 Standard_Boolean errorStatus = Standard_False;
1081 //(*myStream) << "BEGIN_REF_SECTION" << '\0';
1082 WriteLine(TCollection_AsciiString("BEGIN_REF_SECTION"));
1084 CATCH(CArchiveException,e) {
1085 errorStatus = Standard_True;
1089 if (errorStatus) Storage_StreamWriteError::Raise();
1090 return Storage_VSOk;
1093 void FSD_Archive::SetRefSectionSize(const Standard_Integer aSize)
1095 Standard_Boolean errorStatus = Standard_False;
1097 (*myStream) << aSize;
1099 CATCH(CArchiveException,e) {
1100 errorStatus = Standard_True;
1105 Storage_StreamWriteError::Raise();
1108 void FSD_Archive::WriteReferenceType(const Standard_Integer reference,
1109 const Standard_Integer typeNum)
1111 Standard_Boolean errorStatus = Standard_False;
1113 (*myStream) << reference << typeNum;
1115 CATCH(CArchiveException,e) {
1116 errorStatus = Standard_True;
1121 Storage_StreamWriteError::Raise();
1124 Storage_Error FSD_Archive::EndWriteRefSection()
1126 Standard_Boolean errorStatus = Standard_False;
1128 //(*myStream) << "END_REF_SECTION" << '\0';
1129 WriteLine(TCollection_AsciiString("END_REF_SECTION"));
1131 CATCH(CArchiveException,e) {
1132 errorStatus = Standard_True;
1136 if (errorStatus) Storage_StreamWriteError::Raise();
1137 return Storage_VSOk;
1140 // ----------------------- REF : READ
1142 Storage_Error FSD_Archive::BeginReadRefSection()
1144 return FindTag("BEGIN_REF_SECTION");
1147 Standard_Integer FSD_Archive::RefSectionSize()
1149 Standard_Integer i = 0;
1150 Standard_Boolean errorStatus = Standard_False;
1154 CATCH(CArchiveException,e) {
1155 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1156 else errorStatus = Standard_True;
1160 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
1164 void FSD_Archive::ReadReferenceType(Standard_Integer& reference,
1165 Standard_Integer& typeNum)
1167 Standard_Boolean errorStatus = Standard_False;
1169 (*myStream) >> reference;
1170 (*myStream) >> typeNum;
1172 CATCH(CArchiveException,e) {
1173 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1174 else errorStatus = Standard_True;
1179 Storage_StreamTypeMismatchError::Raise();
1182 Storage_Error FSD_Archive::EndReadRefSection()
1184 return FindTag("END_REF_SECTION");
1187 // -------------------- DATA : WRITE
1189 Storage_Error FSD_Archive::BeginWriteDataSection()
1191 Standard_Boolean errorStatus = Standard_False;
1193 //(*myStream) << "BEGIN_DATA_SECTION" << '\0';
1194 WriteLine(TCollection_AsciiString("BEGIN_DATA_SECTION"));
1196 CATCH(CArchiveException,e) {
1197 errorStatus = Standard_True;
1201 if (errorStatus) Storage_StreamWriteError::Raise();
1202 return Storage_VSOk;
1205 void FSD_Archive::WritePersistentObjectHeader(const Standard_Integer aRef,
1206 const Standard_Integer aType)
1208 Standard_Boolean errorStatus = Standard_False;
1210 (*myStream) << aRef << aType;
1212 CATCH(CArchiveException,e) {
1213 errorStatus = Standard_True;
1218 Storage_StreamWriteError::Raise();
1221 void FSD_Archive::BeginWritePersistentObjectData()
1225 void FSD_Archive::BeginWriteObjectData()
1229 void FSD_Archive::EndWriteObjectData()
1233 void FSD_Archive::EndWritePersistentObjectData()
1238 Storage_Error FSD_Archive::EndWriteDataSection()
1240 Standard_Boolean errorStatus = Standard_False;
1242 //(*myStream) << "END_DATA_SECTION" << '\0';
1243 WriteLine(TCollection_AsciiString("END_DATA_SECTION"));
1245 CATCH(CArchiveException,e) {
1246 errorStatus = Standard_True;
1250 if (errorStatus) Storage_StreamWriteError::Raise();
1251 return Storage_VSOk;
1254 // ---------------------- DATA : READ
1256 Storage_Error FSD_Archive::BeginReadDataSection()
1258 return FindTag("BEGIN_DATA_SECTION");
1261 void FSD_Archive::ReadPersistentObjectHeader(Standard_Integer& aRef, Standard_Integer& aType)
1263 Standard_Boolean errorStatus = Standard_False;
1265 (*myStream) >> aRef;
1266 (*myStream) >> aType;
1268 CATCH(CArchiveException,e) {
1269 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1270 else errorStatus = Standard_True;
1275 Storage_StreamTypeMismatchError::Raise();
1278 void FSD_Archive::BeginReadPersistentObjectData()
1282 void FSD_Archive::BeginReadObjectData()
1286 void FSD_Archive::EndReadObjectData()
1290 void FSD_Archive::EndReadPersistentObjectData()
1294 (*myStream) >> theEnd;
1296 if (theEnd != 'E') {
1297 Storage_StreamFormatError::Raise();
1301 Storage_Error FSD_Archive::EndReadDataSection()
1303 return FindTag("END_DATA_SECTION");
1306 Storage_Position FSD_Archive::Tell()
1308 return 0; //just a stub