14#ifndef OPENVPN_COMMON_NUMBER_H
15#define OPENVPN_COMMON_NUMBER_H
36 const bool nondigit_term =
false)
42 if (std::numeric_limits<T>::min() < 0 &&
str[0] ==
'-')
50 const char c =
str[i++];
51 if (c >=
'0' && c <=
'9')
56 else if (!c || nondigit_term)
70 return parse_number<T>(
str.c_str(), retval);
77 if (parse_number<T>(
str.c_str(),
ret))
79 throw number_parse_exception(error);
86 if (parse_number<T>(
str.c_str(),
ret))
88 throw number_parse_exception(std::string(error));
95 if (parse_number<T>(
str,
ret))
97 throw number_parse_exception(std::string(error));
102 const size_t max_len,
105 T *value_return =
nullptr)
107 if (numstr.length() <= max_len)
110 if (parse_number<T>(numstr.c_str(), value))
112 if (value >= minimum && value <= maximum)
115 *value_return = value;
126 bool found_digit =
false;
129 if (c >=
'0' && c <=
'9')
#define OPENVPN_EXCEPTION(C)
bool parse_number_validate(const std::string &numstr, const size_t max_len, const T minimum, const T maximum, T *value_return=nullptr)
bool parse_number(const char *str, T &retval, const bool nondigit_term=false)
bool is_number(const char *str)
T parse_number_throw(const std::string &str, const std::string &error)
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'