Fix coding style

This commit is contained in:
Christophe Bourcier 2023-05-09 11:45:12 +02:00
parent 8458334bcd
commit 6eabe7768b
2 changed files with 33 additions and 20 deletions

View File

@ -643,13 +643,16 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
* \return int - the version * \return int - the version
*/ */
//================================================================================ //================================================================================
int GetMGVersionFromEnv(const char* env_variable){ int GetMGVersionFromEnv(const char* env_variable)
{
MESSAGE("Entering GetMGVersionFromEnv and calling " << env_variable); MESSAGE("Entering GetMGVersionFromEnv and calling " << env_variable);
int version = -1; int version = -1;
if (getenv(env_variable) == nullptr ){ if (getenv(env_variable) == nullptr )
{
MESSAGE("Could not find " << env_variable << " from environment"); MESSAGE("Could not find " << env_variable << " from environment");
} }
else{ else
{
version = std::stoi(std::string(getenv(env_variable))); version = std::stoi(std::string(getenv(env_variable)));
} }
return version; return version;
@ -661,15 +664,18 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
* \return int - the function implemented in the library * \return int - the function implemented in the library
*/ */
//================================================================================ //================================================================================
int GetMGVersionFromFct(const char* function_name){ int GetMGVersionFromFunction(const char* function_name)
MESSAGE("Entering GetMGVersionFromFct and calling " << function_name); {
MESSAGE("Entering GetMGVersionFromFunction and calling " << function_name);
int version = -1; int version = -1;
typedef int (*GetKeyFun)(); typedef int (*GetKeyFun)();
GetKeyFun keyFun = (GetKeyFun) GetProc( theLibraryHandle, function_name); GetKeyFun keyFun = (GetKeyFun) GetProc( theLibraryHandle, function_name);
if ( !keyFun ){ if ( !keyFun )
{
MESSAGE("Could not find " << function_name << " from library"); MESSAGE("Could not find " << function_name << " from library");
} }
else{ else
{
version = keyFun(); version = keyFun();
} }
return version; return version;
@ -677,39 +683,46 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
//================================================================================ //================================================================================
/*! /*!
* \brief Get MeshGems version from the keygen library and meshgems built-in functions * \brief Get MeshGems version from the keygen library or meshgems built-in functions
* \param [out] error - return error description * \param [out] error - return error description
* \return int - the version * \return int - the version
*/ */
//================================================================================ //================================================================================
int GetMGVersionHex(std::string& error) int GetMGVersionHex(std::string& error)
{ {
// get minor version // load mgkeygen library
int v_min = -1; int v_min = -1;
LibraryFile libraryFile; LibraryFile libraryFile;
if ( !loadLibrary( error, libraryFile )) if ( !loadLibrary( error, libraryFile ))
return v_min; return v_min;
MESSAGE("Extracting MeshGems version"); MESSAGE("Extracting MeshGems version");
v_min = GetMGVersionFromFct("meshgems_core_get_version_minor"); // get minor version
if (v_min == -1) v_min = GetMGVersionFromFct("GetVersionMinor"); v_min = GetMGVersionFromFunction("meshgems_core_get_version_minor");
if (v_min == -1) v_min = GetMGVersionFromEnv("MESHGEMS_VERSION_MINOR"); if (v_min == -1)
v_min = GetMGVersionFromFunction("GetVersionMinor");
if (v_min == -1)
v_min = GetMGVersionFromEnv("MESHGEMS_VERSION_MINOR");
if (v_min == -1) if (v_min == -1)
error = "could not retrieve minor version (located in '" + libraryFile._name + "')"; error = "could not retrieve minor version (located in '" + libraryFile._name + "')";
MESSAGE("MeshGems minor version = " << v_min); MESSAGE("MeshGems minor version = " << v_min);
// get major version // get major version
int v_maj = GetMGVersionFromFct("meshgems_core_get_version_major"); int v_maj = GetMGVersionFromFunction("meshgems_core_get_version_major");
if (v_maj == -1) v_maj = GetMGVersionFromFct("GetVersionMajor"); if (v_maj == -1)
if (v_maj == -1) v_maj = GetMGVersionFromEnv("MESHGEMS_VERSION_MAJOR"); v_maj = GetMGVersionFromFunction("GetVersionMajor");
if (v_maj == -1)
v_maj = GetMGVersionFromEnv("MESHGEMS_VERSION_MAJOR");
if (v_maj == -1) if (v_maj == -1)
error = "could not retrieve major version (located in '" + libraryFile._name + "')"; error = "could not retrieve major version (located in '" + libraryFile._name + "')";
MESSAGE("MeshGems major version = " << v_maj); MESSAGE("MeshGems major version = " << v_maj);
// get patch version // get patch version
int v_patch = GetMGVersionFromFct("meshgems_core_get_version_patch"); int v_patch = GetMGVersionFromFunction("meshgems_core_get_version_patch");
if (v_patch == -1) v_patch = GetMGVersionFromFct("GetVersionPatch"); if (v_patch == -1)
if (v_patch == -1) v_patch = GetMGVersionFromEnv("MESHGEMS_VERSION_PATCH"); v_patch = GetMGVersionFromFunction("GetVersionPatch");
if (v_patch == -1)
v_patch = GetMGVersionFromEnv("MESHGEMS_VERSION_PATCH");
if (v_patch == -1) if (v_patch == -1)
error = "could not retrieve patch version (located in '" + libraryFile._name + "')"; error = "could not retrieve patch version (located in '" + libraryFile._name + "')";
MESSAGE("MeshGems patch version = " << v_patch); MESSAGE("MeshGems patch version = " << v_patch);

View File

@ -58,7 +58,7 @@ namespace SMESHUtils_MGLicenseKeyGen
SMESHUtils_EXPORT bool CheckKeyGenLibrary( std::string& error ); SMESHUtils_EXPORT bool CheckKeyGenLibrary( std::string& error );
SMESHUtils_EXPORT std::string GetLibraryName(); SMESHUtils_EXPORT std::string GetLibraryName();
SMESHUtils_EXPORT int GetMGVersionFromFct(const char* function_name); SMESHUtils_EXPORT int GetMGVersionFromFunction(const char* function_name);
SMESHUtils_EXPORT int GetMGVersionFromEnv(const char* env_variable); SMESHUtils_EXPORT int GetMGVersionFromEnv(const char* env_variable);
SMESHUtils_EXPORT int GetMGVersionHex(std::string& error); SMESHUtils_EXPORT int GetMGVersionHex(std::string& error);
SMESHUtils_EXPORT bool NeedsMGSpatialEnvLicense(std::string& error); SMESHUtils_EXPORT bool NeedsMGSpatialEnvLicense(std::string& error);