File indexing completed on 2025-01-18 10:04:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _StdLPersistent_NamedData_HeaderFile
0016 #define _StdLPersistent_NamedData_HeaderFile
0017
0018 #include <StdObjMgt_Attribute.hxx>
0019 #include <StdLPersistent_HArray1.hxx>
0020 #include <StdLPersistent_HArray2.hxx>
0021
0022 #include <TDataStd_NamedData.hxx>
0023 #include <TCollection_HExtendedString.hxx>
0024
0025 class StdLPersistent_NamedData : public StdObjMgt_Attribute<TDataStd_NamedData>
0026 {
0027 template <class HValuesArray>
0028 class pMapData
0029 {
0030 public:
0031 typedef typename HValuesArray::ValueType ValueType;
0032
0033 inline void Read (StdObjMgt_ReadData& theReadData)
0034 { theReadData >> myKeys >> myValues; }
0035 inline void Write (StdObjMgt_WriteData& theWriteData) const
0036 { theWriteData << myKeys << myValues; }
0037
0038 inline operator bool() const
0039 { return !myKeys.IsNull(); }
0040
0041 const TCollection_ExtendedString& Key (Standard_Integer theIndex) const
0042 { return myKeys->Array()->Value(theIndex)->ExtString()->String(); }
0043
0044 ValueType Value (Standard_Integer theIndex) const
0045 { return myValues ? myValues->Array()->Value(theIndex) : 0; }
0046
0047 private:
0048 Handle(StdLPersistent_HArray1::Persistent) myKeys;
0049 Handle(HValuesArray) myValues;
0050 };
0051
0052 public:
0053
0054 inline void Read (StdObjMgt_ReadData& theReadData)
0055 {
0056 theReadData >> myDimensions;
0057 myInts .Read (theReadData);
0058 myReals .Read (theReadData);
0059 myStrings .Read (theReadData);
0060 myBytes .Read (theReadData);
0061 myIntArrays .Read (theReadData);
0062 myRealArrays.Read (theReadData);
0063 }
0064
0065
0066 inline void Write (StdObjMgt_WriteData& theWriteData) const
0067 {
0068 theWriteData << myDimensions;
0069 myInts.Write(theWriteData);
0070 myReals.Write(theWriteData);
0071 myStrings.Write(theWriteData);
0072 myBytes.Write(theWriteData);
0073 myIntArrays.Write(theWriteData);
0074 myRealArrays.Write(theWriteData);
0075 }
0076
0077
0078 void PChildren(StdObjMgt_Persistent::SequenceOfPersistent&) const {}
0079
0080
0081 Standard_CString PName() const { return "PDataStd_NamedData"; }
0082
0083
0084 void Import (const Handle(TDataStd_NamedData)& theAttribute) const;
0085
0086 private:
0087 inline Standard_Integer lower (Standard_Integer theIndex) const;
0088 inline Standard_Integer upper (Standard_Integer theIndex) const;
0089
0090 private:
0091 Handle(StdLPersistent_HArray2::Integer) myDimensions;
0092 pMapData<StdLPersistent_HArray1::Integer> myInts;
0093 pMapData<StdLPersistent_HArray1::Real> myReals;
0094 pMapData<StdLPersistent_HArray1::Persistent> myStrings;
0095 pMapData<StdLPersistent_HArray1::Byte> myBytes;
0096 pMapData<StdLPersistent_HArray1::Persistent> myIntArrays;
0097 pMapData<StdLPersistent_HArray1::Persistent> myRealArrays;
0098 };
0099
0100 #endif