File: BinObjMgt_Persistent.hxx

package info (click to toggle)
oce 0.18.2-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 301,460 kB
  • sloc: cpp: 1,190,610; ansic: 67,225; sh: 11,667; tcl: 7,954; cs: 5,221; python: 2,867; java: 1,522; makefile: 344; xml: 292; perl: 37
file content (363 lines) | stat: -rw-r--r-- 13,383 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _BinObjMgt_Persistent_HeaderFile
#define _BinObjMgt_Persistent_HeaderFile

#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>

#include <TColStd_SequenceOfAddress.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Character.hxx>
#include <Standard_Byte.hxx>
#include <Standard_ExtCharacter.hxx>
#include <Standard_Real.hxx>
#include <Standard_ShortReal.hxx>
#include <Standard_CString.hxx>
#include <BinObjMgt_PChar.hxx>
#include <BinObjMgt_PByte.hxx>
#include <BinObjMgt_PExtChar.hxx>
#include <BinObjMgt_PInteger.hxx>
#include <BinObjMgt_PReal.hxx>
#include <BinObjMgt_PShortReal.hxx>
#include <Handle_TDF_Data.hxx>
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
#include <Standard_Address.hxx>
class TCollection_AsciiString;
class TCollection_ExtendedString;
class TDF_Label;
class Standard_GUID;
class TDF_Data;


//! Binary persistent representation of an object.
//! Really it is used as a buffer for read/write an object.
//!
//! It takes care of Little/Big endian by inversing bytes
//! in objects of standard types (see FSD_FileHeader.hxx
//! for the default value of DO_INVERSE).
class BinObjMgt_Persistent 
{
public:

  DEFINE_STANDARD_ALLOC

  
  //! Empty constructor
  Standard_EXPORT BinObjMgt_Persistent();
  
  Standard_EXPORT   BinObjMgt_Persistent& PutCharacter (const Standard_Character theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_Character theValue) 
{
  return PutCharacter(theValue);
}
  
  Standard_EXPORT   BinObjMgt_Persistent& PutByte (const Standard_Byte theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_Byte theValue) 
{
  return PutByte(theValue);
}
  
  Standard_EXPORT   BinObjMgt_Persistent& PutExtCharacter (const Standard_ExtCharacter theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_ExtCharacter theValue) 
{
  return PutExtCharacter(theValue);
}
  
  Standard_EXPORT   BinObjMgt_Persistent& PutInteger (const Standard_Integer theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_Integer theValue) 
{
  return PutInteger(theValue);
}
  
      BinObjMgt_Persistent& PutBoolean (const Standard_Boolean theValue) ;
    BinObjMgt_Persistent& operator << (const Standard_Boolean theValue) 
{
  return PutBoolean(theValue);
}
  
  Standard_EXPORT   BinObjMgt_Persistent& PutReal (const Standard_Real theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_Real theValue) 
{
  return PutReal(theValue);
}
  
  Standard_EXPORT   BinObjMgt_Persistent& PutShortReal (const Standard_ShortReal theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_ShortReal theValue) 
{
  return PutShortReal(theValue);
}
  
  //! Offset in output buffer is not aligned
  Standard_EXPORT   BinObjMgt_Persistent& PutCString (const Standard_CString theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_CString theValue) 
{
  return PutCString(theValue);
}
  
  //! Offset in output buffer is word-aligned
  Standard_EXPORT   BinObjMgt_Persistent& PutAsciiString (const TCollection_AsciiString& theValue) ;
  BinObjMgt_Persistent& operator << (const TCollection_AsciiString& theValue) 
{
  return PutAsciiString(theValue);
}
  
  //! Offset in output buffer is word-aligned
  Standard_EXPORT   BinObjMgt_Persistent& PutExtendedString (const TCollection_ExtendedString& theValue) ;
  BinObjMgt_Persistent& operator << (const TCollection_ExtendedString& theValue) 
{
  return PutExtendedString(theValue);
}
  
  Standard_EXPORT   BinObjMgt_Persistent& PutLabel (const TDF_Label& theValue) ;
  BinObjMgt_Persistent& operator << (const TDF_Label& theValue) 
{
  return PutLabel(theValue);
}
  
