b311480e |
1 | // Created on: 1997-08-22 |
2 | // Created by: DAUTRY Philippe |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
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) |
22 | |
23 | |
24 | #ifndef DDF_IOStream_HeaderFile |
25 | #define DDF_IOStream_HeaderFile |
26 | |
7fd59977 |
27 | #include <stdio.h> |
28 | |
7fd59977 |
29 | #include <Storage_BaseDriver.hxx> |
7fd59977 |
30 | #include <Storage_Error.hxx> |
7fd59977 |
31 | #include <Storage_OpenMode.hxx> |
7fd59977 |
32 | #include <Storage_Position.hxx> |
33 | |
34 | class Storage_StreamTypeMismatchError; |
35 | class Storage_StreamFormatError; |
36 | class Storage_StreamWriteError; |
37 | class Storage_StreamExtCharParityError; |
38 | |
b7c077b9 |
39 | #include <TColStd_SequenceOfExtendedString.hxx> |
7fd59977 |
40 | |
b7c077b9 |
41 | class DDF_IOStream : public Storage_BaseDriver { |
7fd59977 |
42 | |
43 | public: |
44 | |
45 | // Methods PUBLIC |
46 | // |
47 | DDF_IOStream(); |
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() ; |
104 | void SkipObject() ; |
105 | Storage_BaseDriver& PutReference(const Standard_Integer aValue) ; |
106 | Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ; |
107 | Storage_BaseDriver& operator <<(const Standard_Character aValue) |
108 | { |
109 | return PutCharacter(aValue); |
110 | } |
111 | |
112 | Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ; |
113 | Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue) |
114 | { |
115 | return PutExtCharacter(aValue); |
116 | } |
117 | |
118 | Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ; |
119 | Storage_BaseDriver& operator <<(const Standard_Integer aValue) |
120 | { |
121 | return PutInteger(aValue); |
122 | } |
123 | |
124 | Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ; |
125 | Storage_BaseDriver& operator <<(const Standard_Boolean aValue) |
126 | { |
127 | return PutBoolean(aValue); |
128 | } |
129 | |
130 | Storage_BaseDriver& PutReal(const Standard_Real aValue) ; |
131 | Storage_BaseDriver& operator <<(const Standard_Real aValue) |
132 | { |
133 | return PutReal(aValue); |
134 | } |
135 | |
136 | Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ; |
137 | Storage_BaseDriver& operator <<(const Standard_ShortReal aValue) |
138 | { |
139 | return PutShortReal(aValue); |
140 | } |
141 | |
142 | Storage_BaseDriver& GetReference(Standard_Integer& aValue) ; |
143 | Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ; |
144 | Storage_BaseDriver& operator >>(Standard_Character& aValue) |
145 | { |
146 | return GetCharacter(aValue); |
147 | } |
148 | |
149 | Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ; |
150 | Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue) |
151 | { |
152 | return GetExtCharacter(aValue); |
153 | } |
154 | |
155 | Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ; |
156 | Storage_BaseDriver& operator >>(Standard_Integer& aValue) |
157 | { |
158 | return GetInteger(aValue); |
159 | } |
160 | |
161 | Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ; |
162 | Storage_BaseDriver& operator >>(Standard_Boolean& aValue) |
163 | { |
164 | return GetBoolean(aValue); |
165 | } |
166 | |
167 | Storage_BaseDriver& GetReal(Standard_Real& aValue) ; |
168 | Storage_BaseDriver& operator >>(Standard_Real& aValue) |
169 | { |
170 | return GetReal(aValue); |
171 | } |
172 | |
173 | Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ; |
174 | Storage_BaseDriver& operator >>(Standard_ShortReal& aValue) |
175 | { |
176 | return GetShortReal(aValue); |
177 | } |
178 | |
179 | Storage_Error Close() ; |
180 | void Destroy() ; |
181 | ~DDF_IOStream() |
182 | { |
183 | Destroy(); |
184 | } |
185 | |
186 | |
187 | |
188 | |
189 | |
190 | |
191 | protected: |
192 | |
193 | // Methods PROTECTED |
194 | // |
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) ; |
203 | |
204 | |
205 | // Fields PROTECTED |
206 | // |
207 | |
208 | |
209 | private: |
210 | |
211 | // Methods PRIVATE |
212 | // |
213 | static const Standard_CString MagicNumber() ; |
214 | |
215 | |
216 | // Fields PRIVATE |
217 | // |
218 | //FSD_FStream myStream; |
219 | istream* myIStream; |
220 | ostream* myOStream; |
221 | |
222 | |
223 | }; |
224 | |
57c28b61 |
225 | #ifdef _MSC_VER |
7fd59977 |
226 | #pragma warning (default : 4275) |
227 | #endif |
228 | |
229 | |
230 | // other inline functions and methods (like "C++: function call" methods) |
231 | // |
232 | #endif |