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
9 // under the terms of the GNU Lesser General Public 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 #ifndef _Storage_BaseDriver_HeaderFile
30 #include <Storage_BaseDriver.hxx>
32 #ifndef _Storage_Error_HeaderFile
33 #include <Storage_Error.hxx>
35 #ifndef _Storage_OpenMode_HeaderFile
36 #include <Storage_OpenMode.hxx>
38 #ifndef _Standard_Boolean_HeaderFile
39 #include <Standard_Boolean.hxx>
41 #ifndef _Standard_Integer_HeaderFile
42 #include <Standard_Integer.hxx>
44 #ifndef _Standard_Character_HeaderFile
45 #include <Standard_Character.hxx>
47 #ifndef _Standard_ExtCharacter_HeaderFile
48 #include <Standard_ExtCharacter.hxx>
50 #ifndef _Standard_Real_HeaderFile
51 #include <Standard_Real.hxx>
53 #ifndef _Standard_ShortReal_HeaderFile
54 #include <Standard_ShortReal.hxx>
56 #ifndef _Standard_CString_HeaderFile
57 #include <Standard_CString.hxx>
59 #include <Storage_Position.hxx>
61 class Storage_StreamTypeMismatchError;
62 class Storage_StreamFormatError;
63 class Storage_StreamWriteError;
64 class Storage_StreamExtCharParityError;
66 class TColStd_SequenceOfExtendedString;
68 #ifndef Standard_EXPORT
70 #define Standard_EXPORT __declspec(dllexport)
72 #define Standard_EXPORT
76 #pragma warning (disable : 4275)
79 class Standard_EXPORT DDF_IOStream : public Storage_BaseDriver {
86 Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ;
87 Storage_Error Open(istream* anIStream) ;
88 Storage_Error Open(ostream* anOStream) ;
89 Standard_Boolean IsEnd() ;
90 Storage_Position Tell() { return -1; }
91 static Storage_Error IsGoodFileType(istream* anIStream) ;
92 Storage_Error BeginWriteInfoSection() ;
93 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) ;
94 Storage_Error EndWriteInfoSection() ;
95 Storage_Error BeginReadInfoSection() ;
96 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) ;
97 Storage_Error EndReadInfoSection() ;
98 Storage_Error BeginWriteCommentSection() ;
99 void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ;
100 Storage_Error EndWriteCommentSection() ;
101 Storage_Error BeginReadCommentSection() ;
102 void ReadComment(TColStd_SequenceOfExtendedString& userComments) ;
103 Storage_Error EndReadCommentSection() ;
104 Storage_Error BeginWriteTypeSection() ;
105 void SetTypeSectionSize(const Standard_Integer aSize) ;
106 void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ;
107 Storage_Error EndWriteTypeSection() ;
108 Storage_Error BeginReadTypeSection() ;
109 Standard_Integer TypeSectionSize() ;
110 void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ;
111 Storage_Error EndReadTypeSection() ;
112 Storage_Error BeginWriteRootSection() ;
113 void SetRootSectionSize(const Standard_Integer aSize) ;
114 void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ;
115 Storage_Error EndWriteRootSection() ;
116 Storage_Error BeginReadRootSection() ;
117 Standard_Integer RootSectionSize() ;
118 void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ;
119 Storage_Error EndReadRootSection() ;
120 Storage_Error BeginWriteRefSection() ;
121 void SetRefSectionSize(const Standard_Integer aSize) ;
122 void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ;
123 Storage_Error EndWriteRefSection() ;
124 Storage_Error BeginReadRefSection() ;
125 Standard_Integer RefSectionSize() ;
126 void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ;
127 Storage_Error EndReadRefSection() ;
128 Storage_Error BeginWriteDataSection() ;
129 void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ;
130 void BeginWritePersistentObjectData() ;
131 void BeginWriteObjectData() ;
132 void EndWriteObjectData() ;
133 void EndWritePersistentObjectData() ;
134 Storage_Error EndWriteDataSection() ;
135 Storage_Error BeginReadDataSection() ;
136 void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ;
137 void BeginReadPersistentObjectData() ;
138 void BeginReadObjectData() ;
139 void EndReadObjectData() ;
140 void EndReadPersistentObjectData() ;
141 Storage_Error EndReadDataSection() ;
143 Storage_BaseDriver& PutReference(const Standard_Integer aValue) ;
144 Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ;
145 Storage_BaseDriver& operator <<(const Standard_Character aValue)
147 return PutCharacter(aValue);
150 Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ;
151 Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue)
153 return PutExtCharacter(aValue);
156 Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ;
157 Storage_BaseDriver& operator <<(const Standard_Integer aValue)
159 return PutInteger(aValue);
162 Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ;
163 Storage_BaseDriver& operator <<(const Standard_Boolean aValue)
165 return PutBoolean(aValue);
168 Storage_BaseDriver& PutReal(const Standard_Real aValue) ;
169 Storage_BaseDriver& operator <<(const Standard_Real aValue)
171 return PutReal(aValue);
174 Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ;
175 Storage_BaseDriver& operator <<(const Standard_ShortReal aValue)
177 return PutShortReal(aValue);
180 Storage_BaseDriver& GetReference(Standard_Integer& aValue) ;
181 Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ;
182 Storage_BaseDriver& operator >>(Standard_Character& aValue)
184 return GetCharacter(aValue);
187 Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ;
188 Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue)
190 return GetExtCharacter(aValue);
193 Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ;
194 Storage_BaseDriver& operator >>(Standard_Integer& aValue)
196 return GetInteger(aValue);
199 Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ;
200 Storage_BaseDriver& operator >>(Standard_Boolean& aValue)
202 return GetBoolean(aValue);
205 Storage_BaseDriver& GetReal(Standard_Real& aValue) ;
206 Storage_BaseDriver& operator >>(Standard_Real& aValue)
208 return GetReal(aValue);
211 Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ;
212 Storage_BaseDriver& operator >>(Standard_ShortReal& aValue)
214 return GetShortReal(aValue);
217 Storage_Error Close() ;
233 void ReadLine(TCollection_AsciiString& buffer) ;
234 void ReadWord(TCollection_AsciiString& buffer) ;
235 void ReadExtendedLine(TCollection_ExtendedString& buffer) ;
236 void WriteExtendedLine(const TCollection_ExtendedString& buffer) ;
237 void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ;
238 void ReadString(TCollection_AsciiString& buffer) ;
239 void FlushEndOfLine() ;
240 Storage_Error FindTag(const Standard_CString aTag) ;
251 static const Standard_CString MagicNumber() ;
256 //FSD_FStream myStream;
264 #pragma warning (default : 4275)
268 // other inline functions and methods (like "C++: function call" methods)