0025266: Debug statements in the source are getting flushed on to the console
[occt.git] / src / DDF / DDF_IOStream.hxx
CommitLineData
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
34class Storage_StreamTypeMismatchError;
35class Storage_StreamFormatError;
36class Storage_StreamWriteError;
37class Storage_StreamExtCharParityError;
38
39class TColStd_SequenceOfExtendedString;
40
41#ifndef Standard_EXPORT
42#ifdef WNT
43#define Standard_EXPORT __declspec(dllexport)
44#else
45#define Standard_EXPORT
46#endif
47#endif
48#ifdef WNT
49#pragma warning (disable : 4275)
50#endif
51
52class Standard_EXPORT DDF_IOStream : public Storage_BaseDriver {
53
54public:
55
56 // Methods PUBLIC
57 //
58DDF_IOStream();
59 Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ;
60 Storage_Error Open(istream* anIStream) ;
61 Storage_Error Open(ostream* anOStream) ;
62 Standard_Boolean IsEnd() ;
63 Storage_Position Tell() { return -1; }
64static Storage_Error IsGoodFileType(istream* anIStream) ;
65 Storage_Error BeginWriteInfoSection() ;
66 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) ;
67 Storage_Error EndWriteInfoSection() ;
68 Storage_Error BeginReadInfoSection() ;
69 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) ;
70 Storage_Error EndReadInfoSection() ;
71 Storage_Error BeginWriteCommentSection() ;
72 void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ;
73 Storage_Error EndWriteCommentSection() ;
74 Storage_Error BeginReadCommentSection() ;
75 void ReadComment(TColStd_SequenceOfExtendedString& userComments) ;
76 Storage_Error EndReadCommentSection() ;
77 Storage_Error BeginWriteTypeSection() ;
78 void SetTypeSectionSize(const Standard_Integer aSize) ;
79 void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ;
80 Storage_Error EndWriteTypeSection() ;
81 Storage_Error BeginReadTypeSection() ;
82 Standard_Integer TypeSectionSize() ;
83 void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ;
84 Storage_Error EndReadTypeSection() ;
85 Storage_Error BeginWriteRootSection() ;
86 void SetRootSectionSize(const Standard_Integer aSize) ;
87 void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ;
88 Storage_Error EndWriteRootSection() ;
89 Storage_Error BeginReadRootSection() ;
90 Standard_Integer RootSectionSize() ;
91 void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ;
92 Storage_Error EndReadRootSection() ;
93 Storage_Error BeginWriteRefSection() ;
94 void SetRefSectionSize(const Standard_Integer aSize) ;
95 void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ;
96 Storage_Error EndWriteRefSection() ;
97 Storage_Error BeginReadRefSection() ;
98 Standard_Integer RefSectionSize() ;
99 void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ;
100 Storage_Error EndReadRefSection() ;
101 Storage_Error BeginWriteDataSection() ;
102 void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ;
103 void BeginWritePersistentObjectData() ;
104 void BeginWriteObjectData() ;
105 void EndWriteObjectData() ;
106 void EndWritePersistentObjectData() ;
107 Storage_Error EndWriteDataSection() ;
108 Storage_Error BeginReadDataSection() ;
109 void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ;
110 void BeginReadPersistentObjectData() ;
111 void BeginReadObjectData() ;
112 void EndReadObjectData() ;
113 void EndReadPersistentObjectData() ;
114 Storage_Error EndReadDataSection() ;
115 void SkipObject() ;
116 Storage_BaseDriver& PutReference(const Standard_Integer aValue) ;
117 Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ;
118 Storage_BaseDriver& operator <<(const Standard_Character aValue)
119{
120 return PutCharacter(aValue);
121}
122
123 Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ;
124 Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue)
125{
126 return PutExtCharacter(aValue);
127}
128
129 Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ;
130 Storage_BaseDriver& operator <<(const Standard_Integer aValue)
131{
132 return PutInteger(aValue);
133}
134
135 Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ;
136 Storage_BaseDriver& operator <<(const Standard_Boolean aValue)
137{
138 return PutBoolean(aValue);
139}
140
141 Storage_BaseDriver& PutReal(const Standard_Real aValue) ;
142 Storage_BaseDriver& operator <<(const Standard_Real aValue)
143{
144 return PutReal(aValue);
145}
146
147 Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ;
148 Storage_BaseDriver& operator <<(const Standard_ShortReal aValue)
149{
150 return PutShortReal(aValue);
151}
152
153 Storage_BaseDriver& GetReference(Standard_Integer& aValue) ;
154 Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ;
155 Storage_BaseDriver& operator >>(Standard_Character& aValue)
156{
157 return GetCharacter(aValue);
158}
159
160 Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ;
161 Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue)
162{
163 return GetExtCharacter(aValue);
164}
165
166 Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ;
167 Storage_BaseDriver& operator >>(Standard_Integer& aValue)
168{
169 return GetInteger(aValue);
170}
171
172 Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ;
173 Storage_BaseDriver& operator >>(Standard_Boolean& aValue)
174{
175 return GetBoolean(aValue);
176}
177
178 Storage_BaseDriver& GetReal(Standard_Real& aValue) ;
179 Storage_BaseDriver& operator >>(Standard_Real& aValue)
180{
181 return GetReal(aValue);
182}
183
184 Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ;
185 Storage_BaseDriver& operator >>(Standard_ShortReal& aValue)
186{
187 return GetShortReal(aValue);
188}
189
190 Storage_Error Close() ;
191 void Destroy() ;
192~DDF_IOStream()
193{
194 Destroy();
195}
196
197
198
199
200
201
202protected:
203
204 // Methods PROTECTED
205 //
206 void ReadLine(TCollection_AsciiString& buffer) ;
207 void ReadWord(TCollection_AsciiString& buffer) ;
208 void ReadExtendedLine(TCollection_ExtendedString& buffer) ;
209 void WriteExtendedLine(const TCollection_ExtendedString& buffer) ;
210 void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ;
211 void ReadString(TCollection_AsciiString& buffer) ;
212 void FlushEndOfLine() ;
213 Storage_Error FindTag(const Standard_CString aTag) ;
214
215
216 // Fields PROTECTED
217 //
218
219
220private:
221
222 // Methods PRIVATE
223 //
224static const Standard_CString MagicNumber() ;
225
226
227 // Fields PRIVATE
228 //
229//FSD_FStream myStream;
230istream* myIStream;
231ostream* myOStream;
232
233
234};
235
236#ifdef WNT
237#pragma warning (default : 4275)
238#endif
239
240
241// other inline functions and methods (like "C++: function call" methods)
242//
243#endif