  Standard_EXPORT   BinObjMgt_Persistent& PutGUID (const Standard_GUID& theValue) ;
  BinObjMgt_Persistent& operator << (const Standard_GUID& theValue) 
{
  return PutGUID(theValue);
}
  
  //! Put C array of char, theLength is the number of elements
  Standard_EXPORT   BinObjMgt_Persistent& PutCharArray (const BinObjMgt_PChar theArray, const Standard_Integer theLength) ;
  
  //! Put C array of unsigned chars, theLength is the number of elements
  Standard_EXPORT   BinObjMgt_Persistent& PutByteArray (const BinObjMgt_PByte theArray, const Standard_Integer theLength) ;
  
  //! Put C array of ExtCharacter, theLength is the number of elements
  Standard_EXPORT   BinObjMgt_Persistent& PutExtCharArray (const BinObjMgt_PExtChar theArray, const Standard_Integer theLength) ;
  
  //! Put C array of int, theLength is the number of elements
  Standard_EXPORT   BinObjMgt_Persistent& PutIntArray (const BinObjMgt_PInteger theArray, const Standard_Integer theLength) ;
  
  //! Put C array of double, theLength is the number of elements
  Standard_EXPORT   BinObjMgt_Persistent& PutRealArray (const BinObjMgt_PReal theArray, const Standard_Integer theLength) ;
  
