Convert an integer value to a hexadecimal string. The returned string length is always xdigits long, prefixed by 0 digits. For example, IntToStringHex(0x23, 8) returns the string "00000023".
| 199 | // The returned string length is always xdigits long, prefixed by 0 digits. |
| 200 | // For example, IntToStringHex(0x23, 8) returns the string "00000023". |
| 201 | inline std::string IntToStringHex(int i, int xdigits) { |
| 202 | FLATBUFFERS_ASSERT(i >= 0); |
| 203 | // clang-format off |
| 204 | |
| 205 | #ifndef FLATBUFFERS_PREFER_PRINTF |
| 206 | std::stringstream ss; |
| 207 | ss << std::setw(xdigits) << std::setfill('0') << std::hex << std::uppercase |
| 208 | << i; |
| 209 | return ss.str(); |
| 210 | #else // FLATBUFFERS_PREFER_PRINTF |
| 211 | return NumToStringImplWrapper(i, "%.*X", xdigits); |
| 212 | #endif // FLATBUFFERS_PREFER_PRINTF |
| 213 | // clang-format on |
| 214 | } |
| 215 | |
| 216 | // clang-format off |
| 217 | // Use locale independent functions {strtod_l, strtof_l, strtoll_l, strtoull_l}. |
no test coverage detected