From f2b1eb75abae7f36bd27fb493cb18ff6b2c51e4b Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 28 Mar 2019 20:55:49 +0100 Subject: [PATCH] helpers: add isDigitWord() function returns true if all chars of string parameter are digits Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/205bbeb7ce0355256a80b75452ac3e159f80f68a Author: Thilo Graf Date: 2019-03-28 (Thu, 28 Mar 2019) ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 9 +++++++++ src/system/helpers.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 5712c70e2..3037a7a81 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -1929,4 +1929,13 @@ std::string encodeUrl(std::string 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; +} + // diff --git a/src/system/helpers.h b/src/system/helpers.h index eb788e23d..6feed86a8 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -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 downloadUrl(std::string url, std::string file, const std::string userAgent = " ", unsigned int timeout = 60); +bool isDigitWord(std::string str); + // #endif