MCPcopy Create free account
hub / github.com/arvidn/libtorrent / to_string

Function to_string

src/string_util.cpp:51–70  ·  view source on GitHub ↗

We need well defined results that don't depend on locale

Source from the content-addressed store, hash-verified

49
50 // We need well defined results that don't depend on locale
51 std::array<char, 4 + std::numeric_limits<std::int64_t>::digits10>
52 to_string(std::int64_t const n)
53 {
54 std::array<char, 4 + std::numeric_limits<std::int64_t>::digits10> ret;
55 char *p = &ret.back();
56 *p = '\0';
57 // we want "un" to be the absolute value
58 // since the absolute of INT64_MIN cannot be represented by a signed
59 // int64, we calculate the abs in unsigned space
60 std::uint64_t un = n < 0
61 ? std::numeric_limits<std::uint64_t>::max() - std::uint64_t(n) + 1
62 : std::uint64_t(n);
63 do {
64 *--p = '0' + un % 10;
65 un /= 10;
66 } while (un);
67 if (n < 0) *--p = '-';
68 std::memmove(ret.data(), p, std::size_t(&ret.back() - p + 1));
69 return ret;
70 }
71
72 bool is_alpha(char c)
73 {

Callers 15

write_requestMethod · 0.70
handle_errorMethod · 0.70
mapping_logMethod · 0.70
send_map_requestMethod · 0.70
print_listen_interfacesFunction · 0.70
format_host_for_connectFunction · 0.70
write_requestMethod · 0.70
on_receiveMethod · 0.70
startMethod · 0.70
messageMethod · 0.70
make_magnet_uriFunction · 0.70
create_port_mappingMethod · 0.70

Calls 2

maxFunction · 0.85
dataMethod · 0.45

Tested by 2

TORRENT_TESTFunction · 0.40
TORRENT_TESTFunction · 0.40