/usr/include/Wt/WLocale is in libwt-dev 3.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2012 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WLOCALE_H_
#define WLOCALE_H_
#include <Wt/WGlobal>
#include <Wt/WString>
namespace Wt {
/*! \class WLocale Wt/WLocale Wt/WLocale
* \brief 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.
*
* \sa WApplication::locale()
*/
class WT_API WLocale
{
public:
/*! \brief 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.
*/
WLocale();
/*! \brief Copy constructor.
*/
WLocale(const Wt::WLocale& locale);
/* \brief Creates a locale by name.
*
* The locale name is a string such as "en" (for English) or "en_UK"
* (for UK English).
*/
WLocale(const std::string& locale);
/* \brief Creates a locale by name.
*
* The locale name is a string such as "en" (for English) or "en_UK"
* (for UK English).
*/
WLocale(const char *locale);
/*! \brief 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 setDecimalPoint(WT_UCHAR c);
/*! \brief Returns the decimal point.
*
* \sa setDecimalPoint()
*/
WT_UCHAR decimalPoint() const { return decimalPoint_; }
/*! \brief 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.
*/
void setGroupSeparator(WT_UCHAR c);
/*! \brief Returns the decimal group separator.
*
* \sa setGroupSeparator()
*/
WT_UCHAR groupSeparator() const { return groupSeparator_; }
/*! \brief 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 setDateFormat(const WT_USTRING& format);
/*! \brief Returns the date format.
*
* Returns the date format.
*/
WT_USTRING dateFormat() const { return dateFormat_; }
/*! \brief Returns the locale name.
*
* This is the name of the locale that was set through the
* constructor.
*/
std::string name() const { return name_; }
/*! \brief Casts to the locale string (for pre-3.3.0 compatibility).
*
* \deprecated Use name() instead.
*/
operator std::string() const { return name(); }
/*! \brief Returns the current (user) locale.
*
* This returns WApplication::instance()->locale() if the
* WApplication::instance() != 0, or a default locale otherwise.
*/
static const WLocale& currentLocale();
/*! \brief Parses a floating point number.
*
* Throws a runtime exception if the number could not be parsed.
*/
double toDouble(const WT_USTRING& value) const;
/*! \brief Parses an integer number.
*
* Throws a runtime exception if the number could not be parsed.
*/
int toInt(const WT_USTRING& value) const;
/*! \brief Formats an integer number.
*/
WT_USTRING toString(int value) const;
/*! \brief Formats an integer number.
*/
WT_USTRING toString(unsigned int value) const;
/*! \brief Formats an integer number.
*/
WT_USTRING toString(::int64_t value) const;
/*! \brief Formats an integer number.
*/
WT_USTRING toString(::uint64_t value) const;
/*! \brief Formats a floating point number.
*/
WT_USTRING toString(double value) const;
private:
std::string name_;
WT_UCHAR decimalPoint_, groupSeparator_;
WT_USTRING dateFormat_;
bool isDefaultNumberLocale() const;
WT_USTRING integerToString(const std::string& v) const;
std::string addGrouping(const std::string& v, unsigned decimalPoint) const;
};
}
#endif // WLOCALE_H_
|