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;
37 if (myStream->IsLoading()) SetOpenMode(Storage_VSRead);
38 else SetOpenMode(Storage_VSWrite);
42 Storage_Error FSD_Archive::IsGoodFileType(const TCollection_AsciiString&
51 s = f.Open(aName,Storage_VSRead);
53 if (s == Storage_VSOk) {
54 TCollection_AsciiString l;
55 Standard_Integer len = strlen(FSD_Archive::MagicNumber());
61 if (strncmp(FSD_Archive::MagicNumber(),l.ToCString(),len) != 0) {
62 s = Storage_VSFormatError;
66 s = Storage_VSFormatError;
71 Storage_Error FSD_Archive::Open(const TCollection_AsciiString& aName,
72 const Storage_OpenMode
78 Storage_Error result = Storage_VSOk;
82 if (OpenMode() == Storage_VSNone) {
83 if (aMode == Storage_VSRead) {
84 if (!((FSD_CFile*)myCFile)->Open(aName.ToCString(),CFile::modeRead))
85 result = Storage_VSOpenError;
87 else if (aMode == Storage_VSWrite) {
88 if (!((FSD_CFile*)myCFile)->Open(aName.ToCString(),CFile::modeCreate | CFile::modeWrite))
89 result = Storage_VSOpenError;
91 else if (aMode == Storage_VSReadWrite) {
92 if (!((FSD_CFile*)myCFile)->Open(aName.ToCString(),CFile::modeReadWrite))
93 result = Storage_VSOpenError;
95 if (result == Storage_VSOk) {
96 if (aMode == Storage_VSRead) {
97 myStream = new CArchive( ((FSD_CFile*)myCFile), CArchive::load);
100 myStream = new CArchive( ((FSD_CFile*)myCFile), CArchive::store);
106 myEof = Standard_False;
110 result = Storage_VSAlreadyOpen;
113 result = Storage_VSOpenError;
118 Standard_Boolean FSD_Archive::IsEnd()
123 Storage_Error FSD_Archive::Close()
125 Storage_Error result = Storage_VSOk;
127 myEof = Standard_False;
129 if (OpenMode() != Storage_VSNone) {
133 ((FSD_CFile*)myCFile)->Close();
136 myExternFlag = Standard_False;
138 SetOpenMode(Storage_VSNone);
142 result = Storage_VSNotOpen;
148 // ------------------ PROTECTED
150 const Standard_CString FSD_Archive::MagicNumber()
156 void FSD_Archive::ReadLine(TCollection_AsciiString&
165 Standard_Boolean IsEnd = Standard_False;
177 IsEnd = Standard_True;
181 CATCH(CArchiveException,e) {
182 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
188 void FSD_Archive::WriteLine(const TCollection_AsciiString&
196 for (i = 1; i <= buffer.Length(); i++) {
197 (*myStream) << buffer.Value(i);
199 (*myStream) << (Standard_Character)0;
203 void FSD_Archive::WriteExtendedLine(const TCollection_ExtendedString&
210 Standard_ExtString extBuffer;
213 extBuffer = buffer.ToExtString();
215 for (i = 0; i < buffer.Length(); i++) {
216 (*myStream) << extBuffer[i];
219 (*myStream) << (Standard_ExtCharacter)0;
223 void FSD_Archive::ReadExtendedLine(TCollection_ExtendedString&
231 Standard_ExtCharacter i = 0;
232 Standard_Boolean fin = Standard_False;
238 if (i == 0) fin = Standard_True;
239 else buffer += (Standard_ExtCharacter)i;
242 CATCH(CArchiveException,e) {
243 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
249 void FSD_Archive::ReadChar(TCollection_AsciiString&
253 ,const Standard_Integer
262 Standard_Integer ccount = 0;
266 while (ccount < rsize) {
272 CATCH(CArchiveException,e) {
273 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
280 Storage_Error FSD_Archive::FindTag(const Standard_CString
287 TCollection_AsciiString l;
288 Standard_CString str;
293 Standard_Integer aNum = 0;
298 while ((strcmp(&str[aNum],aTag) != 0) && !IsEnd()) {
299 // while ((strcmp(&str[1],aTag) != 0) && !IsEnd()) {
305 return Storage_VSSectionNotFound;
311 return Storage_VSSectionNotFound;
315 void FSD_Archive::SkipObject()
318 Standard_Boolean errorStatus = Standard_False;
321 Standard_Boolean IsEnd = Standard_False;
322 Standard_Integer rtmp,itmp;
324 Standard_ShortReal stmp;
325 Standard_Integer btmp;
326 Standard_Character ctmp;
327 Standard_ExtCharacter etmp;
329 ReadPersistentObjectHeader(rtmp,itmp);
357 IsEnd = Standard_True;
360 errorStatus = Standard_True;
361 IsEnd = Standard_True;
366 CATCH(CArchiveException,e) {
367 if ((e->m_cause != CArchiveException::endOfFile) &&
368 (e->m_cause != CArchiveException::none)) errorStatus = Standard_True;
369 else if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
375 // ---------------------- PUBLIC : PUT
377 Storage_BaseDriver& FSD_Archive::PutReference(const Standard_Integer
384 Standard_Boolean errorStatus = Standard_False;
387 (*myStream) << FSD_REF << aValue;
389 CATCH(CArchiveException,e) {
390 errorStatus = Standard_True;
394 if (errorStatus) Storage_StreamWriteError::Raise();
399 Storage_BaseDriver& FSD_Archive::PutCharacter(const Standard_Character
406 Standard_Boolean errorStatus = Standard_False;
409 //unsigned short i = aValue;
410 //(*myStream) << FSD_CHA << i;
411 (*myStream) << FSD_CHA << aValue;
413 CATCH(CArchiveException,e) {
414 errorStatus = Standard_True;
418 if (errorStatus) Storage_StreamWriteError::Raise();
423 Storage_BaseDriver& FSD_Archive::PutExtCharacter(const Standard_ExtCharacter
430 Standard_Boolean errorStatus = Standard_False;
432 (*myStream) << FSD_EXT << aValue;
434 CATCH(CArchiveException,e) {
435 errorStatus = Standard_True;
439 if (errorStatus) Storage_StreamWriteError::Raise();
444 Storage_BaseDriver& FSD_Archive::PutInteger(const Standard_Integer
451 Standard_Boolean errorStatus = Standard_False;
453 (*myStream) << FSD_INT << aValue;
455 CATCH(CArchiveException,e) {
456 errorStatus = Standard_True;
460 if (errorStatus) Storage_StreamWriteError::Raise();
465 Storage_BaseDriver& FSD_Archive::PutBoolean(const Standard_Boolean
472 Standard_Boolean errorStatus = Standard_False;
474 (*myStream) << FSD_BOO << ((Standard_Integer)aValue);
476 CATCH(CArchiveException,e) {
477 errorStatus = Standard_True;
481 if (errorStatus) Storage_StreamWriteError::Raise();
486 Storage_BaseDriver& FSD_Archive::PutReal(const Standard_Real
493 Standard_Boolean errorStatus = Standard_False;
495 (*myStream) << FSD_REA << ((Standard_Real)aValue);
497 CATCH(CArchiveException,e) {
498 errorStatus = Standard_True;
502 if (errorStatus) Storage_StreamWriteError::Raise();
507 Storage_BaseDriver& FSD_Archive::PutShortReal(const Standard_ShortReal
514 Standard_Boolean errorStatus = Standard_False;
516 (*myStream) << FSD_SHO << aValue;
518 CATCH(CArchiveException,e) {
519 errorStatus = Standard_True;
523 if (errorStatus) Storage_StreamWriteError::Raise();
528 // ----------------- PUBLIC : GET
530 Storage_BaseDriver& FSD_Archive::GetReference(Standard_Integer&
537 Standard_Boolean errorStatus = Standard_False;
540 (*myStream) >> ptype;
541 if (ptype == FSD_REF)
542 (*myStream) >> aValue;
543 else errorStatus = Standard_True;
545 CATCH(CArchiveException,e) {
546 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
547 else errorStatus = Standard_True;
551 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
556 Storage_BaseDriver& FSD_Archive::GetCharacter(Standard_Character&
563 Standard_Boolean errorStatus = Standard_False;
566 Standard_Character i;
568 (*myStream) >> ptype;
569 if (ptype == FSD_CHA) {
573 else errorStatus = Standard_True;
575 CATCH(CArchiveException,e) {
576 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
577 else errorStatus = Standard_True;
581 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
586 Storage_BaseDriver& FSD_Archive::GetExtCharacter(Standard_ExtCharacter&
593 Standard_Boolean errorStatus = Standard_False;
596 (*myStream) >> ptype;
597 if (ptype == FSD_EXT)
598 (*myStream) >> aValue;
599 else errorStatus = Standard_True;
601 CATCH(CArchiveException,e) {
602 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
603 else errorStatus = Standard_True;
607 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
612 Storage_BaseDriver& FSD_Archive::GetInteger(Standard_Integer&
619 Standard_Boolean errorStatus = Standard_False;
622 (*myStream) >> ptype;
623 if (ptype == FSD_INT)
624 (*myStream) >> aValue;
625 else errorStatus = Standard_True;
627 CATCH(CArchiveException,e) {
628 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
629 else errorStatus = Standard_True;
633 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
638 Storage_BaseDriver& FSD_Archive::GetBoolean(Standard_Boolean&
645 Standard_Boolean errorStatus = Standard_False;
648 (*myStream) >> ptype;
649 if (ptype == FSD_BOO)
650 (*myStream) >> aValue;
651 else errorStatus = Standard_True;
653 CATCH(CArchiveException,e) {
654 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
655 else errorStatus = Standard_True;
659 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
664 Storage_BaseDriver& FSD_Archive::GetReal(Standard_Real&
671 Standard_Boolean errorStatus = Standard_False;
674 (*myStream) >> ptype;
675 if (ptype == FSD_REA)
676 (*myStream) >> aValue;
677 else errorStatus = Standard_True;
679 CATCH(CArchiveException,e) {
680 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
681 else errorStatus = Standard_True;
685 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
690 Storage_BaseDriver& FSD_Archive::GetShortReal(Standard_ShortReal&
697 Standard_Boolean errorStatus = Standard_False;
700 (*myStream) >> ptype;
701 if (ptype == FSD_SHO)
702 (*myStream) >> aValue;
703 else errorStatus = Standard_True;
705 CATCH(CArchiveException,e) {
706 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
707 else errorStatus = Standard_True;
711 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
716 // -------------------------- DESTROY
718 void FSD_Archive::Destroy()
720 if (OpenMode() != Storage_VSNone) {
723 delete ((FSD_CFile*)myCFile);
730 // -------------------------- INFO : WRITE
732 Storage_Error FSD_Archive::BeginWriteInfoSection()
735 Standard_Boolean errorStatus = Standard_False;
737 //(*myStream) << FSD_Archive::MagicNumber();
738 WriteLine(TCollection_AsciiString(FSD_Archive::MagicNumber()));
739 //(*myStream) << "BEGIN_INFO_SECTION" << '\0';
740 WriteLine(TCollection_AsciiString("BEGIN_INFO_SECTION"));
742 CATCH(CArchiveException,e) {
743 errorStatus = Standard_True;
747 if (errorStatus) Storage_StreamWriteError::Raise();
749 Storage_StreamWriteError::Raise();
754 void FSD_Archive::WriteInfo(const Standard_Integer
758 ,const TCollection_AsciiString&
762 ,const TCollection_AsciiString&
766 ,const TCollection_AsciiString&
770 ,const TCollection_AsciiString&
774 ,const TCollection_ExtendedString&
778 ,const TCollection_AsciiString&
782 ,const TCollection_ExtendedString&
786 ,const TColStd_SequenceOfAsciiString&
793 Standard_Boolean errorStatus = Standard_False;
797 (*myStream) << nbObj;
798 //(*myStream) << dbVersion.ToCString() << '\0';
799 WriteLine(dbVersion);
800 //(*myStream) << date.ToCString() << '\0';
802 //(*myStream) << schemaName.ToCString() << '\0';
803 WriteLine(schemaName);
804 //(*myStream) << schemaVersion.ToCString() << '\0';
805 WriteLine(schemaVersion);
806 WriteExtendedLine(appName);
807 //(*myStream) << appVersion.ToCString() << '\0';
808 WriteLine(appVersion);
809 WriteExtendedLine(dataType);
810 (*myStream) << userInfo.Length();
812 for (i = 1; i <= userInfo.Length(); i++) {
813 //(*myStream) << userInfo.Value(i).ToCString() << '\0';
814 WriteLine(userInfo.Value(i));
817 CATCH(CArchiveException,e) {
818 errorStatus = Standard_True;
822 if (errorStatus) Storage_StreamWriteError::Raise();
824 Storage_StreamWriteError::Raise();
829 Storage_Error FSD_Archive::EndWriteInfoSection()
832 Standard_Boolean errorStatus = Standard_False;
834 //(*myStream) << "END_INFO_SECTION" << '\0';
835 WriteLine(TCollection_AsciiString("END_INFO_SECTION"));
837 CATCH(CArchiveException,e) {
838 errorStatus = Standard_True;
842 if (errorStatus) Storage_StreamWriteError::Raise();
844 Storage_StreamWriteError::Raise();
849 Storage_Error FSD_Archive::BeginReadInfoSection()
853 TCollection_AsciiString l;
854 Standard_Integer len = strlen(FSD_Archive::MagicNumber());
856 // first character is length of the magic number
859 if(l.ToCString()[0] != (Standard_Character) len)
860 myFormat = Standard_True;
863 TCollection_AsciiString ll;
869 if (strncmp(FSD_Archive::MagicNumber(),l.ToCString(),len) != 0) {
870 s = Storage_VSFormatError;
873 s = FindTag("BEGIN_INFO_SECTION");
876 s = Storage_VSFormatError;
881 // ------------------- INFO : READ
883 void FSD_Archive::ReadInfo(Standard_Integer&
887 ,TCollection_AsciiString&
891 ,TCollection_AsciiString&
895 ,TCollection_AsciiString&
899 ,TCollection_AsciiString&
903 ,TCollection_ExtendedString&
907 ,TCollection_AsciiString&
911 ,TCollection_ExtendedString&
915 ,TColStd_SequenceOfAsciiString&
922 Standard_Boolean errorStatus = Standard_False;
924 (*myStream) >> nbObj;
928 ReadLine(schemaName);
929 ReadLine(schemaVersion);
930 ReadExtendedLine(appName);
931 ReadLine(appVersion);
932 ReadExtendedLine(dataType);
934 Standard_Integer i,len = 0;
938 TCollection_AsciiString line;
940 for (i = 1; i <= len && !IsEnd(); i++) {
942 userInfo.Append(line);
946 CATCH(CArchiveException,e) {
947 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
948 else errorStatus = Standard_True;
954 Storage_StreamTypeMismatchError::Raise();
957 Storage_Error FSD_Archive::EndReadInfoSection()
959 return FindTag("END_INFO_SECTION");
962 // ---------------- COMMENTS : WRITE
964 Storage_Error FSD_Archive::BeginWriteCommentSection()
967 Standard_Boolean errorStatus = Standard_False;
969 //(*myStream) << "BEGIN_COMMENT_SECTION" << '\0';
970 WriteLine(TCollection_AsciiString("BEGIN_COMMENT_SECTION"));
972 CATCH(CArchiveException,e) {
973 errorStatus = Standard_True;
977 if (errorStatus) Storage_StreamWriteError::Raise();
979 Storage_StreamWriteError::Raise();
984 void FSD_Archive::WriteComment(const TColStd_SequenceOfExtendedString&
991 Standard_Boolean errorStatus = Standard_False;
993 Standard_Integer i,aSize;
995 aSize = aCom.Length();
996 (*myStream) << aSize;
997 for (i = 1; i <= aSize; i++) {
998 WriteExtendedLine(aCom.Value(i));
1001 CATCH(CArchiveException,e) {
1002 errorStatus = Standard_True;
1008 Storage_StreamWriteError::Raise();
1011 Storage_Error FSD_Archive::EndWriteCommentSection()
1014 Standard_Boolean errorStatus = Standard_False;
1016 //(*myStream) << "END_COMMENT_SECTION" << '\0';
1017 WriteLine(TCollection_AsciiString("END_COMMENT_SECTION"));
1019 CATCH(CArchiveException,e) {
1020 errorStatus = Standard_True;
1024 if (errorStatus) Storage_StreamWriteError::Raise();
1026 Storage_StreamWriteError::Raise();
1028 return Storage_VSOk;
1031 // ---------------- COMMENTS : READ
1033 Storage_Error FSD_Archive::BeginReadCommentSection()
1035 return FindTag("BEGIN_COMMENT_SECTION");
1038 void FSD_Archive::ReadComment(TColStd_SequenceOfExtendedString&
1045 Standard_Boolean errorStatus = Standard_False;
1047 TCollection_ExtendedString line;
1048 Standard_Integer len,i;
1052 for (i = 1; i <= len && !IsEnd(); i++) {
1053 ReadExtendedLine(line);
1058 CATCH(CArchiveException,e) {
1059 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1060 else errorStatus = Standard_True;
1066 Storage_StreamTypeMismatchError::Raise();
1069 Storage_Error FSD_Archive::EndReadCommentSection()
1071 return FindTag("END_COMMENT_SECTION");
1074 // --------------- TYPE : WRITE
1076 Storage_Error FSD_Archive::BeginWriteTypeSection()
1079 Standard_Boolean errorStatus = Standard_False;
1081 //(*myStream) << "BEGIN_TYPE_SECTION" << '\0';
1082 WriteLine(TCollection_AsciiString("BEGIN_TYPE_SECTION"));
1084 CATCH(CArchiveException,e) {
1085 errorStatus = Standard_True;
1089 if (errorStatus) Storage_StreamWriteError::Raise();
1091 Storage_StreamWriteError::Raise();
1093 return Storage_VSOk;
1096 void FSD_Archive::SetTypeSectionSize(const Standard_Integer
1103 Standard_Boolean errorStatus = Standard_False;
1105 (*myStream) << aSize;
1107 CATCH(CArchiveException,e) {
1108 errorStatus = Standard_True;
1114 Storage_StreamWriteError::Raise();
1117 void FSD_Archive::WriteTypeInformations(const Standard_Integer
1121 ,const TCollection_AsciiString&
1128 Standard_Boolean errorStatus = Standard_False;
1130 //(*myStream) << typeNum << typeName.ToCString() << '\0';
1131 (*myStream) << typeNum;
1132 WriteLine(typeName);
1134 CATCH(CArchiveException,e) {
1135 errorStatus = Standard_True;
1141 Storage_StreamWriteError::Raise();
1144 Storage_Error FSD_Archive::EndWriteTypeSection()
1147 Standard_Boolean errorStatus = Standard_False;
1149 //(*myStream) << "END_TYPE_SECTION" << '\0';
1150 WriteLine(TCollection_AsciiString("END_TYPE_SECTION"));
1152 CATCH(CArchiveException,e) {
1153 errorStatus = Standard_True;
1157 if (errorStatus) Storage_StreamWriteError::Raise();
1159 Storage_StreamWriteError::Raise();
1161 return Storage_VSOk;
1164 // ------------------- TYPE : READ
1166 Storage_Error FSD_Archive::BeginReadTypeSection()
1168 return FindTag("BEGIN_TYPE_SECTION");
1171 Standard_Integer FSD_Archive::TypeSectionSize()
1173 Standard_Integer i = 0;
1175 Standard_Boolean errorStatus = Standard_False;
1179 CATCH(CArchiveException,e) {
1180 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1181 else errorStatus = Standard_True;
1185 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
1187 Storage_StreamTypeMismatchError::Raise();
1192 void FSD_Archive::ReadTypeInformations(Standard_Integer&
1196 ,TCollection_AsciiString&
1203 Standard_Boolean errorStatus = Standard_False;
1206 (*myStream) >> typeNum;
1209 TCollection_AsciiString tn;
1210 typeName = (Standard_Character) c;
1217 CATCH(CArchiveException,e) {
1218 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1219 else errorStatus = Standard_True;
1225 Storage_StreamTypeMismatchError::Raise();
1228 Storage_Error FSD_Archive::EndReadTypeSection()
1230 return FindTag("END_TYPE_SECTION");
1233 // -------------------- ROOT : WRITE
1235 Storage_Error FSD_Archive::BeginWriteRootSection()
1238 Standard_Boolean errorStatus = Standard_False;
1240 //(*myStream) << "BEGIN_ROOT_SECTION" << '\0';
1241 WriteLine(TCollection_AsciiString("BEGIN_ROOT_SECTION"));
1243 CATCH(CArchiveException,e) {
1244 errorStatus = Standard_True;
1248 if (errorStatus) Storage_StreamWriteError::Raise();
1250 Storage_StreamWriteError::Raise();
1252 return Storage_VSOk;
1255 void FSD_Archive::SetRootSectionSize(const Standard_Integer
1262 Standard_Boolean errorStatus = Standard_False;
1264 (*myStream) << aSize;
1266 CATCH(CArchiveException,e) {
1267 errorStatus = Standard_True;
1273 Storage_StreamWriteError::Raise();
1276 void FSD_Archive::WriteRoot(const TCollection_AsciiString&
1280 ,const Standard_Integer
1284 ,const TCollection_AsciiString&
1291 Standard_Boolean errorStatus = Standard_False;
1293 //(*myStream) << aRef << rootName.ToCString() << '\0' << rootType.ToCString() << '\0';
1294 (*myStream) << aRef;
1295 WriteLine(rootName);
1296 WriteLine(rootType);
1299 CATCH(CArchiveException,e) {
1300 errorStatus = Standard_True;
1306 Storage_StreamWriteError::Raise();
1309 Storage_Error FSD_Archive::EndWriteRootSection()
1312 Standard_Boolean errorStatus = Standard_False;
1314 //(*myStream) << "END_ROOT_SECTION" << '\0';
1315 WriteLine(TCollection_AsciiString("END_ROOT_SECTION"));
1317 CATCH(CArchiveException,e) {
1318 errorStatus = Standard_True;
1322 if (errorStatus) Storage_StreamWriteError::Raise();
1324 Storage_StreamWriteError::Raise();
1326 return Storage_VSOk;
1329 // ----------------------- ROOT : READ
1331 Storage_Error FSD_Archive::BeginReadRootSection()
1333 return FindTag("BEGIN_ROOT_SECTION");
1336 Standard_Integer FSD_Archive::RootSectionSize()
1338 Standard_Integer i = 0;
1340 Standard_Boolean errorStatus = Standard_False;
1344 CATCH(CArchiveException,e) {
1345 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1346 else errorStatus = Standard_True;
1350 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
1352 Storage_StreamTypeMismatchError::Raise();
1357 void FSD_Archive::ReadRoot(TCollection_AsciiString&
1365 ,TCollection_AsciiString&
1372 Standard_Boolean errorStatus = Standard_False;
1374 (*myStream) >> aRef;
1378 CATCH(CArchiveException,e) {
1379 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1380 else errorStatus = Standard_True;
1386 Storage_StreamTypeMismatchError::Raise();
1389 Storage_Error FSD_Archive::EndReadRootSection()
1391 return FindTag("END_ROOT_SECTION");
1394 // -------------------------- REF : WRITE
1396 Storage_Error FSD_Archive::BeginWriteRefSection()
1399 Standard_Boolean errorStatus = Standard_False;
1401 //(*myStream) << "BEGIN_REF_SECTION" << '\0';
1402 WriteLine(TCollection_AsciiString("BEGIN_REF_SECTION"));
1404 CATCH(CArchiveException,e) {
1405 errorStatus = Standard_True;
1409 if (errorStatus) Storage_StreamWriteError::Raise();
1411 Storage_StreamWriteError::Raise();
1413 return Storage_VSOk;
1416 void FSD_Archive::SetRefSectionSize(const Standard_Integer
1423 Standard_Boolean errorStatus = Standard_False;
1425 (*myStream) << aSize;
1427 CATCH(CArchiveException,e) {
1428 errorStatus = Standard_True;
1434 Storage_StreamWriteError::Raise();
1437 void FSD_Archive::WriteReferenceType(const Standard_Integer
1441 ,const Standard_Integer
1448 Standard_Boolean errorStatus = Standard_False;
1450 (*myStream) << reference << typeNum;
1452 CATCH(CArchiveException,e) {
1453 errorStatus = Standard_True;
1459 Storage_StreamWriteError::Raise();
1462 Storage_Error FSD_Archive::EndWriteRefSection()
1465 Standard_Boolean errorStatus = Standard_False;
1467 //(*myStream) << "END_REF_SECTION" << '\0';
1468 WriteLine(TCollection_AsciiString("END_REF_SECTION"));
1470 CATCH(CArchiveException,e) {
1471 errorStatus = Standard_True;
1475 if (errorStatus) Storage_StreamWriteError::Raise();
1477 Storage_StreamWriteError::Raise();
1479 return Storage_VSOk;
1482 // ----------------------- REF : READ
1484 Storage_Error FSD_Archive::BeginReadRefSection()
1486 return FindTag("BEGIN_REF_SECTION");
1489 Standard_Integer FSD_Archive::RefSectionSize()
1491 Standard_Integer i = 0;
1493 Standard_Boolean errorStatus = Standard_False;
1497 CATCH(CArchiveException,e) {
1498 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1499 else errorStatus = Standard_True;
1503 if (errorStatus) Storage_StreamTypeMismatchError::Raise();
1505 Storage_StreamTypeMismatchError::Raise();
1510 void FSD_Archive::ReadReferenceType(Standard_Integer&
1521 Standard_Boolean errorStatus = Standard_False;
1523 (*myStream) >> reference;
1524 (*myStream) >> typeNum;
1526 CATCH(CArchiveException,e) {
1527 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1528 else errorStatus = Standard_True;
1534 Storage_StreamTypeMismatchError::Raise();
1537 Storage_Error FSD_Archive::EndReadRefSection()
1539 return FindTag("END_REF_SECTION");
1542 // -------------------- DATA : WRITE
1544 Storage_Error FSD_Archive::BeginWriteDataSection()
1547 Standard_Boolean errorStatus = Standard_False;
1549 //(*myStream) << "BEGIN_DATA_SECTION" << '\0';
1550 WriteLine(TCollection_AsciiString("BEGIN_DATA_SECTION"));
1552 CATCH(CArchiveException,e) {
1553 errorStatus = Standard_True;
1557 if (errorStatus) Storage_StreamWriteError::Raise();
1559 Storage_StreamWriteError::Raise();
1561 return Storage_VSOk;
1564 void FSD_Archive::WritePersistentObjectHeader(const Standard_Integer
1568 ,const Standard_Integer
1575 Standard_Boolean errorStatus = Standard_False;
1577 (*myStream) << aRef << aType;
1579 CATCH(CArchiveException,e) {
1580 errorStatus = Standard_True;
1586 Storage_StreamWriteError::Raise();
1589 void FSD_Archive::BeginWritePersistentObjectData()
1593 void FSD_Archive::BeginWriteObjectData()
1597 void FSD_Archive::EndWriteObjectData()
1601 void FSD_Archive::EndWritePersistentObjectData()
1608 Storage_Error FSD_Archive::EndWriteDataSection()
1611 Standard_Boolean errorStatus = Standard_False;
1613 //(*myStream) << "END_DATA_SECTION" << '\0';
1614 WriteLine(TCollection_AsciiString("END_DATA_SECTION"));
1616 CATCH(CArchiveException,e) {
1617 errorStatus = Standard_True;
1621 if (errorStatus) Storage_StreamWriteError::Raise();
1623 Storage_StreamWriteError::Raise();
1625 return Storage_VSOk;
1628 // ---------------------- DATA : READ
1630 Storage_Error FSD_Archive::BeginReadDataSection()
1632 return FindTag("BEGIN_DATA_SECTION");
1635 void FSD_Archive::ReadPersistentObjectHeader(Standard_Integer&
1646 Standard_Boolean errorStatus = Standard_False;
1648 (*myStream) >> aRef;
1649 (*myStream) >> aType;
1651 CATCH(CArchiveException,e) {
1652 if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True;
1653 else errorStatus = Standard_True;
1659 Storage_StreamTypeMismatchError::Raise();
1662 void FSD_Archive::BeginReadPersistentObjectData()
1666 void FSD_Archive::BeginReadObjectData()
1670 void FSD_Archive::EndReadObjectData()
1674 void FSD_Archive::EndReadPersistentObjectData()
1679 (*myStream) >> theEnd;
1681 if (theEnd != 'E') {
1682 Storage_StreamFormatError::Raise();
1687 Storage_Error FSD_Archive::EndReadDataSection()
1689 return FindTag("END_DATA_SECTION");
1692 Storage_Position FSD_Archive::Tell()
1694 return 0; //just a stub