MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Ellipsise

Function Ellipsise

common/StringUtil.cpp:444–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 3

UpdateDiscordPresenceMethod · 0.85
TESTFunction · 0.85

Calls 5

minFunction · 0.50
reserveMethod · 0.45
lengthMethod · 0.45
appendMethod · 0.45
dataMethod · 0.45

Tested by 1

TESTFunction · 0.68