Convert string values to unsigned long. * * @note This function implements the same behaviour as std::stoul. The latter * is missing in some Android toolchains. * * @param[in] str String to be converted to unsigned long. * @param[in] pos If idx is not a null pointer, the function sets the value of pos to the position of the first character in str after the number. * @param[in] base
| 89 | * @return Unsigned long representation of @p str. |
| 90 | */ |
| 91 | inline unsigned long stoul(const std::string &str, std::size_t *pos = 0, NumericBase base = NumericBase::BASE_10) |
| 92 | { |
| 93 | assert(base == NumericBase::BASE_10 || base == NumericBase::BASE_16); |
| 94 | std::stringstream stream; |
| 95 | unsigned long value = 0; |
| 96 | if (base == NumericBase::BASE_16) |
| 97 | { |
| 98 | stream << std::hex; |
| 99 | } |
| 100 | stream << str; |
| 101 | stream >> value; |
| 102 | |
| 103 | if (pos) |
| 104 | { |
| 105 | std::string s; |
| 106 | std::stringstream ss_p; |
| 107 | |
| 108 | ss_p << value; |
| 109 | ss_p >> s; |
| 110 | *pos = s.length(); |
| 111 | } |
| 112 | |
| 113 | return value; |
| 114 | } |
| 115 | |
| 116 | #if defined(__ANDROID__) || defined(BARE_METAL) |
| 117 | /** Convert integer and float values to string. |
no outgoing calls
no test coverage detected