Update CommandLineParser class: move method's definition from header to source
This commit is contained in:
parent
0d1ec967e8
commit
78d821114a
@ -4200,6 +4200,21 @@ class CV_EXPORTS CommandLineParser
|
|||||||
std::map<std::string, std::vector<std::string> > data;
|
std::map<std::string, std::vector<std::string> > data;
|
||||||
std::string getString(const std::string& name) const;
|
std::string getString(const std::string& name) const;
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
_Tp analizeValue(const std::string& str);
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
static _Tp getData(const std::string& str)
|
||||||
|
{
|
||||||
|
_Tp res;
|
||||||
|
std::stringstream s1(str);
|
||||||
|
s1 >> res;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
_Tp fromStringNumber(const std::string& str);//the default conversion function for numbers
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
_Tp analyzeValue(const std::string& str);
|
_Tp analyzeValue(const std::string& str);
|
||||||
};
|
};
|
||||||
|
@ -134,6 +134,26 @@ std::string CommandLineParser::getString(const std::string& keys) const
|
|||||||
return data.find(names[found_index])->second[0];
|
return data.find(names[found_index])->second[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
_Tp CommandLineParser::fromStringNumber(const std::string& str) //the default conversion function for numbers
|
||||||
|
{
|
||||||
|
if (str.empty())
|
||||||
|
CV_Error(CV_StsParseError, "Empty string cannot be converted to a number");
|
||||||
|
|
||||||
|
const char* c_str=str.c_str();
|
||||||
|
if((!isdigit(c_str[0]))
|
||||||
|
&&
|
||||||
|
(
|
||||||
|
(c_str[0]!='-') || (strlen(c_str) <= 1) || ( !isdigit(c_str[1]) )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
{
|
||||||
|
CV_Error(CV_StsParseError, "The string '"+ str +"' cannot be converted to a number");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getData<_Tp>(str);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
static _Tp getData(const std::string& str)
|
static _Tp getData(const std::string& str)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user