1 // Created on: 1997-08-22
2 // Created by: DAUTRY Philippe
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // This file has been written using FSD_File.hxx as template.
18 // This is a specific adaptation for Draw use (save & restore commands).
19 // It is not sure at all this code is portable on any other plateform than
20 // SUN OS. Don't use it anywhere else.
21 // Thanks for comprehension. (22 august 97)
24 #ifndef DDF_IOStream_HeaderFile
25 #define DDF_IOStream_HeaderFile
29 #include <Storage_BaseDriver.hxx>
30 #include <Storage_Error.hxx>
31 #include <Storage_OpenMode.hxx>
32 #include <Storage_Position.hxx>
34 class Storage_StreamTypeMismatchError;
35 class Storage_StreamFormatError;
36 class Storage_StreamWriteError;
37 class Storage_StreamExtCharParityError;
39 #include <TColStd_SequenceOfExtendedString.hxx>
41 class DDF_IOStream : public Storage_BaseDriver {
48 Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ;
49 Storage_Error Open(istream* anIStream) ;
50 Storage_Error Open(ostream* anOStream) ;
51 Standard_Boolean IsEnd() ;
52 Storage_Position Tell() { return -1; }
53 static Storage_Error IsGoodFileType(istream* anIStream) ;
54 Storage_Error BeginWriteInfoSection() ;
55 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) ;
56 Storage_Error EndWriteInfoSection() ;
57 Storage_Error BeginReadInfoSection() ;
58 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) ;
59 Storage_Error EndReadInfoSection() ;
60 Storage_Error BeginWriteCommentSection() ;
61 void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ;
62 Storage_Error EndWriteCommentSection() ;
63 Storage_Error BeginReadCommentSection() ;
64 void ReadComment(TColStd_SequenceOfExtendedString& userComments) ;
65 Storage_Error EndReadCommentSection() ;
66 Storage_Error BeginWriteTypeSection() ;
67 void SetTypeSectionSize(const Standard_Integer aSize) ;
68 void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ;
69 Storage_Error EndWriteTypeSection() ;
70 Storage_Error BeginReadTypeSection() ;
71 Standard_Integer TypeSectionSize() ;
72 void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ;
73 Storage_Error EndReadTypeSection() ;
74 Storage_Error BeginWriteRootSection() ;
75 void SetRootSectionSize(const Standard_Integer aSize) ;
76 void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ;
77 Storage_Error EndWriteRootSection() ;
78 Storage_Error BeginReadRootSection() ;
79 Standard_Integer RootSectionSize() ;
80 void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ;
81 Storage_Error EndReadRootSection() ;
82 Storage_Error BeginWriteRefSection() ;
83 void SetRefSectionSize(const Standard_Integer aSize) ;
84 void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ;
85 Storage_Error EndWriteRefSection() ;
86 Storage_Error BeginReadRefSection() ;
87 Standard_Integer RefSectionSize() ;
88 void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ;
89 Storage_Error EndReadRefSection() ;
90 Storage_Error BeginWriteDataSection() ;
91 void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ;
92 void BeginWritePersistentObjectData() ;
93 void BeginWriteObjectData() ;
94 void EndWriteObjectData() ;
95 void EndWritePersistentObjectData() ;
96 Storage_Error EndWriteDataSection() ;
97 Storage_Error BeginReadDataSection() ;
98 void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ;
99 void BeginReadPersistentObjectData() ;
100 void BeginReadObjectData() ;
101 void EndReadObjectData() ;
102 void EndReadPersistentObjectData() ;
103 Storage_Error EndReadDataSection() ;
105 Storage_BaseDriver& PutReference(const Standard_Integer aValue) ;
106 Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ;
107 Storage_BaseDriver& operator <<(const Standard_Character aValue)
109 return PutCharacter(aValue);
112 Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ;
113 Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue)
115 return PutExtCharacter(aValue);
118 Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ;
119 Storage_BaseDriver& operator <<(const Standard_Integer aValue)
121 return PutInteger(aValue);
124 Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ;
125 Storage_BaseDriver& operator <<(const Standard_Boolean aValue)
127 return PutBoolean(aValue);
130 Storage_BaseDriver& PutReal(const Standard_Real aValue) ;
131 Storage_BaseDriver& operator <<(const Standard_Real aValue)
133 return PutReal(aValue);
136 Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ;
137 Storage_BaseDriver& operator <<(const Standard_ShortReal aValue)
139 return PutShortReal(aValue);
142 Storage_BaseDriver& GetReference(Standard_Integer& aValue) ;
143 Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ;
144 Storage_BaseDriver& operator >>(Standard_Character& aValue)
146 return GetCharacter(aValue);
149 Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ;
150 Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue)
152 return GetExtCharacter(aValue);
155 Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ;
156 Storage_BaseDriver& operator >>(Standard_Integer& aValue)
158 return GetInteger(aValue);
161 Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ;
162 Storage_BaseDriver& operator >>(Standard_Boolean& aValue)
164 return GetBoolean(aValue);
167 Storage_BaseDriver& GetReal(Standard_Real& aValue) ;
168 Storage_BaseDriver& operator >>(Standard_Real& aValue)
170 return GetReal(aValue);
173 Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ;
174 Storage_BaseDriver& operator >>(Standard_ShortReal& aValue)
176 return GetShortReal(aValue);
179 Storage_Error Close() ;
195 void ReadLine(TCollection_AsciiString& buffer) ;
196 void ReadWord(TCollection_AsciiString& buffer) ;
197 void ReadExtendedLine(TCollection_ExtendedString& buffer) ;
198 void WriteExtendedLine(const TCollection_ExtendedString& buffer) ;
199 void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ;
200 void ReadString(TCollection_AsciiString& buffer) ;
201 void FlushEndOfLine() ;
202 Storage_Error FindTag(const Standard_CString aTag) ;
213 static Standard_CString MagicNumber() ;
218 //FSD_FStream myStream;
226 #pragma warning (default : 4275)
230 // other inline functions and methods (like "C++: function call" methods)