File indexing completed on 2025-01-18 10:03:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _BinObjMgt_Persistent_HeaderFile
0017 #define _BinObjMgt_Persistent_HeaderFile
0018
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022
0023 #include <TColStd_SequenceOfAddress.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <Standard_ShortReal.hxx>
0026 #include <BinObjMgt_PChar.hxx>
0027 #include <BinObjMgt_PByte.hxx>
0028 #include <BinObjMgt_PExtChar.hxx>
0029 #include <BinObjMgt_PInteger.hxx>
0030 #include <BinObjMgt_PReal.hxx>
0031 #include <BinObjMgt_PShortReal.hxx>
0032 #include <BinObjMgt_Position.hxx>
0033 #include <Standard_OStream.hxx>
0034 #include <Standard_IStream.hxx>
0035 class TCollection_AsciiString;
0036 class TCollection_ExtendedString;
0037 class TDF_Label;
0038 class Standard_GUID;
0039 class TDF_Data;
0040
0041
0042
0043
0044
0045
0046
0047
0048 class BinObjMgt_Persistent
0049 {
0050 public:
0051
0052 DEFINE_STANDARD_ALLOC
0053
0054
0055
0056 Standard_EXPORT BinObjMgt_Persistent();
0057
0058 Standard_EXPORT BinObjMgt_Persistent& PutCharacter (const Standard_Character theValue);
0059 BinObjMgt_Persistent& operator << (const Standard_Character theValue)
0060 {
0061 return PutCharacter(theValue);
0062 }
0063
0064 Standard_EXPORT BinObjMgt_Persistent& PutByte (const Standard_Byte theValue);
0065 BinObjMgt_Persistent& operator << (const Standard_Byte theValue)
0066 {
0067 return PutByte(theValue);
0068 }
0069
0070 Standard_EXPORT BinObjMgt_Persistent& PutExtCharacter (const Standard_ExtCharacter theValue);
0071 BinObjMgt_Persistent& operator << (const Standard_ExtCharacter theValue)
0072 {
0073 return PutExtCharacter(theValue);
0074 }
0075
0076 Standard_EXPORT BinObjMgt_Persistent& PutInteger (const Standard_Integer theValue);
0077 BinObjMgt_Persistent& operator << (const Standard_Integer theValue)
0078 {
0079 return PutInteger(theValue);
0080 }
0081
0082 BinObjMgt_Persistent& PutBoolean (const Standard_Boolean theValue);
0083 BinObjMgt_Persistent& operator << (const Standard_Boolean theValue)
0084 {
0085 return PutBoolean(theValue);
0086 }
0087
0088 Standard_EXPORT BinObjMgt_Persistent& PutReal (const Standard_Real theValue);
0089 BinObjMgt_Persistent& operator << (const Standard_Real theValue)
0090 {
0091 return PutReal(theValue);
0092 }
0093
0094 Standard_EXPORT BinObjMgt_Persistent& PutShortReal (const Standard_ShortReal theValue);
0095 BinObjMgt_Persistent& operator << (const Standard_ShortReal theValue)
0096 {
0097 return PutShortReal(theValue);
0098 }
0099
0100
0101 Standard_EXPORT BinObjMgt_Persistent& PutCString (const Standard_CString theValue);
0102 BinObjMgt_Persistent& operator << (const Standard_CString theValue)
0103 {
0104 return PutCString(theValue);
0105 }
0106
0107
0108 Standard_EXPORT BinObjMgt_Persistent& PutAsciiString (const TCollection_AsciiString& theValue);
0109 BinObjMgt_Persistent& operator << (const TCollection_AsciiString& theValue)
0110 {
0111 return PutAsciiString(theValue);
0112 }
0113
0114
0115 Standard_EXPORT BinObjMgt_Persistent& PutExtendedString (const TCollection_ExtendedString& theValue);
0116 BinObjMgt_Persistent& operator << (const TCollection_ExtendedString& theValue)
0117 {
0118 return PutExtendedString(theValue);
0119 }
0120
0121 Standard_EXPORT BinObjMgt_Persistent& PutLabel (const TDF_Label& theValue);
0122 BinObjMgt_Persistent& operator << (const TDF_Label& theValue)
0123 {
0124 return PutLabel(theValue);
0125 }
0126
0127 Standard_EXPORT BinObjMgt_Persistent& PutGUID (const Standard_GUID& theValue);
0128 BinObjMgt_Persistent& operator << (const Standard_GUID& theValue)
0129 {
0130 return PutGUID(theValue);
0131 }
0132
0133
0134 Standard_EXPORT BinObjMgt_Persistent& PutCharArray (const BinObjMgt_PChar theArray, const Standard_Integer theLength);
0135
0136
0137 Standard_EXPORT BinObjMgt_Persistent& PutByteArray (const BinObjMgt_PByte theArray, const Standard_Integer theLength);
0138
0139
0140 Standard_EXPORT BinObjMgt_Persistent& PutExtCharArray (const BinObjMgt_PExtChar theArray, const Standard_Integer theLength);
0141
0142
0143 Standard_EXPORT BinObjMgt_Persistent& PutIntArray (const BinObjMgt_PInteger theArray, const Standard_Integer theLength);
0144
0145
0146 Standard_EXPORT BinObjMgt_Persistent& PutRealArray (const BinObjMgt_PReal theArray, const Standard_Integer theLength);
0147
0148
0149 Standard_EXPORT BinObjMgt_Persistent& PutShortRealArray (const BinObjMgt_PShortReal theArray, const Standard_Integer theLength);
0150
0151 Standard_EXPORT const BinObjMgt_Persistent& GetCharacter (Standard_Character& theValue) const;
0152 const BinObjMgt_Persistent& operator >> (Standard_Character& theValue) const
0153 {
0154 return GetCharacter(theValue);
0155 }
0156
0157 Standard_EXPORT const BinObjMgt_Persistent& GetByte (Standard_Byte& theValue) const;
0158 const BinObjMgt_Persistent& operator >> (Standard_Byte& theValue) const
0159 {
0160 return GetByte(theValue);
0161 }
0162
0163 Standard_EXPORT const BinObjMgt_Persistent& GetExtCharacter (Standard_ExtCharacter& theValue) const;
0164 const BinObjMgt_Persistent& operator >> (Standard_ExtCharacter& theValue) const
0165 {
0166 return GetExtCharacter(theValue);
0167 }
0168
0169 Standard_EXPORT const BinObjMgt_Persistent& GetInteger (Standard_Integer& theValue) const;
0170 const BinObjMgt_Persistent& operator >> (Standard_Integer& theValue) const
0171 {
0172 return GetInteger(theValue);
0173 }
0174
0175 const BinObjMgt_Persistent& GetBoolean (Standard_Boolean& theValue) const;
0176 const BinObjMgt_Persistent& operator >> (Standard_Boolean& theValue) const
0177 {
0178 return GetBoolean(theValue);
0179 }
0180
0181 Standard_EXPORT const BinObjMgt_Persistent& GetReal (Standard_Real& theValue) const;
0182 const BinObjMgt_Persistent& operator >> (Standard_Real& theValue) const
0183 {
0184 return GetReal(theValue);
0185 }
0186
0187 Standard_EXPORT const BinObjMgt_Persistent& GetShortReal (Standard_ShortReal& theValue) const;
0188 const BinObjMgt_Persistent& operator >> (Standard_ShortReal& theValue) const
0189 {
0190 return GetShortReal(theValue);
0191 }
0192
0193 Standard_EXPORT const BinObjMgt_Persistent& GetAsciiString (TCollection_AsciiString& theValue) const;
0194 const BinObjMgt_Persistent& operator >> (TCollection_AsciiString& theValue) const
0195 {
0196 return GetAsciiString(theValue);
0197 }
0198
0199 Standard_EXPORT const BinObjMgt_Persistent& GetExtendedString (TCollection_ExtendedString& theValue) const;
0200 const BinObjMgt_Persistent& operator >> (TCollection_ExtendedString& theValue) const
0201 {
0202 return GetExtendedString(theValue);
0203 }
0204
0205 Standard_EXPORT const BinObjMgt_Persistent& GetLabel (const Handle(TDF_Data)& theDS, TDF_Label& theValue) const;
0206
0207 Standard_EXPORT const BinObjMgt_Persistent& GetGUID (Standard_GUID& theValue) const;
0208 const BinObjMgt_Persistent& operator >> (Standard_GUID& theValue) const
0209 {
0210 return GetGUID(theValue);
0211 }
0212
0213
0214
0215
0216 Standard_EXPORT const BinObjMgt_Persistent& GetCharArray (const BinObjMgt_PChar theArray, const Standard_Integer theLength) const;
0217
0218
0219
0220
0221 Standard_EXPORT const BinObjMgt_Persistent& GetByteArray (const BinObjMgt_PByte theArray, const Standard_Integer theLength) const;
0222
0223
0224
0225
0226 Standard_EXPORT const BinObjMgt_Persistent& GetExtCharArray (const BinObjMgt_PExtChar theArray, const Standard_Integer theLength) const;
0227
0228
0229
0230
0231 Standard_EXPORT const BinObjMgt_Persistent& GetIntArray (const BinObjMgt_PInteger theArray, const Standard_Integer theLength) const;
0232
0233
0234
0235
0236 Standard_EXPORT const BinObjMgt_Persistent& GetRealArray (const BinObjMgt_PReal theArray, const Standard_Integer theLength) const;
0237
0238
0239
0240
0241 Standard_EXPORT const BinObjMgt_Persistent& GetShortRealArray (const BinObjMgt_PShortReal theArray, const Standard_Integer theLength) const;
0242
0243
0244 Standard_Integer Position() const;
0245
0246
0247
0248
0249 Standard_Boolean SetPosition (const Standard_Integer thePos) const;
0250
0251
0252
0253 void Truncate();
0254
0255
0256 Standard_Boolean IsError() const;
0257 Standard_Boolean operator !() const
0258 {
0259 return IsError();
0260 }
0261
0262
0263 Standard_Boolean IsOK() const;
0264 operator Standard_Boolean () const { return IsOK(); }
0265
0266
0267 Standard_EXPORT void Init();
0268
0269
0270 void SetId (const Standard_Integer theId);
0271
0272
0273 void SetTypeId (const Standard_Integer theId);
0274
0275
0276 Standard_Integer Id() const;
0277
0278
0279 Standard_Integer TypeId() const;
0280
0281
0282 Standard_Integer Length() const;
0283
0284
0285
0286
0287
0288 Standard_EXPORT Standard_OStream& Write (Standard_OStream& theOS, const Standard_Boolean theDirectStream = Standard_False);
0289
0290
0291
0292
0293 Standard_EXPORT Standard_IStream& Read (Standard_IStream& theIS);
0294
0295
0296
0297 Standard_EXPORT void Destroy();
0298 ~BinObjMgt_Persistent()
0299 {
0300 Destroy();
0301 }
0302
0303
0304 Standard_EXPORT void SetOStream (Standard_OStream& theStream) { myOStream = &theStream; }
0305
0306 Standard_EXPORT void SetIStream (Standard_IStream& theStream) { myIStream = &theStream; }
0307
0308 Standard_EXPORT Standard_OStream* GetOStream();
0309
0310 Standard_EXPORT Standard_IStream* GetIStream();
0311
0312 Standard_EXPORT Standard_Boolean IsDirect() { return myDirectWritingIsEnabled; }
0313
0314 Standard_EXPORT Handle(BinObjMgt_Position) StreamStart() { return myStreamStart; }
0315
0316 private:
0317
0318
0319
0320
0321
0322 void alignOffset (const Standard_Integer theSize, const Standard_Boolean toClear = Standard_False) const;
0323
0324
0325
0326
0327 Standard_Integer prepareForPut (const Standard_Integer theSize);
0328
0329
0330 Standard_EXPORT void incrementData (const Standard_Integer theNbPieces);
0331
0332
0333
0334 Standard_Boolean noMoreData (const Standard_Integer theSize) const;
0335
0336
0337 Standard_EXPORT void putArray (const Standard_Address theArray, const Standard_Integer theSize);
0338
0339
0340 Standard_EXPORT void getArray (const Standard_Address theArray, const Standard_Integer theSize) const;
0341
0342
0343 Standard_EXPORT void inverseExtCharData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize);
0344
0345
0346 Standard_EXPORT void inverseIntData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize);
0347
0348
0349 Standard_EXPORT void inverseRealData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize);
0350
0351
0352 Standard_EXPORT void inverseShortRealData (const Standard_Integer theIndex, const Standard_Integer theOffset, const Standard_Integer theSize);
0353
0354
0355 TColStd_SequenceOfAddress myData;
0356 Standard_Integer myIndex;
0357 Standard_Integer myOffset;
0358 Standard_Integer mySize;
0359 Standard_Boolean myIsError;
0360 Standard_OStream* myOStream;
0361 Standard_IStream* myIStream;
0362 Standard_Boolean myDirectWritingIsEnabled;
0363 Handle(BinObjMgt_Position) myStreamStart;
0364 };
0365
0366
0367 #include <BinObjMgt_Persistent.lxx>
0368
0369
0370
0371
0372
0373 #endif