MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / to_hex

Function to_hex

include/dpp/stringops.h:195–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193 * @return std::string value in hex, the length will be 2* the raw size of the type
194 */
195template <typename T> std::string to_hex(T i, bool leading_zeroes = true)
196{
197 char str[26] = { 0 };
198 size_t size = sizeof(T) * 2;
199 std::to_chars(std::begin(str), std::end(str), i, 16);
200 std::string out{str};
201 if (leading_zeroes && out.length() < size) {
202 out.insert(out.begin(), size - out.length(), '0');
203 }
204 return out;
205}
206
207/**
208 * @brief Format a numeric type as a string with leading zeroes

Callers 4

httpsclient.hFile · 0.70
build_multipartMethod · 0.50
to_stringMethod · 0.50
debug_dumpFunction · 0.50

Calls 4

beginFunction · 0.85
endFunction · 0.85
insertMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected