7fd59977 |
1 | // File: DDF_IOStream.hxx |
2 | // -------------- |
3 | // Author: DAUTRY Philippe |
4 | // <fid@fox.paris1.matra-dtv.fr> |
5 | // Copyright: Matra Datavision 1997 |
6 | |
7 | // Version: 0.0 |
8 | // History: Version Date Purpose |
9 | // 0.0 Aug 22 1997 Creation |
10 | |
11 | // This file has been written using FSD_File.hxx as template. |
12 | // This is a specific adaptation for Draw use (save & restore commands). |
13 | // It is not sure at all this code is portable on any other plateform than |
14 | // SUN OS. Don't use it anywhere else. |
15 | // Thanks for comprehension. (22 august 97) |
16 | |
17 | |
18 | #ifndef DDF_IOStream_HeaderFile |
19 | #define DDF_IOStream_HeaderFile |
20 | |
21 | // File generated by CPPExt (Value) |
22 | // Copyright (C) 1991,1995 by |
23 | // |
24 | // MATRA DATAVISION, FRANCE |
25 | // |
26 | // This software is furnished in accordance with the terms and conditions |
27 | // of the contract and with the inclusion of the above copyright notice. |
28 | // This software or any other copy thereof may not be provided or otherwise |
29 | // be made available to any other person. No title to an ownership of the |
30 | // software is hereby transferred. |
31 | // |
32 | // At the termination of the contract, the software and all copies of this |
33 | // software must be deleted. |
34 | |
35 | #include <stdio.h> |
36 | |
37 | #ifndef _Storage_BaseDriver_HeaderFile |
38 | #include <Storage_BaseDriver.hxx> |
39 | #endif |
40 | #ifndef _Storage_Error_HeaderFile |
41 | #include <Storage_Error.hxx> |
42 | #endif |
43 | #ifndef _Storage_OpenMode_HeaderFile |
44 | #include <Storage_OpenMode.hxx> |
45 | #endif |
46 | #ifndef _Standard_Boolean_HeaderFile |
47 | #include <Standard_Boolean.hxx> |
48 | #endif |
49 | #ifndef _Standard_Integer_HeaderFile |
50 | #include <Standard_Integer.hxx> |
51 | #endif |
52 | #ifndef _Standard_Character_HeaderFile |
53 | #include <Standard_Character.hxx> |
54 | #endif |
55 | #ifndef _Standard_ExtCharacter_HeaderFile |
56 | #include <Standard_ExtCharacter.hxx> |
57 | #endif |
58 | #ifndef _Standard_Real_HeaderFile |
59 | #include <Standard_Real.hxx> |
60 | #endif |
61 | #ifndef _Standard_ShortReal_HeaderFile |
62 | #include <Standard_ShortReal.hxx> |
63 | #endif |
64 | #ifndef _Standard_CString_HeaderFile |
65 | #include <Standard_CString.hxx> |
66 | #endif |
67 | #include <Storage_Position.hxx> |
68 | |
69 | class Storage_StreamTypeMismatchError; |
70 | class Storage_StreamFormatError; |
71 | class Storage_StreamWriteError; |
72 | class Storage_StreamExtCharParityError; |
73 | |
74 | class TColStd_SequenceOfExtendedString; |
75 | |
76 | #ifndef Standard_EXPORT |
77 | #ifdef WNT |
78 | #define Standard_EXPORT __declspec(dllexport) |
79 | #else |
80 | #define Standard_EXPORT |
81 | #endif |
82 | #endif |
83 | #ifdef WNT |
84 | #pragma warning (disable : 4275) |
85 | #endif |
86 | |
87 | class Standard_EXPORT DDF_IOStream : public Storage_BaseDriver { |
88 | |
89 | public: |
90 | |
91 | // Methods PUBLIC |
92 | // |
93 | DDF_IOStream(); |
94 | Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ; |
95 | Storage_Error Open(istream* anIStream) ; |
96 | Storage_Error Open(ostream* anOStream) ; |
97 | Standard_Boolean IsEnd() ; |
98 | Storage_Position Tell() { return -1; } |
99 | static Storage_Error IsGoodFileType(istream* anIStream) ; |
100 | Storage_Error BeginWriteInfoSection() ; |
101 | 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) ; |
102 | Storage_Error EndWriteInfoSection() ; |
103 | Storage_Error BeginReadInfoSection() ; |
104 | 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) ; |
105 | Storage_Error EndReadInfoSection() ; |
106 | Storage_Error BeginWriteCommentSection() ; |
107 | void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ; |
108 | Storage_Error EndWriteCommentSection() ; |
109 | Storage_Error BeginReadCommentSection() ; |
110 | void ReadComment(TColStd_SequenceOfExtendedString& userComments) ; |
111 | Storage_Error EndReadCommentSection() ; |
112 | Storage_Error BeginWriteTypeSection() ; |
113 | void SetTypeSectionSize(const Standard_Integer aSize) ; |
114 | void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ; |
115 | Storage_Error EndWriteTypeSection() ; |
116 | Storage_Error BeginReadTypeSection() ; |
117 | Standard_Integer TypeSectionSize() ; |
118 | void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ; |
119 | Storage_Error EndReadTypeSection() ; |
120 | Storage_Error BeginWriteRootSection() ; |
121 | void SetRootSectionSize(const Standard_Integer aSize) ; |
122 | void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ; |
123 | Storage_Error EndWriteRootSection() ; |
124 | Storage_Error BeginReadRootSection() ; |
125 | Standard_Integer RootSectionSize() ; |
126 | void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ; |
127 | Storage_Error EndReadRootSection() ; |
128 | Storage_Error BeginWriteRefSection() ; |
129 | void SetRefSectionSize(const Standard_Integer aSize) ; |
130 | void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ; |
131 | Storage_Error EndWriteRefSection() ; |
132 | Storage_Error BeginReadRefSection() ; |
133 | Standard_Integer RefSectionSize() ; |
134 | void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ; |
135 | Storage_Error EndReadRefSection() ; |
136 | Storage_Error BeginWriteDataSection() ; |
137 | void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ; |
138 | void BeginWritePersistentObjectData() ; |
139 | void BeginWriteObjectData() ; |
140 | void EndWriteObjectData() ; |
141 | void EndWritePersistentObjectData() ; |
142 | Storage_Error EndWriteDataSection() ; |
143 | Storage_Error BeginReadDataSection() ; |
144 | void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ; |
145 | void BeginReadPersistentObjectData() ; |
146 | void BeginReadObjectData() ; |
147 | void EndReadObjectData() ; |
148 | void EndReadPersistentObjectData() ; |
149 | Storage_Error EndReadDataSection() ; |
150 | void SkipObject() ; |
151 | Storage_BaseDriver& PutReference(const Standard_Integer aValue) ; |
152 | Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ; |
153 | Storage_BaseDriver& operator <<(const Standard_Character aValue) |
154 | { |
155 | return PutCharacter(aValue); |
156 | } |
157 | |
158 | Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ; |
159 | Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue) |
160 | { |
161 | return PutExtCharacter(aValue); |
162 | } |
163 | |
164 | Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ; |
165 | Storage_BaseDriver& operator <<(const Standard_Integer aValue) |
166 | { |
167 | return PutInteger(aValue); |
168 | } |
169 | |
170 | Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ; |
171 | Storage_BaseDriver& operator <<(const Standard_Boolean aValue) |
172 | { |
173 | return PutBoolean(aValue); |
174 | } |
175 | |
176 | Storage_BaseDriver& PutReal(const Standard_Real aValue) ; |
177 | Storage_BaseDriver& operator <<(const Standard_Real aValue) |
178 | { |
179 | return PutReal(aValue); |
180 | } |
181 | |
182 | Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ; |
183 | Storage_BaseDriver& operator <<(const Standard_ShortReal aValue) |
184 | { |
185 | return PutShortReal(aValue); |
186 | } |
187 | |
188 | Storage_BaseDriver& GetReference(Standard_Integer& aValue) ; |
189 | Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ; |
190 | Storage_BaseDriver& operator >>(Standard_Character& aValue) |
191 | { |
192 | return GetCharacter(aValue); |
193 | } |
194 | |
195 | Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ; |
196 | Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue) |
197 | { |
198 | return GetExtCharacter(aValue); |
199 | } |
200 | |
201 | Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ; |
202 | Storage_BaseDriver& operator >>(Standard_Integer& aValue) |
203 | { |
204 | return GetInteger(aValue); |
205 | } |
206 | |
207 | Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ; |
208 | Storage_BaseDriver& operator >>(Standard_Boolean& aValue) |
209 | { |
210 | return GetBoolean(aValue); |
211 | } |
212 | |
213 | Storage_BaseDriver& GetReal(Standard_Real& aValue) ; |
214 | Storage_BaseDriver& operator >>(Standard_Real& aValue) |
215 | { |
216 | return GetReal(aValue); |
217 | } |
218 | |
219 | Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ; |
220 | Storage_BaseDriver& operator >>(Standard_ShortReal& aValue) |
221 | { |
222 | return GetShortReal(aValue); |
223 | } |
224 | |
225 | Storage_Error Close() ; |
226 | void Destroy() ; |
227 | ~DDF_IOStream() |
228 | { |
229 | Destroy(); |
230 | } |
231 | |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | protected: |
238 | |
239 | // Methods PROTECTED |
240 | // |
241 | void ReadLine(TCollection_AsciiString& buffer) ; |
242 | void ReadWord(TCollection_AsciiString& buffer) ; |
243 | void ReadExtendedLine(TCollection_ExtendedString& buffer) ; |
244 | void WriteExtendedLine(const TCollection_ExtendedString& buffer) ; |
245 | void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ; |
246 | void ReadString(TCollection_AsciiString& buffer) ; |
247 | void FlushEndOfLine() ; |
248 | Storage_Error FindTag(const Standard_CString aTag) ; |
249 | |
250 | |
251 | // Fields PROTECTED |
252 | // |
253 | |
254 | |
255 | private: |
256 | |
257 | // Methods PRIVATE |
258 | // |
259 | static const Standard_CString MagicNumber() ; |
260 | |
261 | |
262 | // Fields PRIVATE |
263 | // |
264 | //FSD_FStream myStream; |
265 | istream* myIStream; |
266 | ostream* myOStream; |
267 | |
268 | |
269 | }; |
270 | |
271 | #ifdef WNT |
272 | #pragma warning (default : 4275) |
273 | #endif |
274 | |
275 | |
276 | // other inline functions and methods (like "C++: function call" methods) |
277 | // |
278 | #endif |