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

Function EllipsiseInPlace

common/StringUtil.cpp:469–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467 }
468
469 void EllipsiseInPlace(std::string& str, u32 max_length, const char* ellipsis /*= "..."*/)
470 {
471 const u32 str_length = static_cast<u32>(str.length());
472 const u32 ellipsis_len = static_cast<u32>(std::strlen(ellipsis));
473 pxAssert(ellipsis_len > 0 && ellipsis_len <= max_length);
474
475 if (str_length > max_length)
476 {
477 const u32 keep_size = std::min(static_cast<u32>(str.length()), max_length - ellipsis_len);
478 if (keep_size != str_length)
479 str.erase(keep_size);
480
481 str.append(ellipsis);
482 }
483 }
484
485#ifdef _WIN32
486 std::wstring UTF8StringToWideString(const std::string_view str)

Callers 1

TESTFunction · 0.85

Calls 4

minFunction · 0.50
lengthMethod · 0.45
eraseMethod · 0.45
appendMethod · 0.45

Tested by 1

TESTFunction · 0.68