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