Mercurial > hg > orthanc
diff Core/Toolbox.cpp @ 1102:ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Aug 2014 10:51:35 +0200 |
parents | e5686a703c63 |
children | bec1eccf976c |
line wrap: on
line diff
--- a/Core/Toolbox.cpp Thu Aug 07 10:21:43 2014 +0200 +++ b/Core/Toolbox.cpp Thu Aug 07 10:51:35 2014 +0200 @@ -1067,5 +1067,39 @@ throw OrthancException(ErrorCode_SystemCommand); } } + + + bool Toolbox::IsInteger(const std::string& str) + { + std::string s = StripSpaces(str); + + if (s.size() == 0) + { + return false; + } + + size_t pos = 0; + if (s[0] == '-') + { + if (s.size() == 1) + { + return false; + } + + pos = 1; + } + + while (pos < s.size()) + { + if (!isdigit(s[pos])) + { + return false; + } + + pos++; + } + + return true; + } }