MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / arg

Method arg

src/Engine/LocalizedText.cpp:30–44  ·  view source on GitHub ↗

* Replace the next argument placeholder with @a val. * @param val The value to place in the next placeholder's position. * @return A translated string with all occurences of the marker replaced by @a val. */

Source from the content-addressed store, hash-verified

28 * @return A translated string with all occurences of the marker replaced by @a val.
29 */
30LocalizedText LocalizedText::arg(std::wstring const &val) const
31{
32 std::wostringstream os;
33 os << '{' << _nextArg << '}';
34 std::wstring marker(os.str());
35 size_t pos = _text.find(marker);
36 if (std::wstring::npos == pos)
37 return *this;
38 std::wstring ntext(_text);
39 for (/*empty*/ ; std::wstring::npos != pos; pos = ntext.find(marker, pos + val.length()))
40 {
41 ntext.replace(pos, marker.length(), val);
42 }
43 return LocalizedText(ntext, _nextArg);
44}
45
46/**
47 * Replace the next argument placeholder with @a val.

Callers

nothing calls this directly

Calls 2

replaceMethod · 0.80
LocalizedTextClass · 0.70

Tested by

no test coverage detected