diff --git a/src/DDF/DDF_IOStream.cxx b/src/DDF/DDF_IOStream.cxx index 61d010421f..d116d3db96 100644 --- a/src/DDF/DDF_IOStream.cxx +++ b/src/DDF/DDF_IOStream.cxx @@ -281,7 +281,7 @@ void DDF_IOStream::ReadExtendedLine(TCollection_ExtendedString& buffer) void DDF_IOStream::ReadChar(TCollection_AsciiString& buffer, const Standard_Integer rsize) { - char c; + char c = '\0'; Standard_Integer ccount = 0; buffer.Clear(); @@ -1216,7 +1216,7 @@ Storage_Error DDF_IOStream::BeginReadDataSection() void DDF_IOStream::ReadPersistentObjectHeader(Standard_Integer& aRef, Standard_Integer& aType) { - char c; + char c = '\0'; myIStream->get(c); @@ -1256,7 +1256,7 @@ void DDF_IOStream::ReadPersistentObjectHeader(Standard_Integer& aRef, void DDF_IOStream::BeginReadPersistentObjectData() { - char c; + char c = '\0'; myIStream->get(c); while (c != '(') { if (IsEnd() || (c != ' ') || (c == '\n')) { @@ -1273,7 +1273,7 @@ void DDF_IOStream::BeginReadPersistentObjectData() void DDF_IOStream::BeginReadObjectData() { - char c; + char c = '\0'; myIStream->get(c); while (c != '(') { if (IsEnd() || (c != ' ') || (c == '\n')) { @@ -1290,7 +1290,7 @@ void DDF_IOStream::BeginReadObjectData() void DDF_IOStream::EndReadObjectData() { - char c; + char c = '\0'; myIStream->get(c); while (c != ')') { if (IsEnd() || (c != ' ') || (c == '\n')) { @@ -1307,7 +1307,7 @@ void DDF_IOStream::EndReadObjectData() void DDF_IOStream::EndReadPersistentObjectData() { - char c; + char c = '\0'; myIStream->get(c); while (c != ')') { diff --git a/src/FSD/FSD_CmpFile.cxx b/src/FSD/FSD_CmpFile.cxx index 594fe0a7b4..e23394c34b 100644 --- a/src/FSD/FSD_CmpFile.cxx +++ b/src/FSD/FSD_CmpFile.cxx @@ -325,7 +325,7 @@ void FSD_CmpFile::EndWritePersistentObjectData() void FSD_CmpFile::ReadPersistentObjectHeader(Standard_Integer& aRef, Standard_Integer& aType) { - char c; + char c = '\0'; myStream.get(c); @@ -388,7 +388,7 @@ void FSD_CmpFile::EndReadObjectData() void FSD_CmpFile::EndReadPersistentObjectData() { - char c; + char c = '\0'; myStream.get(c); while (c != '\n' && (c != '\r')) { diff --git a/src/FSD/FSD_File.cxx b/src/FSD/FSD_File.cxx index 10afce93a3..c02ee5c24f 100644 --- a/src/FSD/FSD_File.cxx +++ b/src/FSD/FSD_File.cxx @@ -280,7 +280,7 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer) void FSD_File::ReadChar(TCollection_AsciiString& buffer, const Standard_Size rsize) { - char c; + char c = '\0'; Standard_Size ccount = 0; buffer.Clear(); @@ -1234,7 +1234,7 @@ Storage_Error FSD_File::BeginReadDataSection() void FSD_File::ReadPersistentObjectHeader(Standard_Integer& aRef, Standard_Integer& aType) { - char c; + char c = '\0'; myStream.get(c); @@ -1277,7 +1277,7 @@ void FSD_File::ReadPersistentObjectHeader(Standard_Integer& aRef, void FSD_File::BeginReadPersistentObjectData() { - char c; + char c = '\0'; myStream.get(c); while (c != '(') { if (IsEnd() || (c != ' ') || (c == '\n')) { @@ -1296,8 +1296,7 @@ void FSD_File::BeginReadPersistentObjectData() void FSD_File::BeginReadObjectData() { - - char c; + char c = '\0'; myStream.get(c); while (c != '(') { if (IsEnd() || (c != ' ') || (c == '\n')) { @@ -1316,8 +1315,7 @@ void FSD_File::BeginReadObjectData() void FSD_File::EndReadObjectData() { - - char c; + char c = '\0'; myStream.get(c); while (c != ')') { if (IsEnd() || (c != ' ') || (c == '\n')) { @@ -1336,8 +1334,7 @@ void FSD_File::EndReadObjectData() void FSD_File::EndReadPersistentObjectData() { - - char c; + char c = '\0'; myStream.get(c); while (c != ')') { diff --git a/src/ShapePersistent/ShapePersistent_HArray1.hxx b/src/ShapePersistent/ShapePersistent_HArray1.hxx index 6ddbf7ccb0..a1a4b794f1 100644 --- a/src/ShapePersistent/ShapePersistent_HArray1.hxx +++ b/src/ShapePersistent/ShapePersistent_HArray1.hxx @@ -49,8 +49,10 @@ public: }; inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, Poly_Triangle& theTriangle) + (StdObjMgt_ReadData& theReadData, Poly_Triangle& theTriangle) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + Standard_Integer N1, N2, N3; theReadData >> N1 >> N2 >> N3; theTriangle.Set (N1, N2, N3); @@ -58,8 +60,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const Poly_Triangle& theTriangle) + (StdObjMgt_WriteData& theWriteData, const Poly_Triangle& theTriangle) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + Standard_Integer N1, N2, N3; theTriangle.Get(N1, N2, N3); theWriteData << N1 << N2 << N3; diff --git a/src/StdLPersistent/StdLPersistent_HArray1.cxx b/src/StdLPersistent/StdLPersistent_HArray1.cxx index 7318651fa5..c26202183c 100644 --- a/src/StdLPersistent/StdLPersistent_HArray1.cxx +++ b/src/StdLPersistent/StdLPersistent_HArray1.cxx @@ -24,13 +24,13 @@ void StdLPersistent_HArray1::base::Read (StdObjMgt_ReadData& theReadData) theReadData >> aLowerBound >> anUpperBound; createArray (aLowerBound, anUpperBound); - StdObjMgt_ReadData::Object anObjectData (theReadData); + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); Standard_Integer aSize; - anObjectData >> aSize; + theReadData >> aSize; for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++) - readValue (anObjectData, i); + readValue (theReadData, i); } //======================================================================= @@ -42,10 +42,10 @@ void StdLPersistent_HArray1::base::Write (StdObjMgt_WriteData& theWriteData) con Standard_Integer aLowerBound = lowerBound(), anUpperBound = upperBound(); theWriteData << aLowerBound << anUpperBound; - StdObjMgt_WriteData::Object anObjectData(theWriteData); + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); Standard_Integer aSize = anUpperBound - aLowerBound + 1; - anObjectData << aSize; + theWriteData << aSize; for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++) writeValue(theWriteData, i); diff --git a/src/StdLPersistent/StdLPersistent_HArray2.cxx b/src/StdLPersistent/StdLPersistent_HArray2.cxx index cde9009dd8..dffa7662d5 100644 --- a/src/StdLPersistent/StdLPersistent_HArray2.cxx +++ b/src/StdLPersistent/StdLPersistent_HArray2.cxx @@ -27,14 +27,14 @@ void StdLPersistent_HArray2::base::Read (StdObjMgt_ReadData& theReadData) theReadData >> aLowerRow >> aLowerCol >> anUpperRow >> anUpperCol; createArray (aLowerRow, aLowerCol, anUpperRow, anUpperCol); - StdObjMgt_ReadData::Object anObjectData (theReadData); + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); Standard_Integer aSize; - anObjectData >> aSize; + theReadData >> aSize; for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++) for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++) - readValue (anObjectData, aRow, aCol); + readValue (theReadData, aRow, aCol); } //======================================================================= @@ -48,12 +48,12 @@ void StdLPersistent_HArray2::base::Write (StdObjMgt_WriteData& theWriteData) con upperBound(anUpperRow, anUpperCol); theWriteData << aLowerRow << aLowerCol << anUpperRow << anUpperCol; - StdObjMgt_WriteData::Object anObjectData(theWriteData); + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); Standard_Integer aSize = (anUpperRow - aLowerRow + 1) * (anUpperCol - aLowerCol + 1); - anObjectData << aSize; + theWriteData << aSize; for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++) for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++) - writeValue(anObjectData, aRow, aCol); + writeValue(theWriteData, aRow, aCol); } diff --git a/src/StdLPersistent/StdLPersistent_HString.cxx b/src/StdLPersistent/StdLPersistent_HString.cxx index 436f1ca2fc..a14367796c 100644 --- a/src/StdLPersistent/StdLPersistent_HString.cxx +++ b/src/StdLPersistent/StdLPersistent_HString.cxx @@ -26,16 +26,16 @@ template void StdLPersistent_HString::instance::Read (StdObjMgt_ReadData& theReadData) { - StdObjMgt_ReadData::Object anObjectData (theReadData); + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); Standard_Integer aSize; - anObjectData >> aSize; + theReadData >> aSize; myValue = new StringClass (aSize, 0); for (Standard_Integer i = 1; i <= aSize; i++) { CharType aChar; - anObjectData >> aChar; + theReadData >> aChar; myValue->SetValue (i, aChar); } } @@ -48,15 +48,15 @@ template void StdLPersistent_HString::instance::Write (StdObjMgt_WriteData& theWriteData) const { - StdObjMgt_WriteData::Object anObjectData(theWriteData); + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); Standard_Integer aSize = myValue->Length(); - anObjectData << aSize; + theWriteData << aSize; for (Standard_Integer i = 1; i <= aSize; i++) { CharType aChar (0); - anObjectData << aChar; + theWriteData << aChar; } } diff --git a/src/StdObjMgt/StdObjMgt_ReadData.cxx b/src/StdObjMgt/StdObjMgt_ReadData.cxx index 9bb92145b1..5d80270ce1 100644 --- a/src/StdObjMgt/StdObjMgt_ReadData.cxx +++ b/src/StdObjMgt/StdObjMgt_ReadData.cxx @@ -47,8 +47,10 @@ Handle(StdObjMgt_Persistent) StdObjMgt_ReadData::ReadReference() //purpose : Read persistent data from a file //======================================================================= StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID) + (StdObjMgt_ReadData& theReadData, Standard_GUID& theGUID) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + Standard_Integer a32b; Standard_ExtCharacter a16b[3]; Standard_Character a8b [6]; diff --git a/src/StdObjMgt/StdObjMgt_ReadData.hxx b/src/StdObjMgt/StdObjMgt_ReadData.hxx index 8582e14df7..f81d379a02 100644 --- a/src/StdObjMgt/StdObjMgt_ReadData.hxx +++ b/src/StdObjMgt/StdObjMgt_ReadData.hxx @@ -26,7 +26,24 @@ class Standard_GUID; class StdObjMgt_ReadData { public: - class Object; + //! Auxiliary class used to automate begin and end of + //! reading object (eating opening and closing parenthesis) + //! at constructor and destructor + class ObjectSentry + { + public: + explicit ObjectSentry (StdObjMgt_ReadData& theData) : myReadData (&theData) + { myReadData->myDriver->BeginReadObjectData(); } + + ~ObjectSentry () + { myReadData->myDriver->EndReadObjectData(); } + + private: + StdObjMgt_ReadData* myReadData; + + ObjectSentry (const ObjectSentry&); + ObjectSentry& operator = (const ObjectSentry&); + }; Standard_EXPORT StdObjMgt_ReadData (Storage_BaseDriver& theDriver, const Standard_Integer theNumberOfObjects); @@ -88,31 +105,7 @@ private: NCollection_Array1 myPersistentObjects; }; -class StdObjMgt_ReadData::Object -{ -public: - Object (StdObjMgt_ReadData& theData) : myReadData (&theData) - { myReadData->myDriver->BeginReadObjectData(); } - Object(const StdObjMgt_ReadData::Object& theOther) : myReadData(theOther.myReadData) - { myReadData->myDriver->BeginReadObjectData(); } - - ~Object() - { myReadData->myDriver->EndReadObjectData(); } - - operator StdObjMgt_ReadData&() - { return *myReadData; } - - template - StdObjMgt_ReadData& operator >> (Data& theData) - { return *myReadData >> theData; } - -private: - StdObjMgt_ReadData* myReadData; - - StdObjMgt_ReadData::Object& operator = (const StdObjMgt_ReadData::Object&); -}; - Standard_EXPORT StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, Standard_GUID& theGUID); + (StdObjMgt_ReadData& theReadData, Standard_GUID& theGUID); #endif // _StdObjMgt_ReadData_HeaderFile diff --git a/src/StdObjMgt/StdObjMgt_WriteData.cxx b/src/StdObjMgt/StdObjMgt_WriteData.cxx index cbd9b4fb87..7830181f26 100644 --- a/src/StdObjMgt/StdObjMgt_WriteData.cxx +++ b/src/StdObjMgt/StdObjMgt_WriteData.cxx @@ -44,8 +44,10 @@ StdObjMgt_WriteData& StdObjMgt_WriteData::operator << (const Handle(StdObjMgt_Pe //purpose : Read persistent data from a file //======================================================================= StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const Standard_GUID& theGUID) + (StdObjMgt_WriteData& theWriteData, const Standard_GUID& theGUID) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const Standard_UUID anUUID = theGUID.ToUUID(); Standard_Integer a32b; diff --git a/src/StdObjMgt/StdObjMgt_WriteData.hxx b/src/StdObjMgt/StdObjMgt_WriteData.hxx index 48d5ea4b19..22b97c97f1 100644 --- a/src/StdObjMgt/StdObjMgt_WriteData.hxx +++ b/src/StdObjMgt/StdObjMgt_WriteData.hxx @@ -25,7 +25,24 @@ class StdObjMgt_WriteData { public: - class Object; + //! Auxiliary class used to automate begin and end of + //! writing object (adding opening and closing parenthesis) + //! at constructor and destructor + class ObjectSentry + { + public: + explicit ObjectSentry (StdObjMgt_WriteData& theData) : myWriteData(&theData) + { myWriteData->myDriver->BeginWriteObjectData(); } + + ~ObjectSentry() + { myWriteData->myDriver->EndWriteObjectData(); } + + private: + StdObjMgt_WriteData* myWriteData; + + ObjectSentry (const ObjectSentry&); + ObjectSentry& operator = (const ObjectSentry&); + }; Standard_EXPORT StdObjMgt_WriteData (Storage_BaseDriver& theDriver); @@ -71,31 +88,7 @@ private: Storage_BaseDriver* myDriver; }; -class StdObjMgt_WriteData::Object -{ -public: - Object (StdObjMgt_WriteData& theData) : myWriteData(&theData) - { myWriteData->myDriver->BeginWriteObjectData(); } - Object (const StdObjMgt_WriteData::Object& theOther) : myWriteData(theOther.myWriteData) - { myWriteData->myDriver->BeginWriteObjectData(); } - - ~Object() - { myWriteData->myDriver->EndWriteObjectData(); } - - operator StdObjMgt_WriteData& () - { return *myWriteData; } - - template - StdObjMgt_WriteData& operator << (Data& theData) - { return *myWriteData << theData; } - -private: - StdObjMgt_WriteData* myWriteData; - - StdObjMgt_WriteData::Object& operator = (const StdObjMgt_WriteData::Object&); -}; - Standard_EXPORT StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const Standard_GUID& theGUID); + (StdObjMgt_WriteData& theWriteData, const Standard_GUID& theGUID); #endif // _StdObjMgt_WriteData_HeaderFile diff --git a/src/StdObject/StdObject_Location.hxx b/src/StdObject/StdObject_Location.hxx index 29a0854277..7c729d4d48 100644 --- a/src/StdObject/StdObject_Location.hxx +++ b/src/StdObject/StdObject_Location.hxx @@ -40,22 +40,24 @@ private: Handle(StdObjMgt_Persistent) myData; friend StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object, StdObject_Location&); + (StdObjMgt_ReadData&, StdObject_Location&); friend StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object, const StdObject_Location&); + (StdObjMgt_WriteData&, const StdObject_Location&); }; //! Read persistent data from a file. inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, StdObject_Location& theLocation) + (StdObjMgt_ReadData& theReadData, StdObject_Location& theLocation) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); return theReadData >> theLocation.myData; } //! Write persistent data to a file. inline StdObjMgt_WriteData& operator << -(StdObjMgt_WriteData::Object theWriteData, const StdObject_Location& theLocation) + (StdObjMgt_WriteData& theWriteData, const StdObject_Location& theLocation) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); return theWriteData << theLocation.myData; } diff --git a/src/StdObject/StdObject_Shape.hxx b/src/StdObject/StdObject_Shape.hxx index 58d0111412..7d1ab803e5 100644 --- a/src/StdObject/StdObject_Shape.hxx +++ b/src/StdObject/StdObject_Shape.hxx @@ -48,23 +48,25 @@ protected: Standard_Integer myOrient; friend StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object, StdObject_Shape&); + (StdObjMgt_ReadData&, StdObject_Shape&); friend StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object, const StdObject_Shape&); + (StdObjMgt_WriteData&, const StdObject_Shape&); }; //! Read persistent data from a file. inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, StdObject_Shape& theShape) + (StdObjMgt_ReadData& theReadData, StdObject_Shape& theShape) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); theShape.read (theReadData); return theReadData; } //! Write persistent data to a file. inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const StdObject_Shape& theShape) + (StdObjMgt_WriteData& theWriteData, const StdObject_Shape& theShape) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); theShape.write (theWriteData); return theWriteData; } diff --git a/src/StdObject/StdObject_gp_Axes.hxx b/src/StdObject/StdObject_gp_Axes.hxx index f5c78bc335..105487e24e 100644 --- a/src/StdObject/StdObject_gp_Axes.hxx +++ b/src/StdObject/StdObject_gp_Axes.hxx @@ -26,8 +26,9 @@ inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Ax2d& theAx) + (StdObjMgt_ReadData& theReadData, gp_Ax2d& theAx) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); gp_Pnt2d aLoc; gp_Dir2d aDir; theReadData >> aLoc >> aDir; @@ -36,8 +37,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& - write (StdObjMgt_WriteData::Object theWriteData, const gp_Ax2d& theAx) + write (StdObjMgt_WriteData& theWriteData, const gp_Ax2d& theAx) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const gp_Pnt2d& aLoc = theAx.Location(); const gp_Dir2d& aDir = theAx.Direction(); theWriteData << aLoc << aDir; @@ -45,8 +48,10 @@ inline StdObjMgt_WriteData& } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Ax2d& theAx) + (StdObjMgt_WriteData& theWriteData, const gp_Ax2d& theAx) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const gp_Pnt2d& aLoc = theAx.Location(); const gp_Dir2d& aDir = theAx.Direction(); theWriteData << aLoc << aDir; @@ -54,8 +59,9 @@ inline StdObjMgt_WriteData& operator << } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Ax22d& theAx) + (StdObjMgt_ReadData& theReadData, gp_Ax22d& theAx) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); gp_Pnt2d aLoc; gp_Dir2d aYDir, aXDir; theReadData >> aLoc >> aYDir >> aXDir; @@ -64,8 +70,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Ax22d& theAx) + (StdObjMgt_WriteData& theWriteData, const gp_Ax22d& theAx) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const gp_Pnt2d& aLoc = theAx.Location(); const gp_Dir2d& aYDir = theAx.YDirection(); const gp_Dir2d& aXDir = theAx.XDirection(); @@ -74,8 +82,9 @@ inline StdObjMgt_WriteData& operator << } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Ax1& theAx) + (StdObjMgt_ReadData& theReadData, gp_Ax1& theAx) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); gp_Pnt aLoc; gp_Dir aDir; theReadData >> aLoc >> aDir; @@ -84,8 +93,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& - write(StdObjMgt_WriteData::Object theWriteData, const gp_Ax1& theAx) + write(StdObjMgt_WriteData& theWriteData, const gp_Ax1& theAx) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const gp_Pnt& aLoc = theAx.Location(); const gp_Dir& aDir = theAx.Direction(); theWriteData << aLoc << aDir; @@ -93,8 +104,10 @@ inline StdObjMgt_WriteData& } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Ax1& theAx) + (StdObjMgt_WriteData& theWriteData, const gp_Ax1& theAx) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const gp_Pnt& aLoc = theAx.Location(); const gp_Dir& aDir = theAx.Direction(); theWriteData << aLoc << aDir; @@ -102,8 +115,9 @@ inline StdObjMgt_WriteData& operator << } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Ax2& theAx) + (StdObjMgt_ReadData& theReadData, gp_Ax2& theAx) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); gp_Ax1 anAx; gp_Dir aYDir, aXDir; theReadData >> anAx >> aYDir >> aXDir; @@ -112,8 +126,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Ax2& theAx) + (StdObjMgt_WriteData& theWriteData, const gp_Ax2& theAx) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const gp_Ax1& anAx = theAx.Axis(); const gp_Dir& aYDir = theAx.YDirection(); const gp_Dir& aXDir = theAx.XDirection(); @@ -122,8 +138,9 @@ inline StdObjMgt_WriteData& operator << } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Ax3& theAx) + (StdObjMgt_ReadData& theReadData, gp_Ax3& theAx) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); gp_Ax1 anAx; gp_Dir aYDir, aXDir; theReadData >> anAx >> aYDir >> aXDir; @@ -134,8 +151,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << -(StdObjMgt_WriteData::Object theWriteData, const gp_Ax3& theAx) + (StdObjMgt_WriteData& theWriteData, const gp_Ax3& theAx) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + const gp_Ax1& anAx = theAx.Axis(); const gp_Dir& aYDir = theAx.YDirection(); const gp_Dir& aXDir = theAx.XDirection(); diff --git a/src/StdObject/StdObject_gp_Trsfs.hxx b/src/StdObject/StdObject_gp_Trsfs.hxx index 54cc6a27cb..8d5d311d4f 100644 --- a/src/StdObject/StdObject_gp_Trsfs.hxx +++ b/src/StdObject/StdObject_gp_Trsfs.hxx @@ -25,8 +25,9 @@ inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Mat2d& theMat) + (StdObjMgt_ReadData& theReadData, gp_Mat2d& theMat) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); theReadData >> theMat(1, 1) >> theMat(1, 2) >> theMat(2, 1) >> theMat(2, 2); @@ -34,8 +35,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Mat2d& theMat) + (StdObjMgt_WriteData& theWriteData, const gp_Mat2d& theMat) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << theMat(1, 1) << theMat(1, 2) << theMat(2, 1) << theMat(2, 2); @@ -43,8 +46,9 @@ inline StdObjMgt_WriteData& operator << } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Mat& theMat) + (StdObjMgt_ReadData& theReadData, gp_Mat& theMat) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); theReadData >> theMat(1, 1) >> theMat(1, 2) >> theMat(1, 3) >> theMat(2, 1) >> theMat(2, 2) >> theMat(2, 3) @@ -53,8 +57,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Mat& theMat) + (StdObjMgt_WriteData& theWriteData, const gp_Mat& theMat) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << theMat(1, 1) << theMat(1, 2) << theMat(1, 3) << theMat(2, 1) << theMat(2, 2) << theMat(2, 3) @@ -63,8 +69,10 @@ inline StdObjMgt_WriteData& operator << } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Trsf2d& theTrsf) + (StdObjMgt_ReadData& theReadData, gp_Trsf2d& theTrsf) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + Standard_Real aScale; Standard_Integer aForm; gp_Mat2d aMat; @@ -79,8 +87,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << -(StdObjMgt_WriteData::Object theWriteData, const gp_Trsf2d& theTrsf) + (StdObjMgt_WriteData& theWriteData, const gp_Trsf2d& theTrsf) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + Standard_Real aScale = theTrsf.ScaleFactor(); Standard_Integer aForm = theTrsf.Form(); const gp_Mat2d& aMat = theTrsf.HVectorialPart(); @@ -92,8 +102,10 @@ inline StdObjMgt_WriteData& operator << } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Trsf& theTrsf) + (StdObjMgt_ReadData& theReadData, gp_Trsf& theTrsf) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + Standard_Real aScale; Standard_Integer aForm; gp_Mat aMat; @@ -110,8 +122,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Trsf& theTrsf) + (StdObjMgt_WriteData& theWriteData, const gp_Trsf& theTrsf) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + Standard_Real aScale = theTrsf.ScaleFactor(); Standard_Integer aForm = theTrsf.Form(); const gp_Mat& aMat = theTrsf.HVectorialPart(); diff --git a/src/StdObject/StdObject_gp_Vectors.hxx b/src/StdObject/StdObject_gp_Vectors.hxx index 4090a25cc7..66b28f0b77 100644 --- a/src/StdObject/StdObject_gp_Vectors.hxx +++ b/src/StdObject/StdObject_gp_Vectors.hxx @@ -28,8 +28,10 @@ inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_XY& theXY) + (StdObjMgt_ReadData& theReadData, gp_XY& theXY) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + Standard_Real aX, aY; theReadData >> aX >> aY; theXY.SetCoord (aX, aY); @@ -37,16 +39,20 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_XY& theXY) + (StdObjMgt_WriteData& theWriteData, const gp_XY& theXY) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + Standard_Real aX = theXY.X(), aY = theXY.Y(); theWriteData << aX << aY; return theWriteData; } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Pnt2d& thePnt) + (StdObjMgt_ReadData& theReadData, gp_Pnt2d& thePnt) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + gp_XY aXY; theReadData >> aXY; thePnt.SetXY (aXY); @@ -54,15 +60,19 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Pnt2d& thePnt) + (StdObjMgt_WriteData& theWriteData, const gp_Pnt2d& thePnt) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << thePnt.XY(); return theWriteData; } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Vec2d& theVec) + (StdObjMgt_ReadData& theReadData, gp_Vec2d& theVec) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + gp_XY aXY; theReadData >> aXY; theVec.SetXY (aXY); @@ -70,15 +80,19 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Vec2d& theVec) + (StdObjMgt_WriteData& theWriteData, const gp_Vec2d& theVec) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << theVec.XY(); return theWriteData; } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Dir2d& theDir) + (StdObjMgt_ReadData& theReadData, gp_Dir2d& theDir) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + gp_XY aXY; theReadData >> aXY; theDir.SetXY (aXY); @@ -86,15 +100,19 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Dir2d& theDir) + (StdObjMgt_WriteData& theWriteData, const gp_Dir2d& theDir) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << theDir.XY(); return theWriteData; } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_XYZ& theXYZ) + (StdObjMgt_ReadData& theReadData, gp_XYZ& theXYZ) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + Standard_Real aX, aY, aZ; theReadData >> aX >> aY >> aZ; theXYZ.SetCoord(aX, aY, aZ); @@ -102,16 +120,20 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_XYZ& theXYZ) + (StdObjMgt_WriteData& theWriteData, const gp_XYZ& theXYZ) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + Standard_Real aX = theXYZ.X(), aY = theXYZ.Y(), aZ = theXYZ.Z(); theWriteData << aX << aY << aZ; return theWriteData; } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Pnt& thePnt) + (StdObjMgt_ReadData& theReadData, gp_Pnt& thePnt) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + gp_XYZ aXYZ; theReadData >> aXYZ; thePnt.SetXYZ (aXYZ); @@ -119,15 +141,19 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Pnt& thePnt) + (StdObjMgt_WriteData& theWriteData, const gp_Pnt& thePnt) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << thePnt.XYZ(); return theWriteData; } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Vec& theVec) + (StdObjMgt_ReadData& theReadData, gp_Vec& theVec) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + gp_XYZ aXYZ; theReadData >> aXYZ; theVec.SetXYZ (aXYZ); @@ -135,15 +161,19 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Vec& theVec) + (StdObjMgt_WriteData& theWriteData, const gp_Vec& theVec) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << theVec.XYZ(); return theWriteData; } inline StdObjMgt_ReadData& operator >> - (StdObjMgt_ReadData::Object theReadData, gp_Dir& theDir) + (StdObjMgt_ReadData& theReadData, gp_Dir& theDir) { + StdObjMgt_ReadData::ObjectSentry aSentry (theReadData); + gp_XYZ aXYZ; theReadData >> aXYZ; theDir.SetXYZ(aXYZ); @@ -151,8 +181,10 @@ inline StdObjMgt_ReadData& operator >> } inline StdObjMgt_WriteData& operator << - (StdObjMgt_WriteData::Object theWriteData, const gp_Dir& theDir) + (StdObjMgt_WriteData& theWriteData, const gp_Dir& theDir) { + StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData); + theWriteData << theDir.XYZ(); return theWriteData; } diff --git a/tests/bugs/fclasses/begin b/tests/bugs/fclasses/begin index 5fee6fb13b..6b038e8401 100755 --- a/tests/bugs/fclasses/begin +++ b/tests/bugs/fclasses/begin @@ -1,9 +1 @@ set subgroup fclasses - - - - - - - - diff --git a/tests/bugs/fclasses/bug29355 b/tests/bugs/fclasses/bug29355 new file mode 100644 index 0000000000..88b5a800b5 --- /dev/null +++ b/tests/bugs/fclasses/bug29355 @@ -0,0 +1,16 @@ +puts "# ======================================================================" +puts "# 0029355: OCCT 6.9.1 persistence restored in OCCT 7.2.0 not working" +puts "# ======================================================================" + +pload OCAF MODELING + +puts "" +puts "# Check reading of shape from FSD archive" +fsdread [locate_data_file bug29355.fsd] a +checkshape a +checknbshapes a -face 14 -solid 0 -edge 39 -vertex 26 + +puts "" +puts "# Check that reading fails with expected message on truncated file" +puts "REQUIRED 29355 ALL: Error : 6" +catch {fsdread [locate_data_file bug29355_truncated.fsd] a}