29 #ifndef OX_REQUIRED_RESULT 30 # if defined(__GNUC_) && !defined(__INTEL_COMPILER) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) 31 # define OX_REQUIRED_RESULT __attribute__ ((warn_unused_result)) 33 # define OX_REQUIRED_RESULT 55 const wchar_t *
c_str() const OX_REQUIRED_RESULT {
return _text.c_str(); }
75 : _text(text), _nextArg(0)
84 : _text(text), _nextArg(replaced + 1)
93 inline LocalizedText::operator std::wstring
const&()
const 104 template <
typename T>
107 std::wostringstream os;
108 os <<
'{' << _nextArg <<
'}';
109 std::wstring marker(os.str());
110 size_t pos = _text.find(marker);
111 if (std::string::npos == pos)
113 std::wstring ntext(_text);
116 std::wstring tval(os.str());
117 for ( ; std::wstring::npos != pos; pos = ntext.find(marker, pos + tval.length()))
119 ntext.replace(pos, marker.length(), tval);
130 template <
typename T>
133 std::wostringstream os;
134 os <<
'{' << _nextArg <<
'}';
135 std::wstring marker(os.str());
136 size_t pos = _text.find(marker);
137 if (std::string::npos != pos)
141 std::wstring tval(os.str());
142 for ( ; std::wstring::npos != pos; pos = _text.find(marker, pos + tval.length()))
144 _text.replace(pos, marker.length(), tval);
152 inline std::wostream &operator<<(std::wostream &os,
const LocalizedText &txt)
154 os << static_cast<std::wstring const &>(txt);
LocalizedText()
Create the empty string.
Definition: LocalizedText.h:49
std::string asUTF8() const OX_REQUIRED_RESULT
Return the UTF-8 representation of this string.
Definition: LocalizedText.cpp:82
#define OX_REQUIRED_RESULT
This is used to enable warning of unused results, to warn the user of costly function calls...
Definition: LocalizedText.h:33
A string that is already translated.
Definition: LocalizedText.h:43
LocalizedText arg(const std::wstring &) const OX_REQUIRED_RESULT
Replace next argument.
Definition: LocalizedText.cpp:30
const wchar_t * c_str() const OX_REQUIRED_RESULT
Get a pointer to underlying wchat_t data.
Definition: LocalizedText.h:55
Definition: BaseInfoState.cpp:40