OpenXcom  1.0
Open-source clone of the original X-Com
Public Member Functions | List of all members
OpenXcom::LocalizedText Class Reference

A string that is already translated. More...

#include <LocalizedText.h>

Public Member Functions

 LocalizedText (const std::wstring &)
 Create from existing unicode string. More...
 
 LocalizedText ()
 Create the empty string.
 
 operator std::wstring const & () const OX_REQUIRED_RESULT
 Return constant wide string.
 
std::string asUTF8 () const OX_REQUIRED_RESULT
 Return the UTF-8 representation of this string. More...
 
const wchar_t * c_str () const OX_REQUIRED_RESULT
 Get a pointer to underlying wchat_t data.
 
LocalizedText arg (std::wstring const &) const OX_REQUIRED_RESULT
 Replace next argument. More...
 
LocalizedTextarg (std::wstring const &) OX_REQUIRED_RESULT
 Replace next argument. More...
 
template<typename T >
LocalizedText arg (T) const OX_REQUIRED_RESULT
 Replace next argument. More...
 
template<typename T >
LocalizedTextarg (T) OX_REQUIRED_RESULT
 Replace next argument. More...
 

Detailed Description

A string that is already translated.

Using this class allows argument substitution in the translated strings.

Constructor & Destructor Documentation

◆ LocalizedText()

OpenXcom::LocalizedText::LocalizedText ( const std::wstring &  text)
inline

Create from existing unicode string.

Create a LocalizedText from a localized std::wstring.

Member Function Documentation

◆ arg() [1/4]

LocalizedText OpenXcom::LocalizedText::arg ( std::wstring const &  val) const

Replace next argument.

Replace the next argument placeholder with val.

Parameters
valThe value to place in the next placeholder's position.
Returns
A translated string with all occurences of the marker replaced by val.

◆ arg() [2/4]

LocalizedText & OpenXcom::LocalizedText::arg ( std::wstring const &  val)

Replace next argument.

Replace the next argument placeholder with val.

Parameters
valThe value to place in the next placeholder's position.
Returns
The translated string with all occurences of the marker replaced by val.

◆ arg() [3/4]

template<typename T >
LocalizedText OpenXcom::LocalizedText::arg ( val) const

Replace next argument.

Replace the next argument placeholder with val.

Template Parameters
TThe type of the replacement value. It should be streamable to std::owstringstream.
Parameters
valThe value to place in the next placeholder's position.
Returns
A translated string with all occurences of the marker replaced by val.

◆ arg() [4/4]

template<typename T >
LocalizedText & OpenXcom::LocalizedText::arg ( val)

Replace next argument.

Replace the next argument placeholder with val.

Template Parameters
TThe type of the replacement value. It should be streamable to std::owstringstream.
Parameters
valThe value to place in the next placeholder's position.
Returns
The translated string with all occurences of the marker replaced by val.

◆ asUTF8()

std::string OpenXcom::LocalizedText::asUTF8 ( ) const

Return the UTF-8 representation of this string.

Returns
A UTF-8 string.

The documentation for this class was generated from the following files: