ADD: added string to short function in the utils class
This commit is contained in:
@@ -19,6 +19,7 @@ namespace SimCore {
|
|||||||
static std::string implode(const std::vector<std::string> &v , char delim);
|
static std::string implode(const std::vector<std::string> &v , char delim);
|
||||||
|
|
||||||
static bool isNumber(const std::string& s);
|
static bool isNumber(const std::string& s);
|
||||||
|
static std::uint16_t StringToUShort(std::string str);
|
||||||
static void check_host_name(int hostname);
|
static void check_host_name(int hostname);
|
||||||
static void check_host_entry(struct hostent * hostentry);
|
static void check_host_entry(struct hostent * hostentry);
|
||||||
static void IP_formatter(char *IPbuffer);
|
static void IP_formatter(char *IPbuffer);
|
||||||
|
|||||||
@@ -37,6 +37,18 @@ namespace SimCore {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::uint16_t UtilFunctions::StringToUShort(std::string str)
|
||||||
|
{
|
||||||
|
std::uint16_t myInt16(0);
|
||||||
|
if(!std::empty(str))
|
||||||
|
{
|
||||||
|
int myInt(std::stoi(str));
|
||||||
|
if (myInt <= static_cast<int>(UINT16_MAX) && myInt >=0) {
|
||||||
|
myInt16 = static_cast<uint16_t>(myInt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return myInt16;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool UtilFunctions::isNumber(const std::string& s)
|
bool UtilFunctions::isNumber(const std::string& s)
|
||||||
|
|||||||
Reference in New Issue
Block a user