Skip to content
Snippets Groups Projects
Commit 12e31c90 authored by Jonathan Guinet's avatar Jonathan Guinet
Browse files

BUG: IsAttribute Method gives bad results with non-existant parameters.

parent dbf0e085
No related branches found
No related tags found
No related merge requests found
...@@ -181,7 +181,7 @@ CommandLineParser::GetAttribut( const std::string & key, const std::string & exp ...@@ -181,7 +181,7 @@ CommandLineParser::GetAttribut( const std::string & key, const std::string & exp
tempModKey = expFromKey.substr( 0, expFromKey.find("--")-1); tempModKey = expFromKey.substr( 0, expFromKey.find("--")-1);
} }
// Only if the key has values assciated // Only if the key has values associated
if( tempModKey.size() > 0 ) if( tempModKey.size() > 0 )
{ {
std::vector<itksys::String> spaceSplitted = itksys::SystemTools::SplitString(tempModKey.substr(1, tempModKey.size()).c_str(), ' ', false); std::vector<itksys::String> spaceSplitted = itksys::SystemTools::SplitString(tempModKey.substr(1, tempModKey.size()).c_str(), ' ', false);
...@@ -196,7 +196,7 @@ CommandLineParser::GetAttribut( const std::string & key, const std::string & exp ...@@ -196,7 +196,7 @@ CommandLineParser::GetAttribut( const std::string & key, const std::string & exp
} }
} }
// Remove space at the begining of the string and cast into std::vector<std::string> // Remove space at the beginning of the string and cast into std::vector<std::string>
for(unsigned int i=0; i<spaceSplitted.size(); i++) for(unsigned int i=0; i<spaceSplitted.size(); i++)
{ {
while( spaceSplitted[i].size()>0 && spaceSplitted[i][0] == ' ' ) while( spaceSplitted[i].size()>0 && spaceSplitted[i][0] == ' ' )
...@@ -244,21 +244,12 @@ bool ...@@ -244,21 +244,12 @@ bool
CommandLineParser::IsAttributExists( const std::string key, const std::string & exp ) CommandLineParser::IsAttributExists( const std::string key, const std::string & exp )
{ {
std::string keySpaced = key; std::string keySpaced = key;
// Add space to avoid troubles with key twhich starts by another one : --out and --outmax for example std::string expSpaced = exp;
// Add space to avoid troubles with key which starts by another one : --out and --outmax for example
keySpaced.append(" "); keySpaced.append(" ");
std::size_t found = exp.find(keySpaced); expSpaced.append(" ");
if( found == std::string::npos ) std::size_t found = expSpaced.find(keySpaced);
{ return (found != std::string::npos);
// Case the attribut is at the end of the expression : no space
found = exp.find(key);
if( found == std::string::npos )
{
return false;
}
return true;
}
return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment