Salome HOME
SWIG exception: removing C++11 warnings, minimal work.
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldGlobs.cxx
index 11a46ae5d47f2d512cbd49a757537d3636a3abbf..af727fc7b717c457742d1e1625bbb5b8db6f714e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -375,9 +375,9 @@ namespace MEDCouplingImpl
   {
   public:
     PflFinder(const std::string& pfl):_pfl(pfl) { }
-    bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
+    bool operator() (const MCAuto<DataArrayInt>& loc) { return loc->getName()==_pfl; }
   private:
-    const std::string& _pfl;
+    const std::string _pfl;
   };
 }
 /// @endcond
@@ -395,21 +395,25 @@ int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
   return std::distance(_locs.begin(),it);
 }
 
-/*!
- * The returned value is never null.
- */
-const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
+int MEDFileFieldGlobs::getProfileId(const std::string& pfl) const
 {
-  std::string pflNameCpp(pflName);
-  std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
+  std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pfl));
   if(it==_pfls.end())
     {
-      std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
+      std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfileId : no such profile name : \"" << pfl << "\" Possible localizations are : ";
       for(it=_pfls.begin();it!=_pfls.end();it++)
         oss << "\"" << (*it)->getName() << "\", ";
       throw INTERP_KERNEL::Exception(oss.str());
     }
-  return *it;
+  return std::distance(_pfls.begin(),it);
+}
+
+/*!
+ * The returned value is never null.
+ */
+const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
+{
+  return getProfileFromId(getProfileId(pflName));
 }
 
 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
@@ -432,7 +436,7 @@ MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
 }
 
 /*!
- * The returned value is never null.
+ * The returned value is never null. Borrowed reference returned.
  */
 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
 {
@@ -1039,6 +1043,17 @@ int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
   return contentNotNull()->getLocalizationId(loc);
 }
 
+/*!
+ * Returns an id of a profile by its name.
+ *  \param [in] loc - the profile name of interest.
+ *  \return int - the id of the profile.
+ *  \throw If there is no a profile named \a loc.
+ */
+int MEDFileFieldGlobsReal::getProfileId(const std::string& pfl) const
+{
+  return contentNotNull()->getProfileId(pfl);
+}
+
 /*!
  * Returns the name of the MED file.
  *  \return const std::string&  - the MED file name.
@@ -1119,7 +1134,7 @@ MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locNa
 /*!
  * Returns a profile array, apt for modification, by its name.
  *  \param [in] pflName - the name of the profile of interest.
- *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
+ *  \return DataArrayInt * - Borrowed reference - a non-const pointer to the profile array having the name \a pflName.
  *  \throw If there is no a profile named \a pflName.
  */
 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
@@ -1130,7 +1145,7 @@ DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
 /*!
  * Returns a profile array, apt for modification, by its id.
  *  \param [in] pflId - the id of the profile of interest.
- *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
+ *  \return DataArrayInt * - Borrowed reference - a non-const pointer to the profile array having the id \a pflId.
  *  \throw If there is no a profile with id \a pflId.
  */
 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)