#include <WString>
Public Member Functions | |
| WString (const wchar_t *value=0) | |
| Construct a WString from a wide C string. | |
| WString (const WString &other) | |
| Copy constructor. | |
| WString (const std::wstring value) | |
| Construct a WString from a wide C++ string. | |
| WString (const char *value) | |
| Construct a WString from a C string. | |
| WString (const std::string value) | |
| Construct a WString from a C++ string. | |
| ~WString () | |
| Delete a WString. | |
| WString & | operator= (const WString &rhs) |
| Assignment operator. | |
| bool | operator== (const WString &rhs) const |
| Comparison operator. | |
| WString & | operator+= (const WString &rhs) |
| Self-concatenation operator. | |
| WString & | operator+= (const std::wstring rhs) |
| Self-concatenation operator. | |
| WString & | operator+= (const wchar_t *rhs) |
| Self-concatenation operator. | |
| WString & | operator+= (const std::string rhs) |
| Self-concatenation operator. | |
| WString & | operator+= (const char *rhs) |
| Self-concatenation operator. | |
| bool | empty () const |
| Is the string empty ? | |
| std::string | toUTF8 () const |
| Get the value as a UTF8 unicode encoded string. | |
| std::wstring | value () const |
| Get the value as a wide C++ string. | |
| std::string | narrow () const |
| Get the value as a narrow C++ string. | |
| operator std::wstring () const | |
| Get the value as a wide C++ string. | |
| bool | literal () const |
| Is this string literal or localized ? | |
| const std::string | key () const |
| Get the key for this localized string. | |
| WString & | arg (const std::wstring value) |
| Add a value for the next positional string argument of this localized string. | |
| WString & | arg (const std::string value) |
| Add a value for the next positional string argument of this localized string. | |
| WString & | arg (int value) |
| Add a value for the next positional integer argument of this localized string. | |
| const std::vector< std::wstring > & | args () const |
| The list of arguments. | |
| bool | refresh () |
| Refresh the message. | |
Static Public Member Functions | |
| static WString | fromUTF8 (const std::string value) |
| Construct a WString from a UTF8 unicode encoded string. | |
| static WString | tr (const char *key) |
| Construct a localized string with the specified key. | |
Wt offers this string to facilitate handling of unicode text through the user interface, as well as to offer support for localized text using message resource bundles.
A WString may be constructed from a std::string, std::wstring or c-style strings (const char * and const wchar_t *), and converted to each of these strings. In addition, it supports conversion from and to UTF8 unicode encoded strings.
By using the static functions WString::tr() (or WWidget::tr()), one may construct a localized string. The key is used to retrieve its current value from the application's message-resource bundles. Arguments in the message, denoted using {n} for the n'th argument, may be substituted by arguments set using arg(int) and arg(std::string).
By calling WApplication::refresh(), the contents of every WString may be refreshed by the owner (and this is done so for all Wt widgets that own a WString), by calling refresh(). In this way, the contents is adapted to a possibly changed locale.
This string class does not provide anything more than basic manipulations. Instead, you should convert to a standard library string class to manipulate the string contents.
| WString & Wt::WString::arg | ( | int | value | ) |
Add a value for the next positional integer argument of this localized string.
In the resource, the n-th argument is reffered to as using '{n}'. For example: a resource message '{1} bought {2} apples in the shop.' with first argument value 'Bart' and second argument value '5' becomes: 'Bart bought 5 apples in the shop.'.
| WString& Wt::WString::arg | ( | const std::string | value | ) |
Add a value for the next positional string argument of this localized string.
In the resource, the n-th argument is reffered to as using '{n}'. For example: a resource message '{1} bought {2} apples in the shop.' with first argument value 'Bart' and second argument value '5' becomes: 'Bart bought 5 apples in the shop.'.
| WString & Wt::WString::arg | ( | const std::wstring | value | ) |
Add a value for the next positional string argument of this localized string.
In the resource, the n-th argument is reffered to as using '{n}'. For example: a resource message '{1} bought {2} apples in the shop.' with first argument value 'Bart' and second argument value '5' becomes: 'Bart bought 5 apples in the shop.'.
| const std::string Wt::WString::key | ( | ) | const |
Get the key for this localized string.
When the string is literal, the result is undefined.
| bool Wt::WString::literal | ( | ) | const [inline] |
| std::string Wt::WString::narrow | ( | ) | const |
| Wt::WString::operator std::wstring | ( | ) | const |
Get the value as a wide C++ string.
For a localized string, returns the current localized value.
| bool Wt::WString::refresh | ( | ) |
Refresh the message.
For a localized message, this rereads the value from the message resource bundle.
Returns whether the value has changed.
| std::string Wt::WString::toUTF8 | ( | ) | const |
Get the value as a UTF8 unicode encoded string.
For a localized string, returns the current localized value.
| WString Wt::WString::tr | ( | const char * | key | ) | [static] |
Construct a localized string with the specified key.
The key is looked up in the application message resource bundles. If the key cannot be resolved, the value is set to ??key??.
| std::wstring Wt::WString::value | ( | ) | const |
Get the value as a wide C++ string.
For a localized string, returns the current localized value.
1.4.7