MCPcopy Create free account
hub / github.com/MihailRis/voxelcore / format_data_size

Method format_data_size

src/util/stringutil.cpp:428–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428std::string util::format_data_size(size_t size) {
429 if (size < 1024) {
430 return std::to_string(size)+" B";
431 }
432 const std::string postfixes[] {
433 " B", " KiB", " MiB", " GiB", " TiB", " EiB", " PiB"
434 };
435 int group = 0;
436 size_t remainder = 0;
437 while (size >= 1024) {
438 group++;
439 remainder = size % 1024;
440 size /= 1024;
441 }
442 return std::to_string(size)+"."+
443 std::to_string(static_cast<int>(round(remainder/1024.0f)))+
444 postfixes[group];
445}
446
447std::pair<std::string, std::string> util::split_at(std::string_view view, char c) {
448 size_t idx = view.find(c);

Callers

nothing calls this directly

Calls 1

to_stringFunction · 0.50

Tested by

no test coverage detected