| 106 | */ |
| 107 | template <typename T> |
| 108 | LocalizedText LocalizedText::arg(T val) const |
| 109 | { |
| 110 | std::wostringstream os; |
| 111 | os << '{' << _nextArg << '}'; |
| 112 | std::wstring marker(os.str()); |
| 113 | size_t pos = _text.find(marker); |
| 114 | if (std::string::npos == pos) |
| 115 | return *this; |
| 116 | std::wstring ntext(_text); |
| 117 | os.str(L""); |
| 118 | os << val; |
| 119 | std::wstring tval(os.str()); |
| 120 | for (/*empty*/ ; std::wstring::npos != pos; pos = ntext.find(marker, pos + tval.length())) |
| 121 | { |
| 122 | ntext.replace(pos, marker.length(), tval); |
| 123 | } |
| 124 | return LocalizedText(ntext, _nextArg); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Replace the next argument placeholder with @a val. |