| 442 | } |
| 443 | |
| 444 | std::string Ellipsise(const std::string_view str, u32 max_length, const char* ellipsis /*= "..."*/) |
| 445 | { |
| 446 | std::string ret; |
| 447 | ret.reserve(max_length); |
| 448 | |
| 449 | const u32 str_length = static_cast<u32>(str.length()); |
| 450 | const u32 ellipsis_len = static_cast<u32>(std::strlen(ellipsis)); |
| 451 | pxAssert(ellipsis_len > 0 && ellipsis_len <= max_length); |
| 452 | |
| 453 | if (str_length > max_length) |
| 454 | { |
| 455 | const u32 copy_size = std::min(str_length, max_length - ellipsis_len); |
| 456 | if (copy_size > 0) |
| 457 | ret.append(str.data(), copy_size); |
| 458 | if (copy_size != str_length) |
| 459 | ret.append(ellipsis); |
| 460 | } |
| 461 | else |
| 462 | { |
| 463 | ret.append(str); |
| 464 | } |
| 465 | |
| 466 | return ret; |
| 467 | } |
| 468 | |
| 469 | void EllipsiseInPlace(std::string& str, u32 max_length, const char* ellipsis /*= "..."*/) |
| 470 | { |