Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 951555b1 authored by Quentin Khan's avatar Quentin Khan
Browse files
parents 78cbafc1 f40a183f
......@@ -200,6 +200,39 @@ inline void PrintUsedOptions(const std::vector<FParameterNames>& options){
}
}
inline bool CheckValidParameters(const int argc, char* argv[], const std::vector<FParameterNames> options){
bool isValide = true;
bool previousIsCorrectParameter = false;
for(int idxParameter = 1 ; idxParameter < argc ; ++idxParameter){
bool paramExist = false;
for(unsigned idxTest = 0 ; idxTest < options.size() ; ++idxTest){
paramExist = FParameters::existParameter(argc, argv, options[idxTest].options);
if(paramExist){
break;
}
}
if(paramExist == true){
previousIsCorrectParameter = true;
}
else if(previousIsCorrectParameter){
previousIsCorrectParameter = false;
}
else{
previousIsCorrectParameter = false;
isValide = false;
std::cout << "[PARAMETER-ERROR] Parameter " << (idxParameter-1) << " = \"" << argv[idxParameter] << "\" seems incorrect." << "\n";
}
}
if(isValide == false){
std::cout << "[ScalFMM] To know more about correct parameters ask for help by passing:\n\t";
for(const char* param : FParameterDefinitions::Help.options){
std::cout << "\t" << param << ",";
}
std::cout << std::endl;
}
return isValide;
}
inline void PrintFlags(){
std::cout << "[ScalFMM] This executable has been compiled with:\n";
std::cout << " Flags: " << SCALFMMCompileFlags << "\n";
......@@ -241,6 +274,10 @@ inline void PrintGivenParams(int argc, const char* const * const argv){
if(FParameters::existParameter(argc, argv, FParameterDefinitions::UserParams.options)) {\
FParameterDefinitions::PrintGivenParams(argc, argv);\
} \
if(FParameterDefinitions::CheckValidParameters(argc, argv, {FParameterDefinitions::Compile, FParameterDefinitions::DateHost, \
FParameterDefinitions::UserParams, __VA_ARGS__}) == false){ \
return 121;\
} \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::Help.options)) {\
const std::vector<FParameterNames> optionsvec = {FParameterDefinitions::Compile, FParameterDefinitions::DateHost, \
FParameterDefinitions::UserParams, __VA_ARGS__};\
......@@ -263,6 +300,10 @@ inline void PrintGivenParams(int argc, const char* const * const argv){
if(FParameters::existParameter(argc, argv, FParameterDefinitions::UserParams.options)) {\
FParameterDefinitions::PrintGivenParams(argc, argv);\
} \
if(FParameterDefinitions::CheckValidParameters(argc, argv, {FParameterDefinitions::Compile, FParameterDefinitions::DateHost, \
FParameterDefinitions::UserParams, __VA_ARGS__}) == false){ \
return 121;\
} \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::Help.options)) {\
std::cout << argv[0] << " : " << description << "\n"; \
const std::vector<FParameterNames> optionsvec = {FParameterDefinitions::Compile, FParameterDefinitions::DateHost, \
......
......@@ -24,6 +24,8 @@
#include <vector>
#include "FAssert.hpp"
/** This file proposes some methods
* to work with user input parameters.
*/
......@@ -44,6 +46,7 @@ namespace FParameters{
std::istringstream iss(str,std::istringstream::in);
VariableType value;
iss >> value;
FAssertLF(iss.eof());
if( /*iss.tellg()*/ iss.eof() ) return value;
return defaultValue;
}
......@@ -103,6 +106,7 @@ namespace FParameters{
template <class VariableType>
inline const VariableType getValue(const int argc, const char* const * const argv, const char* const inName, const VariableType& defaultValue = VariableType(), const bool caseSensible = false){
const int position = findParameter(argc,argv,inName,caseSensible);
FAssertLF(position == NotFound || position != argc - 1);
if(position == NotFound || position == argc - 1){
return defaultValue;
}
......@@ -113,6 +117,7 @@ namespace FParameters{
*/
inline const char* getStr(const int argc, const char* const * const argv, const char* const inName, const char* const inDefault, const bool caseSensible = false){
const int position = findParameter(argc,argv,inName,caseSensible);
FAssertLF(position == NotFound || position != argc - 1);
if(position == NotFound || position == argc - 1){
return inDefault;
}
......@@ -154,6 +159,7 @@ namespace FParameters{
inline const VariableType getValue(const int argc, const char* const * const argv, const std::vector<const char*>& inNames, const VariableType& defaultValue = VariableType(), const bool caseSensible = false){
for(const char* name : inNames){
const int position = findParameter(argc, argv, name, caseSensible);
FAssertLF(position == NotFound || position != argc - 1);
if(position != NotFound && position != argc - 1){
return StrToOther(argv[position+1],defaultValue);
}
......@@ -166,6 +172,7 @@ namespace FParameters{
inline const char* getStr(const int argc, const char* const * const argv, const std::vector<const char*>& inNames, const char* const inDefault, const bool caseSensible = false){
for(const char* name : inNames){
const int position = findParameter(argc, argv, name, caseSensible);
FAssertLF(position == NotFound || position != argc - 1);
if(position != NotFound && position != argc - 1){
return argv[position+1];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment