1 // Created on: 1997-08-22
2 // Created by: DAUTRY Philippe
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 // This file has been written using FSD_File.hxx as template.
22 // This is a specific adaptation for Draw use (save & restore commands).
23 // It is not sure at all this code is portable on any other plateform than
24 // SUN OS. Don't use it anywhere else.
25 // Thanks for comprehension. (22 august 97)
28 #ifndef DDF_IOStream_HeaderFile
29 #define DDF_IOStream_HeaderFile
33 #ifndef _Storage_BaseDriver_HeaderFile
34 #include <Storage_BaseDriver.hxx>
36 #ifndef _Storage_Error_HeaderFile
37 #include <Storage_Error.hxx>
39 #ifndef _Storage_OpenMode_HeaderFile
40 #include <Storage_OpenMode.hxx>
42 #ifndef _Standard_Boolean_HeaderFile
43 #include <Standard_Boolean.hxx>
45 #ifndef _Standard_Integer_HeaderFile
46 #include <Standard_Integer.hxx>
48 #ifndef _Standard_Character_HeaderFile
49 #include <Standard_Character.hxx>
51 #ifndef _Standard_ExtCharacter_HeaderFile
52 #include <Standard_ExtCharacter.hxx>
54 #ifndef _Standard_Real_HeaderFile
55 #include <Standard_Real.hxx>
57 #ifndef _Standard_ShortReal_HeaderFile
58 #include <Standard_ShortReal.hxx>
60 #ifndef _Standard_CString_HeaderFile
61 #include <Standard_CString.hxx>
63 #include <Storage_Position.hxx>
65 class Storage_StreamTypeMismatchError;
66 class Storage_StreamFormatError;
67 class Storage_StreamWriteError;
68 class Storage_StreamExtCharParityError;
70 class TColStd_SequenceOfExtendedString;
72 #ifndef Standard_EXPORT
74 #define Standard_EXPORT __declspec(dllexport)
76 #define Standard_EXPORT
80 #pragma warning (disable : 4275)
83 class Standard_EXPORT DDF_IOStream : public Storage_BaseDriver {
90 Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ;
91 Storage_Error Open(istream* anIStream) ;
92 Storage_Error Open(ostream* anOStream) ;
93 Standard_Boolean IsEnd() ;
94 Storage_Position Tell() { return -1; }
95 static Storage_Error IsGoodFileType(istream* anIStream) ;
96 Storage_Error BeginWriteInfoSection() ;
97 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) ;
98 Storage_Error EndWriteInfoSection() ;
99 Storage_Error BeginReadInfoSection() ;
100 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) ;
101 Storage_Error EndReadInfoSection() ;
102 Storage_Error BeginWriteCommentSection() ;
103 void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ;
104 Storage_Error EndWriteCommentSection() ;
105 Storage_Error BeginReadCommentSection() ;
106 void ReadComment(TColStd_SequenceOfExtendedString& userComments) ;
107 Storage_Error EndReadCommentSection() ;
108 Storage_Error BeginWriteTypeSection() ;
109 void SetTypeSectionSize(const Standard_Integer aSize) ;
110 void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ;
111 Storage_Error EndWriteTypeSection() ;
112 Storage_Error BeginReadTypeSection() ;
113 Standard_Integer TypeSectionSize() ;
114 void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ;
115 Storage_Error EndReadTypeSection() ;
116 Storage_Error BeginWriteRootSection() ;
117 void SetRootSectionSize(const Standard_Integer aSize) ;
118 void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ;
119 Storage_Error EndWriteRootSection() ;
120 Storage_Error BeginReadRootSection() ;
121 Standard_Integer RootSectionSize() ;
122 void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ;
123 Storage_Error EndReadRootSection() ;
124 Storage_Error BeginWriteRefSection() ;
125 void SetRefSectionSize(const Standard_Integer aSize) ;
126 void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ;
127 Storage_Error EndWriteRefSection() ;
128 Storage_Error BeginReadRefSection() ;
129 Standard_Integer RefSectionSize() ;
130 void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ;
131 Storage_Error EndReadRefSection() ;
132 Storage_Error BeginWriteDataSection() ;
133 void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ;
134 void BeginWritePersistentObjectData() ;
135 void BeginWriteObjectData() ;
136 void EndWriteObjectData() ;
137 void EndWritePersistentObjectData() ;
138 Storage_Error EndWriteDataSection() ;
139 Storage_Error BeginReadDataSection() ;
140 void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ;
141 void BeginReadPersistentObjectData() ;
142 void BeginReadObjectData() ;
143 void EndReadObjectData() ;
144 void EndReadPersistentObjectData() ;
145 Storage_Error EndReadDataSection() ;
147 Storage_BaseDriver& PutReference(const Standard_Integer aValue) ;
148 Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ;
149 Storage_BaseDriver& operator <<(const Standard_Character aValue)
151 return PutCharacter(aValue);
154 Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ;
155 Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue)
157 return PutExtCharacter(aValue);
160 Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ;
161 Storage_BaseDriver& operator <<(const Standard_Integer aValue)
163 return PutInteger(aValue);
166 Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ;
167 Storage_BaseDriver& operator <<(const Standard_Boolean aValue)
169 return PutBoolean(aValue);
172 Storage_BaseDriver& PutReal(const Standard_Real aValue) ;
173 Storage_BaseDriver& operator <<(const Standard_Real aValue)
175 return PutReal(aValue);
178 Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ;
179 Storage_BaseDriver& operator <<(const Standard_ShortReal aValue)
181 return PutShortReal(aValue);
184 Storage_BaseDriver& GetReference(Standard_Integer& aValue) ;
185 Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ;
186 Storage_BaseDriver& operator >>(Standard_Character& aValue)
188 return GetCharacter(aValue);
191 Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ;
192 Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue)
194 return GetExtCharacter(aValue);
197 Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ;
198 Storage_BaseDriver& operator >>(Standard_Integer& aValue)
200 return GetInteger(aValue);
203 Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ;
204 Storage_BaseDriver& operator >>(Standard_Boolean& aValue)
206 return GetBoolean(aValue);
209 Storage_BaseDriver& GetReal(Standard_Real& aValue) ;
210 Storage_BaseDriver& operator >>(Standard_Real& aValue)
212 return GetReal(aValue);
215 Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ;
216 Storage_BaseDriver& operator >>(Standard_ShortReal& aValue)
218 return GetShortReal(aValue);
221 Storage_Error Close() ;
237 void ReadLine(TCollection_AsciiString& buffer) ;
238 void ReadWord(TCollection_AsciiString& buffer) ;
239 void ReadExtendedLine(TCollection_ExtendedString& buffer) ;
240 void WriteExtendedLine(const TCollection_ExtendedString& buffer) ;
241 void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ;
242 void ReadString(TCollection_AsciiString& buffer) ;
243 void FlushEndOfLine() ;
244 Storage_Error FindTag(const Standard_CString aTag) ;
255 static const Standard_CString MagicNumber() ;
260 //FSD_FStream myStream;
268 #pragma warning (default : 4275)
272 // other inline functions and methods (like "C++: function call" methods)