  //! Put C array of float, theLength is the number of elements
  Standard_EXPORT   BinObjMgt_Persistent& PutShortRealArray (const BinObjMgt_PShortReal theArray, const Standard_Integer theLength) ;
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetCharacter (Standard_Character& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (Standard_Character& theValue)  const
{
  return GetCharacter(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetByte (Standard_Byte& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (Standard_Byte& theValue)  const
{
  return GetByte(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetExtCharacter (Standard_ExtCharacter& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (Standard_ExtCharacter& theValue)  const
{
  return GetExtCharacter(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetInteger (Standard_Integer& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (Standard_Integer& theValue)  const
{
  return GetInteger(theValue);
}
  
     const  BinObjMgt_Persistent& GetBoolean (Standard_Boolean& theValue)  const;
   const  BinObjMgt_Persistent& operator >> (Standard_Boolean& theValue)  const
{
  return GetBoolean(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetReal (Standard_Real& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (Standard_Real& theValue)  const
{
  return GetReal(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetShortReal (Standard_ShortReal& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (Standard_ShortReal& theValue)  const
{
  return GetShortReal(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetAsciiString (TCollection_AsciiString& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (TCollection_AsciiString& theValue)  const
{
  return GetAsciiString(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetExtendedString (TCollection_ExtendedString& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (TCollection_ExtendedString& theValue)  const
{
  return GetExtendedString(theValue);
}
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetLabel (const Handle(TDF_Data)& theDS, TDF_Label& theValue)  const;
  
  Standard_EXPORT  const  BinObjMgt_Persistent& GetGUID (Standard_GUID& theValue)  const;
 const  BinObjMgt_Persistent& operator >> (Standard_GUID& theValue)  const
{
  return GetGUID(theValue);
}
  
  //! Get C array of char, theLength is the number of elements;
  //! theArray must point to a
  //! space enough to place theLength elements
  Standard_EXPORT  const  BinObjMgt_Persistent& GetCharArray (const BinObjMgt_PChar theArray, const Standard_Integer theLength)  const;
  
  //! Get C array of unsigned chars, theLength is the number of elements;
  //! theArray must point to a
  //! space enough to place theLength elements
  Standard_EXPORT  const  BinObjMgt_Persistent& GetByteArray (const BinObjMgt_PByte theArray, const Standard_Integer theLength)  const;
  
  //! Get C array of ExtCharacter, theLength is the number of elements;
  //! theArray must point to a
  //! space enough to place theLength elements
  Standard_EXPORT  const  BinObjMgt_Persistent& GetExtCharArray (const BinObjMgt_PExtChar theArray, const Standard_Integer theLength)  const;
  
  //! Get C array of int, theLength is the number of elements;
  //! theArray must point to a
  //! space enough to place theLength elements
  Standard_EXPORT  const  BinObjMgt_Persistent& GetIntArray (const BinObjMgt_PInteger theArray, const Standard_Integer theLength)  const;
  
  //! Get C array of double, theLength is the number of elements;
  //! theArray must point to a
  //! space enough to place theLength elements
  Standard_EXPORT  const  BinObjMgt_Persistent& GetRealArray (const BinObjMgt_PReal theArray, const Standard_Integer theLength)  const;
  
  //! Get C array of float, theLength is the number of elements;
  //! theArray must point to a
  //! space enough to place theLength elements
  Standard_EXPORT  const  BinObjMgt_Persistent& GetShortRealArray (const BinObjMgt_PShortReal theArray, const Standard_Integer theLength)  const;
  
  //! Tells the current position for get/put
      Standard_Integer Position()  const;
  
  //! Sets the current position for get/put.
  //! Resets an error state depending on the validity of thePos.
  //! Returns the new state (value of IsOK())
      Standard_Boolean SetPosition (const Standard_Integer thePos)  const;
  
  //! Truncates the buffer by current position,
  //! i.e. updates mySize
      void Truncate() ;
  
  //! Indicates an error after Get methods or SetPosition
      Standard_Boolean IsError()  const;
    Standard_Boolean operator !()  const
{
  return IsError();
}
  
  //! Indicates a good state after Get methods or SetPosition
      Standard_Boolean IsOK()  const;
operator Standard_Boolean () const { return IsOK(); }
  
  //! Initializes me to reuse again
  Standard_EXPORT   void Init() ;
  
  //! Sets the Id of the object
      void SetId (const Standard_Integer theId) ;
  
  //! Sets the Id of the type of the object
      void SetTypeId (const Standard_Integer theId) ;
  
  //! Returns the Id of the object
      Standard_Integer Id()  const;
  
  //! Returns the Id of the type of the object
      Standard_Integer TypeId()  const;
  
  //! Returns the length of data
      Standard_Integer Length()  const;
  
  //! Stores <me> to the stream.
  //! inline Standard_OStream& operator<< (Standard_OStream&,
  //! BinObjMgt_Persistent&) is also available
  Standard_EXPORT   Standard_OStream& Write (Standard_OStream& theOS) ;
  
  //! Retrieves <me> from the stream.
  //! inline Standard_IStream& operator>> (Standard_IStream&,
  //! BinObjMgt_Persistent&) is also available
  Standard_EXPORT   Standard_IStream& Read (Standard_IStream& theIS) ;
  
  //! Frees the allocated memory;
  //! This object can be reused after call to Init
  Standard_EXPORT   void Destroy() ;
~BinObjMgt_Persistent()
{
  Destroy();
}




protected:





private:

  
  //! Aligns myOffset to the given size;
  //! enters the next piece if the end of the current one is reached;
  //! toClear==true means to fill unused space by 0
      void alignOffset (const Standard_Integer theSize, const Standard_Boolean toClear = Standard_False)  const;
  
  //! Prepares the room for theSize bytes;
  //! returns the number of pieces except for the current one
  //! are to be occupied
      Standard_Integer prepareForPut (const Standard_Integer theSize) ;
  
  //! Allocates theNbPieces more pieces
  Standard_EXPORT   void incrementData (const Standard_Integer theNbPieces) ;
  
  //! Checks if there is no more data of the given size starting
  //! from the current position in myData
      Standard_Boolean noMoreData (const Standard_Integer theSize)  const;
  
  //! Puts theLength bytes from theArray
  Standard_EXPORT   void putArray (const Standard_Address theArray, const Standard_Integer theSize) ;
  
  //! Gets theLength bytes into theArray
  Standard_EXPORT   void getArray (const Standard_Address theArray, const Standard_Integer theSize)  const;
  
  //! Inverses bytes in the data addressed by the given values
  Standard_EXPORT   void inverseExtCharData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize) ;
  
  //! Inverses bytes in the data addressed by the given values
  Standard_EXPORT   void inverseIntData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize) ;
  
  //! Inverses bytes in the data addressed by the given values
  Standard_EXPORT   void inverseRealData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize) ;
  
  //! Inverses bytes in the data addressed by the given values
  Standard_EXPORT   void inverseShortRealData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize) ;


  TColStd_SequenceOfAddress myData;
  Standard_Integer myIndex;
  Standard_Integer myOffset;
  Standard_Integer mySize;
  Standard_Boolean myIsError;


};


#include <BinObjMgt_Persistent.lxx>





#endif // _BinObjMgt_Persistent_HeaderFile