Wt  3.3.0
Public Member Functions | Static Public Member Functions
Wt::WLocale Class Reference

A locale. More...

#include <Wt/WLocale>

List of all members.

Public Member Functions

 WLocale ()
 Default constructor.
 WLocale (const Wt::WLocale &locale)
 Copy constructor.
void setDecimalPoint (std::string c)
 Sets the decimal point.
std::string decimalPoint () const
 Returns the decimal point.
void setGroupSeparator (std::string c)
 Sets the decimal group separator.
std::string groupSeparator () const
 Returns the decimal group separator.
void setDateFormat (const WString &format)
 Sets the date format.
WString dateFormat () const
std::string name () const
 Returns the locale name.
 operator std::string () const
 Casts to the locale string (for pre-3.3.0 compatibility).
double toDouble (const WString &value) const
 Parses a floating point number.
int toInt (const WString &value) const
 Parses an integer number.
WString toString (int value) const
 Formats an integer number.
WString toString (unsigned int value) const
 Formats an integer number.
WString toString (::int64_t value) const
 Formats an integer number.
WString toString (::uint64_t value) const
 Formats an integer number.
WString toString (double value) const
 Formats a floating point number.

Static Public Member Functions

static const WLocalecurrentLocale ()
 Returns the current (user) locale.

Detailed Description

A locale.

This class provides localization support for an application.

It's functionality is currently limited to date and number formatting, and the formatting properties need to be configured here, we plan to leverage standard C++ locale functionality to obtain these configurations. The locale also provides client-side support, and thus cannot solely rely on C++'s locale support.

See also:
WApplication::locale()

Constructor & Destructor Documentation

Wt::WLocale::WLocale ( )

Default constructor.

Configures a locale with an empty name, and US conventions:

  • "yyyy/MM/dd" format for dates.
  • "." as decimal point, and no group separator.

Member Function Documentation

const WLocale & Wt::WLocale::currentLocale ( ) [static]

Returns the current (user) locale.

This returns WApplication::instance()->locale() if the WApplication::instance() != 0, or a default locale otherwise.

WString Wt::WLocale::dateFormat ( ) const

Returns the date format.

std::string Wt::WLocale::decimalPoint ( ) const

Returns the decimal point.

See also:
setDecimalPoint()
std::string Wt::WLocale::groupSeparator ( ) const

Returns the decimal group separator.

See also:
setGroupSeparator()
std::string Wt::WLocale::name ( ) const

Returns the locale name.

This is the name of the locale that was set through the constructor.

Wt::WLocale::operator std::string ( ) const

Casts to the locale string (for pre-3.3.0 compatibility).

Deprecated:
Use name() instead.
void Wt::WLocale::setDateFormat ( const WString format)

Sets the date format.

Sets the default format for date entry, e.g. as used in WDateValidator. See WDate::toString() for the supported syntax.

void Wt::WLocale::setDecimalPoint ( std::string  c)

Sets the decimal point.

Sets the character used to separate integral from fractional digits in a double.

Note:
the argument is a UTF-8 encoded character and can thus be up to 4 byte.
void Wt::WLocale::setGroupSeparator ( std::string  c)

Sets the decimal group separator.

Sets the character used to separate thousands in a number.

Note:
the argument is a UTF-8 encoded character and can thus be up to 4 byte.
double Wt::WLocale::toDouble ( const WString value) const

Parses a floating point number.

Throws a runtime exception if the number could not be parsed.

int Wt::WLocale::toInt ( const WString value) const

Parses an integer number.

Throws a runtime exception if the number could not be parsed.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Mon Apr 8 2013 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1