1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
occt/src/BinDrivers/BinDrivers_DocumentRetrievalDriver.cxx
abv aa00364da7 0026377: Passing Handle objects as arguments to functions as non-const reference to base type is dangerous
Operator of cast to non-const reference is declared deprecated to produce compiler warning if used (usually implicitly).

OCCT code is updated to avoid that cast, occurring when function accepting non-const reference to handle is called with handle to derived type.
For that, local variable of argument type is passed instead, and down-cast is used to get it to desired type after the call.
A few occurrences of use of uninitialized variable are corrected.
2016-02-20 10:10:11 +03:00

104 lines
3.8 KiB
C++

// Created on: 2002-10-31
// Created by: Michael SAZONOV
// Copyright (c) 2002-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BinDrivers.hxx>
#include <BinDrivers_DocumentRetrievalDriver.hxx>
#include <BinLDrivers_DocumentSection.hxx>
#include <BinMDataStd.hxx>
#include <BinMDF_ADriverTable.hxx>
#include <BinMNaming.hxx>
#include <BinMNaming_NamedShapeDriver.hxx>
#include <CDM_MessageDriver.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Standard_IStream.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TNaming_NamedShape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinDrivers_DocumentRetrievalDriver,BinLDrivers_DocumentRetrievalDriver)
//=======================================================================
//function : BinDrivers_DocumentRetrievalDriver
//purpose : Constructor
//=======================================================================
BinDrivers_DocumentRetrievalDriver::BinDrivers_DocumentRetrievalDriver ()
{
}
//=======================================================================
//function : AttributeDrivers
//purpose :
//=======================================================================
Handle(BinMDF_ADriverTable) BinDrivers_DocumentRetrievalDriver::AttributeDrivers
(const Handle(CDM_MessageDriver)& theMessageDriver)
{
return BinDrivers::AttributeDrivers (theMessageDriver);
}
//=======================================================================
//function : ReadShapeSection
//purpose :
//=======================================================================
void BinDrivers_DocumentRetrievalDriver::ReadShapeSection
(BinLDrivers_DocumentSection& /*theSection*/,
Standard_IStream& theIS,
const Standard_Boolean /*isMess*/)
{
// Read Shapes
Handle(BinMDF_ADriver) aDriver;
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape),aDriver))
{
try {
OCC_CATCH_SIGNALS
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
Handle(BinMNaming_NamedShapeDriver)::DownCast (aDriver);
aNamedShapeDriver->ReadShapeSection (theIS);
}
catch(Standard_Failure) {
Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
const TCollection_ExtendedString aMethStr
("BinDrivers_DocumentRetrievalDriver: ");
WriteMessage (aMethStr + "error of Shape Section " +
aFailure->GetMessageString());
}
}
}
//=======================================================================
//function : CheckShapeSection
//purpose :
//=======================================================================
void BinDrivers_DocumentRetrievalDriver::CheckShapeSection(
const Storage_Position& /*ShapeSectionPos*/,
Standard_IStream& /*IS*/)
{}
//=======================================================================
//function : PropagateDocumentVersion
//purpose :
//=======================================================================
void BinDrivers_DocumentRetrievalDriver::PropagateDocumentVersion(
const Standard_Integer theDocVersion )
{
BinMDataStd::SetDocumentVersion(theDocVersion);
BinMNaming::SetDocumentVersion(theDocVersion);
}