comparison 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
comparison
equal deleted inserted replaced
1101:e5686a703c63 1102:ce6386b37afd
1065 { 1065 {
1066 LOG(ERROR) << "System command failed with status code " << status; 1066 LOG(ERROR) << "System command failed with status code " << status;
1067 throw OrthancException(ErrorCode_SystemCommand); 1067 throw OrthancException(ErrorCode_SystemCommand);
1068 } 1068 }
1069 } 1069 }
1070
1071
1072 bool Toolbox::IsInteger(const std::string& str)
1073 {
1074 std::string s = StripSpaces(str);
1075
1076 if (s.size() == 0)
1077 {
1078 return false;
1079 }
1080
1081 size_t pos = 0;
1082 if (s[0] == '-')
1083 {
1084 if (s.size() == 1)
1085 {
1086 return false;
1087 }
1088
1089 pos = 1;
1090 }
1091
1092 while (pos < s.size())
1093 {
1094 if (!isdigit(s[pos]))
1095 {
1096 return false;
1097 }
1098
1099 pos++;
1100 }
1101
1102 return true;
1103 }
1070 } 1104 }
1071 1105