| 48 | /// <returns>The best fitting string of the units.</returns> |
| 49 | template<typename T> |
| 50 | String UnitsToText(T units, int32 divider, const Span<const Char*> sizes) |
| 51 | { |
| 52 | if (sizes.Length() == 0) |
| 53 | return String::Format(TEXT("{0}"), units); |
| 54 | int32 i = 0; |
| 55 | double dblSUnits = static_cast<double>(units); |
| 56 | for (; static_cast<uint64>(units / static_cast<double>(divider)) > 0; i++, units /= divider) |
| 57 | dblSUnits = (double)units / (double)divider; |
| 58 | if (i >= sizes.Length()) |
| 59 | i = 0; |
| 60 | String text = String::Format(TEXT("{}"), RoundTo2DecimalPlaces(dblSUnits)); |
| 61 | const int32 dot = text.FindLast('.'); |
| 62 | if (dot != -1) |
| 63 | text = text.Left(dot + 3); |
| 64 | return String::Format(TEXT("{0} {1}"), text, sizes[i]); |
| 65 | } |
| 66 | |
| 67 | /// <summary> |
| 68 | /// Converts size of the data (in bytes) to the best fitting string. |
no test coverage detected