OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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. More...
 
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

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

Create from existing unicode string.

Create a LocalizedText from a localized std::wstring.

Member Function Documentation

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.
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.
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.
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.
std::string OpenXcom::LocalizedText::asUTF8 ( ) const

Return the UTF-8 representation of this string.

Returns
A UTF-8 string.
OpenXcom::LocalizedText::operator std::wstring const & ( ) const
inline

Return constant wide string.

Typecast to constant std::wstring reference.

This is used to avoid copying when the string will not change.


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