7fd59977 |
1 | |
2 | #include "stdafx.h" |
3 | |
4 | #include "FSD_CArchive.hxx" |
5 | #include "FSD_Archive.ixx" |
6 | |
7 | #include <FSD_CFile.hxx> |
8 | |
9 | #define FSD_REF 'R' |
10 | #define FSD_CHA 'c' |
11 | #define FSD_EXT 'C' |
12 | #define FSD_INT 'I' |
13 | #define FSD_BOO 'B' |
14 | #define FSD_REA 'F' |
15 | #define FSD_SHO 'f' |
16 | #define FSD_END 'E' |
17 | |
18 | const Standard_CString MAGICNUMBER = "FSDARCH"; |
19 | |
20 | FSD_Archive::FSD_Archive() |
21 | { |
22 | myStream = NULL; |
23 | myEof = Standard_False; |
24 | myExternFlag = Standard_False; |
25 | myCFile = NULL; |
26 | myFormat = Standard_False; |
27 | } |
28 | |
29 | FSD_Archive::FSD_Archive(const FSD_CArchive& anArchive) |
30 | { |
31 | myStream = anArchive; |
32 | myEof = Standard_False; |
33 | myExternFlag = Standard_True; |
34 | myCFile = NULL; |
35 | myFormat = Standard_False; |
7fd59977 |
36 | if (myStream->IsLoading()) SetOpenMode(Storage_VSRead); |
37 | else SetOpenMode(Storage_VSWrite); |
7fd59977 |
38 | } |
39 | |
50fe2dab |
40 | Storage_Error FSD_Archive::IsGoodFileType(const TCollection_AsciiString& aName) |
7fd59977 |
41 | { |
42 | FSD_Archive f; |
43 | Storage_Error s; |
7fd59977 |
44 | s = f.Open(aName,Storage_VSRead); |
45 | |
46 | if (s == Storage_VSOk) { |
47 | TCollection_AsciiString l; |
5c573e69 |
48 | Standard_Integer len = (int)strlen(FSD_Archive::MagicNumber()); |
7fd59977 |
49 | |
50 | f.ReadChar(l,len); |
51 | |
52 | f.Close(); |
53 | |
54 | if (strncmp(FSD_Archive::MagicNumber(),l.ToCString(),len) != 0) { |
55 | s = Storage_VSFormatError; |
56 | } |
57 | } |
7fd59977 |
58 | return s; |
59 | } |
60 | |
576f8b11 |
61 | Storage_Error FSD_Archive::Open(const TCollection_AsciiString& theName, |
50fe2dab |
62 | const Storage_OpenMode aMode) |
7fd59977 |
63 | { |
64 | Storage_Error result = Storage_VSOk; |
576f8b11 |
65 | CString aName = theName.ToCString(); |
66 | SetName (theName); |
7fd59977 |
67 | if (OpenMode() == Storage_VSNone) { |
68 | if (aMode == Storage_VSRead) { |
576f8b11 |
69 | if (!((FSD_CFile*)myCFile)->Open(aName, CFile::modeRead)) |
7fd59977 |
70 | result = Storage_VSOpenError; |
71 | } |
72 | else if (aMode == Storage_VSWrite) { |
576f8b11 |
73 | if (!((FSD_CFile*)myCFile)->Open(aName, CFile::modeCreate | CFile::modeWrite)) |
7fd59977 |
74 | result = Storage_VSOpenError; |
75 | } |
76 | else if (aMode == Storage_VSReadWrite) { |
576f8b11 |
77 | if (!((FSD_CFile*)myCFile)->Open(aName, CFile::modeReadWrite)) |
7fd59977 |
78 | result = Storage_VSOpenError; |
79 | } |
80 | if (result == Storage_VSOk) { |
81 | if (aMode == Storage_VSRead) { |
82 | myStream = new CArchive( ((FSD_CFile*)myCFile), CArchive::load); |
83 | } |
84 | else { |
85 | myStream = new CArchive( ((FSD_CFile*)myCFile), CArchive::store); |
86 | } |
87 | |
88 | SetOpenMode(aMode); |
89 | } |
90 | |
91 | myEof = Standard_False; |
92 | |
93 | } |
94 | else { |
95 | result = Storage_VSAlreadyOpen; |
96 | } |
7fd59977 |
97 | return result; |
98 | } |
99 | |
100 | Standard_Boolean FSD_Archive::IsEnd() |
101 | { |
102 | return myEof; |
103 | } |
104 | |
105 | Storage_Error FSD_Archive::Close() |
106 | { |
107 | Storage_Error result = Storage_VSOk; |
108 | |
109 | myEof = Standard_False; |
110 | |
111 | if (OpenMode() != Storage_VSNone) { |
7fd59977 |
112 | if (!myExternFlag) { |
113 | (*myStream).Close(); |
114 | ((FSD_CFile*)myCFile)->Close(); |
115 | delete myStream; |
116 | } |
117 | myExternFlag = Standard_False; |
118 | myStream = NULL; |
119 | SetOpenMode(Storage_VSNone); |
7fd59977 |
120 | } |
121 | else { |
122 | result = Storage_VSNotOpen; |
123 | } |
124 | |
125 | return result; |
126 | } |
127 | |
128 | // ------------------ PROTECTED |
129 | |
130 | const Standard_CString FSD_Archive::MagicNumber() |
131 | { |
132 | return MAGICNUMBER; |
133 | } |
134 | |
135 | |
50fe2dab |
136 | void FSD_Archive::ReadLine(TCollection_AsciiString& buffer) |
7fd59977 |
137 | { |
7fd59977 |
138 | TRY { |
139 | char c; |
140 | Standard_Boolean IsEnd = Standard_False; |
141 | |
142 | buffer.Clear(); |
143 | |
144 | while (!IsEnd) { |
145 | (*myStream) >> c; |
146 | |
147 | if (c != '\0') { |
148 | buffer += c; |
149 | } |
150 | else { |
151 | buffer += c; |
152 | IsEnd = Standard_True; |
153 | } |
154 | } |
155 | } |
156 | CATCH(CArchiveException,e) { |
157 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
158 | } |
159 | END_CATCH |
7fd59977 |
160 | } |
161 | |
50fe2dab |
162 | void FSD_Archive::WriteLine(const TCollection_AsciiString& buffer) |
7fd59977 |
163 | { |
7fd59977 |
164 | Standard_Integer i; |
165 | for (i = 1; i <= buffer.Length(); i++) { |
166 | (*myStream) << buffer.Value(i); |
167 | } |
168 | (*myStream) << (Standard_Character)0; |
7fd59977 |
169 | } |
170 | |
50fe2dab |
171 | void FSD_Archive::WriteExtendedLine(const TCollection_ExtendedString& buffer) |
7fd59977 |
172 | { |
7fd59977 |
173 | Standard_ExtString extBuffer; |
174 | Standard_Integer i; |
175 | |
176 | extBuffer = buffer.ToExtString(); |
177 | |
178 | for (i = 0; i < buffer.Length(); i++) { |
179 | (*myStream) << extBuffer[i]; |
180 | } |
181 | |
182 | (*myStream) << (Standard_ExtCharacter)0; |
7fd59977 |
183 | } |
184 | |
50fe2dab |
185 | void FSD_Archive::ReadExtendedLine(TCollection_ExtendedString& buffer) |
7fd59977 |
186 | { |
7fd59977 |
187 | TRY { |
188 | Standard_ExtCharacter i = 0; |
189 | Standard_Boolean fin = Standard_False; |
190 | |
191 | buffer.Clear(); |
192 | |
193 | while (!fin) { |
194 | (*myStream) >> i; |
195 | if (i == 0) fin = Standard_True; |
196 | else buffer += (Standard_ExtCharacter)i; |
197 | } |
198 | } |
199 | CATCH(CArchiveException,e) { |
200 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
201 | } |
202 | END_CATCH |
7fd59977 |
203 | } |
204 | |
50fe2dab |
205 | void FSD_Archive::ReadChar(TCollection_AsciiString& buffer, const Standard_Integer rsize) |
7fd59977 |
206 | { |
7fd59977 |
207 | TRY { |
208 | char c; |
209 | Standard_Integer ccount = 0; |
210 | |
211 | buffer.Clear(); |
212 | |
213 | while (ccount < rsize) { |
214 | (*myStream) >> c; |
215 | buffer += c; |
216 | ccount++; |
217 | } |
218 | } |
219 | CATCH(CArchiveException,e) { |
220 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
221 | } |
222 | END_CATCH |
7fd59977 |
223 | } |
224 | |
225 | |
50fe2dab |
226 | Storage_Error FSD_Archive::FindTag(const Standard_CString aTag) |
7fd59977 |
227 | { |
7fd59977 |
228 | TCollection_AsciiString l; |
229 | Standard_CString str; |
230 | |
231 | ReadLine(l); |
232 | str = l.ToCString(); |
233 | |
234 | Standard_Integer aNum = 0; |
235 | |
236 | if(!myFormat) |
237 | aNum = 1; |
238 | |
239 | while ((strcmp(&str[aNum],aTag) != 0) && !IsEnd()) { |
240 | // while ((strcmp(&str[1],aTag) != 0) && !IsEnd()) { |
241 | ReadLine(l); |
242 | str = l.ToCString(); |
243 | } |
244 | |
245 | if (IsEnd()) { |
246 | return Storage_VSSectionNotFound; |
247 | } |
248 | else { |
249 | return Storage_VSOk; |
250 | } |
7fd59977 |
251 | } |
252 | |
253 | void FSD_Archive::SkipObject() |
254 | { |
7fd59977 |
255 | Standard_Boolean errorStatus = Standard_False; |
256 | TRY { |
257 | char c; |
258 | Standard_Boolean IsEnd = Standard_False; |
259 | Standard_Integer rtmp,itmp; |
260 | Standard_Real ftmp; |
261 | Standard_ShortReal stmp; |
262 | Standard_Integer btmp; |
263 | Standard_Character ctmp; |
264 | Standard_ExtCharacter etmp; |
265 | |
266 | ReadPersistentObjectHeader(rtmp,itmp); |
267 | |
268 | while (!IsEnd) { |
269 | (*myStream) >> c; |
270 | |
271 | switch (c) { |
272 | case FSD_REF: |
273 | (*myStream) >> rtmp; |
274 | break; |
275 | case FSD_CHA: |
276 | (*myStream) >> ctmp; |
277 | break; |
278 | case FSD_EXT: |
279 | (*myStream) >> etmp; |
280 | break; |
281 | case FSD_INT: |
282 | (*myStream) >> itmp; |
283 | break; |
284 | case FSD_BOO: |
285 | (*myStream) >> btmp; |
286 | break; |
287 | case FSD_REA: |
288 | (*myStream) >> ftmp; |
289 | break; |
290 | case FSD_SHO: |
291 | (*myStream) >> stmp; |
292 | break; |
293 | case FSD_END: |
294 | IsEnd = Standard_True; |
295 | break; |
296 | default: |
297 | errorStatus = Standard_True; |
298 | IsEnd = Standard_True; |
299 | break; |
300 | } |
301 | } |
302 | } |
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; |
307 | } |
308 | END_CATCH |
7fd59977 |
309 | } |
310 | |
311 | // ---------------------- PUBLIC : PUT |
312 | |
50fe2dab |
313 | Storage_BaseDriver& FSD_Archive::PutReference(const Standard_Integer aValue) |
7fd59977 |
314 | { |
7fd59977 |
315 | Standard_Boolean errorStatus = Standard_False; |
316 | |
317 | TRY { |
318 | (*myStream) << FSD_REF << aValue; |
319 | } |
320 | CATCH(CArchiveException,e) { |
321 | errorStatus = Standard_True; |
322 | } |
323 | END_CATCH |
324 | |
325 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
326 | return *this; |
327 | } |
328 | |
50fe2dab |
329 | Storage_BaseDriver& FSD_Archive::PutCharacter(const Standard_Character aValue) |
7fd59977 |
330 | { |
7fd59977 |
331 | Standard_Boolean errorStatus = Standard_False; |
332 | |
333 | TRY { |
334 | //unsigned short i = aValue; |
335 | //(*myStream) << FSD_CHA << i; |
336 | (*myStream) << FSD_CHA << aValue; |
337 | } |
338 | CATCH(CArchiveException,e) { |
339 | errorStatus = Standard_True; |
340 | } |
341 | END_CATCH |
342 | |
343 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
344 | return *this; |
345 | } |
346 | |
50fe2dab |
347 | Storage_BaseDriver& FSD_Archive::PutExtCharacter(const Standard_ExtCharacter aValue) |
7fd59977 |
348 | { |
7fd59977 |
349 | Standard_Boolean errorStatus = Standard_False; |
350 | TRY { |
351 | (*myStream) << FSD_EXT << aValue; |
352 | } |
353 | CATCH(CArchiveException,e) { |
354 | errorStatus = Standard_True; |
355 | } |
356 | END_CATCH |
357 | |
358 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
359 | return *this; |
360 | } |
361 | |
50fe2dab |
362 | Storage_BaseDriver& FSD_Archive::PutInteger(const Standard_Integer aValue) |
7fd59977 |
363 | { |
7fd59977 |
364 | Standard_Boolean errorStatus = Standard_False; |
365 | TRY { |
366 | (*myStream) << FSD_INT << aValue; |
367 | } |
368 | CATCH(CArchiveException,e) { |
369 | errorStatus = Standard_True; |
370 | } |
371 | END_CATCH |
372 | |
373 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
374 | return *this; |
375 | } |
376 | |
50fe2dab |
377 | Storage_BaseDriver& FSD_Archive::PutBoolean(const Standard_Boolean aValue) |
7fd59977 |
378 | { |
7fd59977 |
379 | Standard_Boolean errorStatus = Standard_False; |
380 | TRY { |
381 | (*myStream) << FSD_BOO << ((Standard_Integer)aValue); |
382 | } |
383 | CATCH(CArchiveException,e) { |
384 | errorStatus = Standard_True; |
385 | } |
386 | END_CATCH |
387 | |
388 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
389 | return *this; |
390 | } |
391 | |
50fe2dab |
392 | Storage_BaseDriver& FSD_Archive::PutReal(const Standard_Real aValue) |
7fd59977 |
393 | { |
7fd59977 |
394 | Standard_Boolean errorStatus = Standard_False; |
395 | TRY { |
396 | (*myStream) << FSD_REA << ((Standard_Real)aValue); |
397 | } |
398 | CATCH(CArchiveException,e) { |
399 | errorStatus = Standard_True; |
400 | } |
401 | END_CATCH |
402 | |
403 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
404 | return *this; |
405 | } |
406 | |
50fe2dab |
407 | Storage_BaseDriver& FSD_Archive::PutShortReal(const Standard_ShortReal aValue) |
7fd59977 |
408 | { |
7fd59977 |
409 | Standard_Boolean errorStatus = Standard_False; |
410 | TRY { |
411 | (*myStream) << FSD_SHO << aValue; |
412 | } |
413 | CATCH(CArchiveException,e) { |
414 | errorStatus = Standard_True; |
415 | } |
416 | END_CATCH |
417 | |
418 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
419 | return *this; |
420 | } |
421 | |
422 | // ----------------- PUBLIC : GET |
423 | |
50fe2dab |
424 | Storage_BaseDriver& FSD_Archive::GetReference(Standard_Integer& aValue) |
7fd59977 |
425 | { |
7fd59977 |
426 | Standard_Boolean errorStatus = Standard_False; |
427 | TRY { |
428 | char ptype; |
429 | (*myStream) >> ptype; |
430 | if (ptype == FSD_REF) |
431 | (*myStream) >> aValue; |
432 | else errorStatus = Standard_True; |
433 | } |
434 | CATCH(CArchiveException,e) { |
435 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
436 | else errorStatus = Standard_True; |
437 | } |
438 | END_CATCH |
439 | |
440 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
441 | return *this; |
442 | } |
443 | |
50fe2dab |
444 | Storage_BaseDriver& FSD_Archive::GetCharacter(Standard_Character& aValue) |
7fd59977 |
445 | { |
7fd59977 |
446 | Standard_Boolean errorStatus = Standard_False; |
447 | TRY { |
448 | //unsigned short i; |
449 | Standard_Character i; |
450 | char ptype; |
451 | (*myStream) >> ptype; |
452 | if (ptype == FSD_CHA) { |
453 | (*myStream) >> i; |
454 | aValue = (char)i; |
455 | } |
456 | else errorStatus = Standard_True; |
457 | } |
458 | CATCH(CArchiveException,e) { |
459 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
460 | else errorStatus = Standard_True; |
461 | } |
462 | END_CATCH |
463 | |
464 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
465 | return *this; |
466 | } |
467 | |
50fe2dab |
468 | Storage_BaseDriver& FSD_Archive::GetExtCharacter(Standard_ExtCharacter& aValue) |
7fd59977 |
469 | { |
7fd59977 |
470 | Standard_Boolean errorStatus = Standard_False; |
471 | TRY { |
472 | char ptype; |
473 | (*myStream) >> ptype; |
474 | if (ptype == FSD_EXT) |
475 | (*myStream) >> aValue; |
476 | else errorStatus = Standard_True; |
477 | } |
478 | CATCH(CArchiveException,e) { |
479 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
480 | else errorStatus = Standard_True; |
481 | } |
482 | END_CATCH |
483 | |
484 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
485 | return *this; |
486 | } |
487 | |
50fe2dab |
488 | Storage_BaseDriver& FSD_Archive::GetInteger(Standard_Integer& aValue) |
7fd59977 |
489 | { |
7fd59977 |
490 | Standard_Boolean errorStatus = Standard_False; |
491 | TRY { |
492 | char ptype; |
493 | (*myStream) >> ptype; |
494 | if (ptype == FSD_INT) |
495 | (*myStream) >> aValue; |
496 | else errorStatus = Standard_True; |
497 | } |
498 | CATCH(CArchiveException,e) { |
499 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
500 | else errorStatus = Standard_True; |
501 | } |
502 | END_CATCH |
503 | |
504 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
505 | return *this; |
506 | } |
507 | |
50fe2dab |
508 | Storage_BaseDriver& FSD_Archive::GetBoolean(Standard_Boolean& aValue) |
7fd59977 |
509 | { |
7fd59977 |
510 | Standard_Boolean errorStatus = Standard_False; |
511 | TRY { |
512 | char ptype; |
513 | (*myStream) >> ptype; |
514 | if (ptype == FSD_BOO) |
515 | (*myStream) >> aValue; |
516 | else errorStatus = Standard_True; |
517 | } |
518 | CATCH(CArchiveException,e) { |
519 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
520 | else errorStatus = Standard_True; |
521 | } |
522 | END_CATCH |
523 | |
524 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
525 | return *this; |
526 | } |
527 | |
50fe2dab |
528 | Storage_BaseDriver& FSD_Archive::GetReal(Standard_Real& aValue) |
7fd59977 |
529 | { |
7fd59977 |
530 | Standard_Boolean errorStatus = Standard_False; |
531 | TRY { |
532 | char ptype; |
533 | (*myStream) >> ptype; |
534 | if (ptype == FSD_REA) |
535 | (*myStream) >> aValue; |
536 | else errorStatus = Standard_True; |
537 | } |
538 | CATCH(CArchiveException,e) { |
539 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
540 | else errorStatus = Standard_True; |
541 | } |
542 | END_CATCH |
543 | |
544 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
545 | return *this; |
546 | } |
547 | |
50fe2dab |
548 | Storage_BaseDriver& FSD_Archive::GetShortReal(Standard_ShortReal& aValue) |
7fd59977 |
549 | { |
7fd59977 |
550 | Standard_Boolean errorStatus = Standard_False; |
551 | TRY { |
552 | char ptype; |
553 | (*myStream) >> ptype; |
554 | if (ptype == FSD_SHO) |
555 | (*myStream) >> aValue; |
556 | else errorStatus = Standard_True; |
557 | } |
558 | CATCH(CArchiveException,e) { |
559 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
560 | else errorStatus = Standard_True; |
561 | } |
562 | END_CATCH |
563 | |
564 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
565 | return *this; |
566 | } |
567 | |
568 | // -------------------------- DESTROY |
569 | |
570 | void FSD_Archive::Destroy() |
571 | { |
572 | if (OpenMode() != Storage_VSNone) { |
573 | Close(); |
574 | if (myCFile) { |
575 | delete ((FSD_CFile*)myCFile); |
576 | myCFile = NULL; |
577 | } |
578 | |
579 | } |
580 | } |
581 | |
582 | // -------------------------- INFO : WRITE |
583 | |
584 | Storage_Error FSD_Archive::BeginWriteInfoSection() |
585 | { |
7fd59977 |
586 | Standard_Boolean errorStatus = Standard_False; |
587 | TRY { |
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")); |
592 | } |
593 | CATCH(CArchiveException,e) { |
594 | errorStatus = Standard_True; |
595 | } |
596 | END_CATCH |
597 | |
598 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
599 | return Storage_VSOk; |
600 | } |
601 | |
50fe2dab |
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) |
611 | { |
7fd59977 |
612 | Standard_Boolean errorStatus = Standard_False; |
613 | TRY { |
614 | Standard_Integer i; |
615 | |
616 | (*myStream) << nbObj; |
617 | //(*myStream) << dbVersion.ToCString() << '\0'; |
618 | WriteLine(dbVersion); |
619 | //(*myStream) << date.ToCString() << '\0'; |
620 | WriteLine(date); |
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(); |
630 | |
631 | for (i = 1; i <= userInfo.Length(); i++) { |
632 | //(*myStream) << userInfo.Value(i).ToCString() << '\0'; |
633 | WriteLine(userInfo.Value(i)); |
634 | } |
635 | } |
636 | CATCH(CArchiveException,e) { |
637 | errorStatus = Standard_True; |
638 | } |
639 | END_CATCH |
640 | |
641 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
642 | } |
643 | |
644 | |
645 | Storage_Error FSD_Archive::EndWriteInfoSection() |
646 | { |
50fe2dab |
647 | |
7fd59977 |
648 | Standard_Boolean errorStatus = Standard_False; |
649 | TRY { |
650 | //(*myStream) << "END_INFO_SECTION" << '\0'; |
651 | WriteLine(TCollection_AsciiString("END_INFO_SECTION")); |
652 | } |
653 | CATCH(CArchiveException,e) { |
654 | errorStatus = Standard_True; |
655 | } |
656 | END_CATCH |
657 | |
658 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
659 | return Storage_VSOk; |
660 | } |
661 | |
662 | Storage_Error FSD_Archive::BeginReadInfoSection() |
663 | { |
664 | Storage_Error s; |
50fe2dab |
665 | |
7fd59977 |
666 | TCollection_AsciiString l; |
5c573e69 |
667 | Standard_Integer len = (int)strlen(FSD_Archive::MagicNumber()); |
7fd59977 |
668 | |
669 | // first character is length of the magic number |
670 | ReadChar(l,1); |
671 | |
672 | if(l.ToCString()[0] != (Standard_Character) len) |
673 | myFormat = Standard_True; |
674 | |
675 | if(myFormat) { |
676 | TCollection_AsciiString ll; |
677 | ReadLine(ll); |
678 | l += ll; |
679 | } else { |
680 | ReadChar(l,len); |
681 | } |
682 | if (strncmp(FSD_Archive::MagicNumber(),l.ToCString(),len) != 0) { |
683 | s = Storage_VSFormatError; |
684 | } |
685 | else { |
686 | s = FindTag("BEGIN_INFO_SECTION"); |
687 | } |
7fd59977 |
688 | return s; |
689 | } |
690 | |
691 | // ------------------- INFO : READ |
692 | |
50fe2dab |
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) |
702 | { |
7fd59977 |
703 | Standard_Boolean errorStatus = Standard_False; |
704 | TRY { |
705 | (*myStream) >> nbObj; |
706 | |
707 | ReadLine(dbVersion); |
708 | ReadLine(date); |
709 | ReadLine(schemaName); |
710 | ReadLine(schemaVersion); |
711 | ReadExtendedLine(appName); |
712 | ReadLine(appVersion); |
713 | ReadExtendedLine(dataType); |
714 | |
715 | Standard_Integer i,len = 0; |
716 | |
717 | (*myStream) >> len; |
718 | |
719 | TCollection_AsciiString line; |
720 | |
721 | for (i = 1; i <= len && !IsEnd(); i++) { |
722 | ReadLine(line); |
723 | userInfo.Append(line); |
724 | line.Clear(); |
725 | } |
726 | } |
727 | CATCH(CArchiveException,e) { |
728 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
729 | else errorStatus = Standard_True; |
730 | } |
731 | END_CATCH |
732 | |
733 | if (errorStatus) |
7fd59977 |
734 | Storage_StreamTypeMismatchError::Raise(); |
735 | } |
736 | |
737 | Storage_Error FSD_Archive::EndReadInfoSection() |
738 | { |
739 | return FindTag("END_INFO_SECTION"); |
740 | } |
741 | |
742 | // ---------------- COMMENTS : WRITE |
743 | |
744 | Storage_Error FSD_Archive::BeginWriteCommentSection() |
745 | { |
7fd59977 |
746 | Standard_Boolean errorStatus = Standard_False; |
747 | TRY { |
748 | //(*myStream) << "BEGIN_COMMENT_SECTION" << '\0'; |
749 | WriteLine(TCollection_AsciiString("BEGIN_COMMENT_SECTION")); |
750 | } |
751 | CATCH(CArchiveException,e) { |
752 | errorStatus = Standard_True; |
753 | } |
754 | END_CATCH |
755 | |
756 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
757 | return Storage_VSOk; |
758 | } |
759 | |
50fe2dab |
760 | void FSD_Archive::WriteComment(const TColStd_SequenceOfExtendedString& aCom) |
7fd59977 |
761 | { |
7fd59977 |
762 | Standard_Boolean errorStatus = Standard_False; |
763 | TRY { |
764 | Standard_Integer i,aSize; |
765 | |
766 | aSize = aCom.Length(); |
767 | (*myStream) << aSize; |
768 | for (i = 1; i <= aSize; i++) { |
769 | WriteExtendedLine(aCom.Value(i)); |
770 | } |
771 | } |
772 | CATCH(CArchiveException,e) { |
773 | errorStatus = Standard_True; |
774 | } |
775 | END_CATCH |
776 | |
777 | if (errorStatus) |
7fd59977 |
778 | Storage_StreamWriteError::Raise(); |
779 | } |
780 | |
781 | Storage_Error FSD_Archive::EndWriteCommentSection() |
782 | { |
7fd59977 |
783 | Standard_Boolean errorStatus = Standard_False; |
784 | TRY { |
785 | //(*myStream) << "END_COMMENT_SECTION" << '\0'; |
786 | WriteLine(TCollection_AsciiString("END_COMMENT_SECTION")); |
787 | } |
788 | CATCH(CArchiveException,e) { |
789 | errorStatus = Standard_True; |
790 | } |
791 | END_CATCH |
792 | |
793 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
794 | return Storage_VSOk; |
795 | } |
796 | |
797 | // ---------------- COMMENTS : READ |
798 | |
799 | Storage_Error FSD_Archive::BeginReadCommentSection() |
800 | { |
801 | return FindTag("BEGIN_COMMENT_SECTION"); |
802 | } |
803 | |
50fe2dab |
804 | void FSD_Archive::ReadComment(TColStd_SequenceOfExtendedString& aCom) |
7fd59977 |
805 | { |
7fd59977 |
806 | Standard_Boolean errorStatus = Standard_False; |
807 | TRY { |
808 | TCollection_ExtendedString line; |
809 | Standard_Integer len,i; |
810 | |
811 | (*myStream) >> len; |
812 | |
813 | for (i = 1; i <= len && !IsEnd(); i++) { |
814 | ReadExtendedLine(line); |
815 | aCom.Append(line); |
816 | line.Clear(); |
817 | } |
818 | } |
819 | CATCH(CArchiveException,e) { |
820 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
821 | else errorStatus = Standard_True; |
822 | } |
823 | END_CATCH |
824 | |
825 | if (errorStatus) |
7fd59977 |
826 | Storage_StreamTypeMismatchError::Raise(); |
827 | } |
828 | |
829 | Storage_Error FSD_Archive::EndReadCommentSection() |
830 | { |
831 | return FindTag("END_COMMENT_SECTION"); |
832 | } |
833 | |
834 | // --------------- TYPE : WRITE |
835 | |
836 | Storage_Error FSD_Archive::BeginWriteTypeSection() |
837 | { |
7fd59977 |
838 | Standard_Boolean errorStatus = Standard_False; |
839 | TRY { |
840 | //(*myStream) << "BEGIN_TYPE_SECTION" << '\0'; |
841 | WriteLine(TCollection_AsciiString("BEGIN_TYPE_SECTION")); |
842 | } |
843 | CATCH(CArchiveException,e) { |
844 | errorStatus = Standard_True; |
845 | } |
846 | END_CATCH |
847 | |
848 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
849 | return Storage_VSOk; |
850 | } |
851 | |
50fe2dab |
852 | void FSD_Archive::SetTypeSectionSize(const Standard_Integer aSize) |
7fd59977 |
853 | { |
7fd59977 |
854 | Standard_Boolean errorStatus = Standard_False; |
855 | TRY { |
856 | (*myStream) << aSize; |
857 | } |
858 | CATCH(CArchiveException,e) { |
859 | errorStatus = Standard_True; |
860 | } |
861 | END_CATCH |
862 | |
863 | if (errorStatus) |
7fd59977 |
864 | Storage_StreamWriteError::Raise(); |
865 | } |
866 | |
50fe2dab |
867 | void FSD_Archive::WriteTypeInformations (const Standard_Integer typeNum, |
868 | const TCollection_AsciiString& typeName) |
7fd59977 |
869 | { |
7fd59977 |
870 | Standard_Boolean errorStatus = Standard_False; |
871 | TRY { |
872 | //(*myStream) << typeNum << typeName.ToCString() << '\0'; |
873 | (*myStream) << typeNum; |
874 | WriteLine(typeName); |
875 | } |
876 | CATCH(CArchiveException,e) { |
877 | errorStatus = Standard_True; |
878 | } |
879 | END_CATCH |
880 | |
881 | if (errorStatus) |
7fd59977 |
882 | Storage_StreamWriteError::Raise(); |
883 | } |
884 | |
885 | Storage_Error FSD_Archive::EndWriteTypeSection() |
886 | { |
7fd59977 |
887 | Standard_Boolean errorStatus = Standard_False; |
888 | TRY { |
889 | //(*myStream) << "END_TYPE_SECTION" << '\0'; |
890 | WriteLine(TCollection_AsciiString("END_TYPE_SECTION")); |
891 | } |
892 | CATCH(CArchiveException,e) { |
893 | errorStatus = Standard_True; |
894 | } |
895 | END_CATCH |
896 | |
897 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
898 | return Storage_VSOk; |
899 | } |
900 | |
901 | // ------------------- TYPE : READ |
902 | |
903 | Storage_Error FSD_Archive::BeginReadTypeSection() |
904 | { |
905 | return FindTag("BEGIN_TYPE_SECTION"); |
906 | } |
907 | |
908 | Standard_Integer FSD_Archive::TypeSectionSize() |
909 | { |
910 | Standard_Integer i = 0; |
7fd59977 |
911 | Standard_Boolean errorStatus = Standard_False; |
912 | TRY { |
913 | (*myStream) >> i; |
914 | } |
915 | CATCH(CArchiveException,e) { |
916 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
917 | else errorStatus = Standard_True; |
918 | } |
919 | END_CATCH |
920 | |
921 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
922 | return i; |
923 | } |
924 | |
50fe2dab |
925 | void FSD_Archive::ReadTypeInformations(Standard_Integer& typeNum, TCollection_AsciiString& typeName) |
7fd59977 |
926 | { |
7fd59977 |
927 | Standard_Boolean errorStatus = Standard_False; |
928 | TRY { |
929 | unsigned char c; |
930 | (*myStream) >> typeNum; |
931 | (*myStream) >> c; |
932 | if(myFormat) { |
933 | TCollection_AsciiString tn; |
934 | typeName = (Standard_Character) c; |
935 | ReadLine(tn); |
936 | typeName += tn; |
937 | } else { |
938 | ReadLine(typeName); |
939 | } |
940 | } |
941 | CATCH(CArchiveException,e) { |
942 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
943 | else errorStatus = Standard_True; |
944 | } |
945 | END_CATCH |
946 | |
947 | if (errorStatus) |
7fd59977 |
948 | Storage_StreamTypeMismatchError::Raise(); |
949 | } |
950 | |
951 | Storage_Error FSD_Archive::EndReadTypeSection() |
952 | { |
953 | return FindTag("END_TYPE_SECTION"); |
954 | } |
955 | |
956 | // -------------------- ROOT : WRITE |
957 | |
958 | Storage_Error FSD_Archive::BeginWriteRootSection() |
959 | { |
7fd59977 |
960 | Standard_Boolean errorStatus = Standard_False; |
961 | TRY { |
962 | //(*myStream) << "BEGIN_ROOT_SECTION" << '\0'; |
963 | WriteLine(TCollection_AsciiString("BEGIN_ROOT_SECTION")); |
964 | } |
965 | CATCH(CArchiveException,e) { |
966 | errorStatus = Standard_True; |
967 | } |
968 | END_CATCH |
969 | |
970 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
971 | return Storage_VSOk; |
972 | } |
973 | |
50fe2dab |
974 | void FSD_Archive::SetRootSectionSize(const Standard_Integer aSize) |
7fd59977 |
975 | { |
7fd59977 |
976 | Standard_Boolean errorStatus = Standard_False; |
977 | TRY { |
978 | (*myStream) << aSize; |
979 | } |
980 | CATCH(CArchiveException,e) { |
981 | errorStatus = Standard_True; |
982 | } |
983 | END_CATCH |
984 | |
985 | if (errorStatus) |
7fd59977 |
986 | Storage_StreamWriteError::Raise(); |
987 | } |
988 | |
50fe2dab |
989 | void FSD_Archive::WriteRoot (const TCollection_AsciiString& rootName, |
990 | const Standard_Integer aRef, |
991 | const TCollection_AsciiString& rootType) |
992 | { |
7fd59977 |
993 | Standard_Boolean errorStatus = Standard_False; |
994 | TRY { |
995 | //(*myStream) << aRef << rootName.ToCString() << '\0' << rootType.ToCString() << '\0'; |
996 | (*myStream) << aRef; |
997 | WriteLine(rootName); |
998 | WriteLine(rootType); |
999 | |
1000 | } |
1001 | CATCH(CArchiveException,e) { |
1002 | errorStatus = Standard_True; |
1003 | } |
1004 | END_CATCH |
1005 | |
1006 | if (errorStatus) |
7fd59977 |
1007 | Storage_StreamWriteError::Raise(); |
1008 | } |
1009 | |
1010 | Storage_Error FSD_Archive::EndWriteRootSection() |
1011 | { |
7fd59977 |
1012 | Standard_Boolean errorStatus = Standard_False; |
1013 | TRY { |
1014 | //(*myStream) << "END_ROOT_SECTION" << '\0'; |
1015 | WriteLine(TCollection_AsciiString("END_ROOT_SECTION")); |
1016 | } |
1017 | CATCH(CArchiveException,e) { |
1018 | errorStatus = Standard_True; |
1019 | } |
1020 | END_CATCH |
1021 | |
1022 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
1023 | return Storage_VSOk; |
1024 | } |
1025 | |
1026 | // ----------------------- ROOT : READ |
1027 | |
1028 | Storage_Error FSD_Archive::BeginReadRootSection() |
1029 | { |
1030 | return FindTag("BEGIN_ROOT_SECTION"); |
1031 | } |
1032 | |
1033 | Standard_Integer FSD_Archive::RootSectionSize() |
1034 | { |
1035 | Standard_Integer i = 0; |
7fd59977 |
1036 | Standard_Boolean errorStatus = Standard_False; |
1037 | TRY { |
1038 | (*myStream) >> i; |
1039 | } |
1040 | CATCH(CArchiveException,e) { |
1041 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
1042 | else errorStatus = Standard_True; |
1043 | } |
1044 | END_CATCH |
1045 | |
1046 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
1047 | return i; |
1048 | } |
1049 | |
50fe2dab |
1050 | void FSD_Archive::ReadRoot(TCollection_AsciiString& rootName, |
1051 | Standard_Integer& aRef, |
1052 | TCollection_AsciiString& rootType) |
1053 | { |
7fd59977 |
1054 | Standard_Boolean errorStatus = Standard_False; |
1055 | TRY { |
1056 | (*myStream) >> aRef; |
1057 | ReadLine(rootName); |
1058 | ReadLine(rootType); |
1059 | } |
1060 | CATCH(CArchiveException,e) { |
1061 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
1062 | else errorStatus = Standard_True; |
1063 | } |
1064 | END_CATCH |
1065 | |
1066 | if (errorStatus) |
7fd59977 |
1067 | Storage_StreamTypeMismatchError::Raise(); |
1068 | } |
1069 | |
1070 | Storage_Error FSD_Archive::EndReadRootSection() |
1071 | { |
1072 | return FindTag("END_ROOT_SECTION"); |
1073 | } |
1074 | |
1075 | // -------------------------- REF : WRITE |
1076 | |
1077 | Storage_Error FSD_Archive::BeginWriteRefSection() |
1078 | { |
7fd59977 |
1079 | Standard_Boolean errorStatus = Standard_False; |
1080 | TRY { |
1081 | //(*myStream) << "BEGIN_REF_SECTION" << '\0'; |
1082 | WriteLine(TCollection_AsciiString("BEGIN_REF_SECTION")); |
1083 | } |
1084 | CATCH(CArchiveException,e) { |
1085 | errorStatus = Standard_True; |
1086 | } |
1087 | END_CATCH |
1088 | |
1089 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
1090 | return Storage_VSOk; |
1091 | } |
1092 | |
50fe2dab |
1093 | void FSD_Archive::SetRefSectionSize(const Standard_Integer aSize) |
7fd59977 |
1094 | { |
7fd59977 |
1095 | Standard_Boolean errorStatus = Standard_False; |
1096 | TRY { |
1097 | (*myStream) << aSize; |
1098 | } |
1099 | CATCH(CArchiveException,e) { |
1100 | errorStatus = Standard_True; |
1101 | } |
1102 | END_CATCH |
1103 | |
1104 | if (errorStatus) |
7fd59977 |
1105 | Storage_StreamWriteError::Raise(); |
1106 | } |
1107 | |
50fe2dab |
1108 | void FSD_Archive::WriteReferenceType(const Standard_Integer reference, |
1109 | const Standard_Integer typeNum) |
7fd59977 |
1110 | { |
7fd59977 |
1111 | Standard_Boolean errorStatus = Standard_False; |
1112 | TRY { |
1113 | (*myStream) << reference << typeNum; |
1114 | } |
1115 | CATCH(CArchiveException,e) { |
1116 | errorStatus = Standard_True; |
1117 | } |
1118 | END_CATCH |
1119 | |
1120 | if (errorStatus) |
7fd59977 |
1121 | Storage_StreamWriteError::Raise(); |
1122 | } |
1123 | |
1124 | Storage_Error FSD_Archive::EndWriteRefSection() |
1125 | { |
7fd59977 |
1126 | Standard_Boolean errorStatus = Standard_False; |
1127 | TRY { |
1128 | //(*myStream) << "END_REF_SECTION" << '\0'; |
1129 | WriteLine(TCollection_AsciiString("END_REF_SECTION")); |
1130 | } |
1131 | CATCH(CArchiveException,e) { |
1132 | errorStatus = Standard_True; |
1133 | } |
1134 | END_CATCH |
1135 | |
1136 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
1137 | return Storage_VSOk; |
1138 | } |
1139 | |
1140 | // ----------------------- REF : READ |
1141 | |
1142 | Storage_Error FSD_Archive::BeginReadRefSection() |
1143 | { |
1144 | return FindTag("BEGIN_REF_SECTION"); |
1145 | } |
1146 | |
1147 | Standard_Integer FSD_Archive::RefSectionSize() |
1148 | { |
1149 | Standard_Integer i = 0; |
7fd59977 |
1150 | Standard_Boolean errorStatus = Standard_False; |
1151 | TRY { |
1152 | (*myStream) >> i; |
1153 | } |
1154 | CATCH(CArchiveException,e) { |
1155 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
1156 | else errorStatus = Standard_True; |
1157 | } |
1158 | END_CATCH |
1159 | |
1160 | if (errorStatus) Storage_StreamTypeMismatchError::Raise(); |
7fd59977 |
1161 | return i; |
1162 | } |
1163 | |
50fe2dab |
1164 | void FSD_Archive::ReadReferenceType(Standard_Integer& reference, |
1165 | Standard_Integer& typeNum) |
7fd59977 |
1166 | { |
7fd59977 |
1167 | Standard_Boolean errorStatus = Standard_False; |
1168 | TRY { |
1169 | (*myStream) >> reference; |
1170 | (*myStream) >> typeNum; |
1171 | } |
1172 | CATCH(CArchiveException,e) { |
1173 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
1174 | else errorStatus = Standard_True; |
1175 | } |
1176 | END_CATCH |
1177 | |
1178 | if (errorStatus) |
7fd59977 |
1179 | Storage_StreamTypeMismatchError::Raise(); |
1180 | } |
1181 | |
1182 | Storage_Error FSD_Archive::EndReadRefSection() |
1183 | { |
1184 | return FindTag("END_REF_SECTION"); |
1185 | } |
1186 | |
1187 | // -------------------- DATA : WRITE |
1188 | |
1189 | Storage_Error FSD_Archive::BeginWriteDataSection() |
1190 | { |
7fd59977 |
1191 | Standard_Boolean errorStatus = Standard_False; |
1192 | TRY { |
1193 | //(*myStream) << "BEGIN_DATA_SECTION" << '\0'; |
1194 | WriteLine(TCollection_AsciiString("BEGIN_DATA_SECTION")); |
1195 | } |
1196 | CATCH(CArchiveException,e) { |
1197 | errorStatus = Standard_True; |
1198 | } |
1199 | END_CATCH |
1200 | |
1201 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
1202 | return Storage_VSOk; |
1203 | } |
1204 | |
50fe2dab |
1205 | void FSD_Archive::WritePersistentObjectHeader(const Standard_Integer aRef, |
1206 | const Standard_Integer aType) |
7fd59977 |
1207 | { |
7fd59977 |
1208 | Standard_Boolean errorStatus = Standard_False; |
1209 | TRY { |
1210 | (*myStream) << aRef << aType; |
1211 | } |
1212 | CATCH(CArchiveException,e) { |
1213 | errorStatus = Standard_True; |
1214 | } |
1215 | END_CATCH |
1216 | |
1217 | if (errorStatus) |
7fd59977 |
1218 | Storage_StreamWriteError::Raise(); |
1219 | } |
1220 | |
1221 | void FSD_Archive::BeginWritePersistentObjectData() |
1222 | { |
1223 | } |
1224 | |
1225 | void FSD_Archive::BeginWriteObjectData() |
1226 | { |
1227 | } |
1228 | |
1229 | void FSD_Archive::EndWriteObjectData() |
1230 | { |
1231 | } |
1232 | |
1233 | void FSD_Archive::EndWritePersistentObjectData() |
1234 | { |
7fd59977 |
1235 | (*myStream) << 'E'; |
7fd59977 |
1236 | } |
1237 | |
1238 | Storage_Error FSD_Archive::EndWriteDataSection() |
1239 | { |
7fd59977 |
1240 | Standard_Boolean errorStatus = Standard_False; |
1241 | TRY { |
1242 | //(*myStream) << "END_DATA_SECTION" << '\0'; |
1243 | WriteLine(TCollection_AsciiString("END_DATA_SECTION")); |
1244 | } |
1245 | CATCH(CArchiveException,e) { |
1246 | errorStatus = Standard_True; |
1247 | } |
1248 | END_CATCH |
1249 | |
1250 | if (errorStatus) Storage_StreamWriteError::Raise(); |
7fd59977 |
1251 | return Storage_VSOk; |
1252 | } |
1253 | |
1254 | // ---------------------- DATA : READ |
1255 | |
1256 | Storage_Error FSD_Archive::BeginReadDataSection() |
1257 | { |
1258 | return FindTag("BEGIN_DATA_SECTION"); |
1259 | } |
1260 | |
50fe2dab |
1261 | void FSD_Archive::ReadPersistentObjectHeader(Standard_Integer& aRef, Standard_Integer& aType) |
7fd59977 |
1262 | { |
7fd59977 |
1263 | Standard_Boolean errorStatus = Standard_False; |
1264 | TRY { |
1265 | (*myStream) >> aRef; |
1266 | (*myStream) >> aType; |
1267 | } |
1268 | CATCH(CArchiveException,e) { |
1269 | if (e->m_cause == CArchiveException::endOfFile) myEof = Standard_True; |
1270 | else errorStatus = Standard_True; |
1271 | } |
1272 | END_CATCH |
1273 | |
1274 | if (errorStatus) |
7fd59977 |
1275 | Storage_StreamTypeMismatchError::Raise(); |
1276 | } |
1277 | |
1278 | void FSD_Archive::BeginReadPersistentObjectData() |
1279 | { |
1280 | } |
1281 | |
1282 | void FSD_Archive::BeginReadObjectData() |
1283 | { |
1284 | } |
1285 | |
1286 | void FSD_Archive::EndReadObjectData() |
1287 | { |
1288 | } |
1289 | |
1290 | void FSD_Archive::EndReadPersistentObjectData() |
1291 | { |
7fd59977 |
1292 | char theEnd; |
1293 | |
1294 | (*myStream) >> theEnd; |
1295 | |
1296 | if (theEnd != 'E') { |
1297 | Storage_StreamFormatError::Raise(); |
1298 | } |
7fd59977 |
1299 | } |
1300 | |
1301 | Storage_Error FSD_Archive::EndReadDataSection() |
1302 | { |
1303 | return FindTag("END_DATA_SECTION"); |
1304 | } |
1305 | |
1306 | Storage_Position FSD_Archive::Tell() |
1307 | { |
1308 | return 0; //just a stub |
480bf81e |
1309 | } |