0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / DDocStd / DDocStd.hxx
index 52bbd19..cbca7da 100644 (file)
@@ -60,6 +60,14 @@ public:
   
   Standard_EXPORT static Standard_Boolean Find (const Handle(TDocStd_Document)& Document, const Standard_CString Entry, const Standard_GUID& ID, Handle(TDF_Attribute)& A, const Standard_Boolean Complain = Standard_True);
   
+  //! Safe variant for arbitrary type of argument
+  template <class T> 
+  static Standard_Boolean Find (const Handle(TDocStd_Document)& Document, const Standard_CString Entry, const Standard_GUID& ID, Handle(T)& A, const Standard_Boolean Complain = Standard_True)
+  {
+    Handle(TDF_Attribute) anAttr = A;
+    return Find (Document, Entry, ID, anAttr, Complain) && ! (A = Handle(T)::DownCast(anAttr)).IsNull();
+  }
+
   Standard_EXPORT static Draw_Interpretor& ReturnLabel (Draw_Interpretor& theCommands, const TDF_Label& L);
   
   Standard_EXPORT static void AllCommands (Draw_Interpretor& theCommands);