std::string MEDCoupling::MEDFileVersionStr()
{
- return std::string(MED_VERSION_STR);
+ const int SZ=20;
+ char buf[SZ];
+ std::fill(buf,buf+SZ,'\0');
+ const char START_EXPECTED[]="MED-";
+ med_err ret(MEDlibraryStrVersion(buf));
+ if(ret!=0)
+ throw INTERP_KERNEL::Exception("MEDFileVersionStr : fail to find version of MED file ! It looks very bad !");
+ std::string zeRet(buf);
+ std::size_t pos(zeRet.find(START_EXPECTED,0));
+ if(pos!=0)
+ {
+ std::ostringstream oss; oss << "MEDFileVersionStr : internal error ! The MEDFile returned version (\"" << zeRet << "\") has not the right pattern !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ return zeRet.substr(sizeof(START_EXPECTED)-1,std::string::npos);
}
std::string MEDCoupling::MEDFileVersionOfFileStr(const std::string& fileName)
void MEDCoupling::MEDFileVersion(int& major, int& minor, int& release)
{
- major=MED_NUM_MAJEUR;
- minor=MED_NUM_MINEUR;
- release=MED_NUM_RELEASE;
+ med_int majj,minn,rell;
+ med_err ret(MEDlibraryNumVersion(&majj,&minn,&rell));
+ if(ret!=0)
+ throw INTERP_KERNEL::Exception("MEDFileVersion : fail to call MEDlibraryNumVersion ! It looks very bad !");
+ major=majj;
+ minor=minn;
+ release=rell;
}
/*!
namespace MEDCoupling
{
bool HasXDR();
- std::string MEDFileVersionStr();
+ std::string MEDFileVersionStr() throw(INTERP_KERNEL::Exception);
std::string MEDFileVersionOfFileStr(const std::string& fileName) throw(INTERP_KERNEL::Exception);
void SetEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
void SetCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
%inline
{
- PyObject *MEDFileVersionSwig()
+ PyObject *MEDFileVersionSwig() throw(INTERP_KERNEL::Exception)
{
int major,minor,release;
MEDCoupling::MEDFileVersion(major,minor,release);
return ret;
}
- PyObject *GetFieldIterationsSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName)
+ PyObject *GetFieldIterationsSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
std::vector< std::pair<int,int> > res=MEDCoupling::GetFieldIterations(type,fileName,meshName,fieldName);
PyObject *ret=PyList_New(res.size());