helpers: add isDigitWord() function

returns true if all chars of string parameter are digits


Origin commit data
------------------
Commit: 205bbeb7ce
Author: Thilo Graf <dbt@novatux.de>
Date: 2019-03-28 (Thu, 28 Mar 2019)
This commit is contained in:
2019-03-28 20:55:49 +01:00
committed by vanhofen
parent 2f33b08980
commit 70a4e3610f
2 changed files with 11 additions and 0 deletions

View File

@@ -1929,4 +1929,13 @@ std::string encodeUrl(std::string txt)
return txt; return txt;
} }
bool isDigitWord(std::string str)
{
for (size_t i=0; i < str.size(); i++)
if (!isdigit(str[i]))
return false;
return true;
}
// //

View File

@@ -186,5 +186,7 @@ std::string decodeUrl(std::string url);
bool getUrl(std::string &url, std::string &answer, const std::string userAgent = " ", unsigned int timeout = 60); bool getUrl(std::string &url, std::string &answer, const std::string userAgent = " ", unsigned int timeout = 60);
bool downloadUrl(std::string url, std::string file, const std::string userAgent = " ", unsigned int timeout = 60); bool downloadUrl(std::string url, std::string file, const std::string userAgent = " ", unsigned int timeout = 60);
bool isDigitWord(std::string str);
// //
#endif #endif