rwsf::LocaleSnapshotrwsf::Locale
#include <rwsf/core/LocaleSnapshot.h>
The class rwsf::LocaleSnapshot implements the rwsf::Locale interface using Standard C Library facilities. To use it, the program creates an rwsf::LocaleSnapshot instance. The constructor of the instance queries the program's environment (using Standard C Library functions such as localeconv(), strftime(), and, if available, vendor specific library functions) to determine the formatting conventions in effect at the moment of instantiation. When done, the locale can then be switched and another instance of rwsf::LocaleSnapshot created.
By creating multiple instances of rwsf::LocaleSnapshot, your program can have more than one locale active at the same time, something that is difficult to do with the Standard C Library facilities.
Note: rwsf::LocaleSnapshot does not encapsulate character set, collation, or message information.
Class rwsf::LocaleSnapshot contains a set of public data members initialized by its constructor with information extracted from its execution environment.
For a description of the static members of the rwsf::Locale interface that operate on objects of type rwsf::LocaleSnapshot, see the rwsf::Locale class description.
LocaleSnapshot(const char* localeName = 0);
Constructs an rwsf::Locale object by extracting formats from the global locale environment. It uses the Standard C Library function setlocale() to set the named locale, and then restores the previous global locale after formats have been extracted. If localeName is 0, it simply uses the current locale. The most useful locale name is the empty string, "", which is a synonym for the user's chosen locale (usually specified by the environment variable LANG).
virtual std::string asString(long) const; virtual std::string asString(unsigned long) const; virtual std::string asString(double f, int precision = 6, bool showpoint = 0) const; std::string asString(const struct tm* tmbuf, const char *format, const rwsf::TimeZone& r = rwsf::TimeZone::local()) const; virtual std::string
asString(const struct tm* tmbuf, char format, const rwsf::TimeZone& = rwsf::TimeZone::local())
const; virtual std::string
moneyAsString(double, CurrSymbol=LOCAL) const; virtual std::string
moneyAsString(double, Locale::CurrSymbol=LOCAL) const; virtual int
monthIndex(const std::string&) const; virtual bool stringToDate (const std::string&, struct tm*) const; virtual bool stringToMoney(const std::string&, double*, Locale::CurrSymbol=LOCAL) const; virtual bool stringToNum (const std::string&, double*) const; virtual bool stringToNum (const std::string&, long*) const; virtual bool stringToNum (const std::string&, unsigned long*) const; stringToTime (const std::string&, struct tm*) const; virtual int weekdayIndex(const std::string&) const;
Note: All previous member functions are redefined from class rwsf::Locale. These virtual functions follow the interface described under class rwsf::Locale. They generally work by converting values to and from strings using the rules specified by the struct lconv values (see <locale.h>) encapsulated in self.
virtual const std::string&
currency_symbol() const;
Returns a string to use as the currency symbol for this locale.
virtual const std::string&
decimal_point() const;
Returns a string to use as the numerical decimal separator.
virtual const std::string& grouping() const;
Returns a string identifying the number of digits to be included in a numerical group. A group is simply the digits between adjacent thousand's separators.
Each character of the string is an integer that specifies the number of digits in a group, starting with the right most group.
If the value is equal to 0, the previous element is used repeatedly for the remainder of the digits.
If the value is equal to CHAR_MAX, no further grouping is to be performed.
Example
"\3" \\ Specifies the United States grouping system. \\ For example, "1,000,000" "\3\2" \\ Specifies the Nepalese grouping system. \\ For example, "1,00,00,000"
virtual const std::string&
int_curr_symbol() const;
Returns a string to use as the international currency symbol.
virtual const std::string&
locale_name() const;
Returns the name of the encapsulated std::locale.
virtual const std::string&
mon_decimal_point() const;
Returns a string to use as the monetary decimal separator.
virtual const std::string&
mon_thousands_sep() const;
Returns a string to use as the monetary thousands separator.
virtual const std::string&
mon_grouping() const;
Returns a string identifying the number of digits to be included in a numerical group. A group is simply the digits between adjacent thousand's separators.
Each character of the string is an integer that specifies the number of digits in a group, starting with the right most group.
If the value is equal to 0, the previous element is used repeatedly for the remainder of the digits.
If the value is equal to CHAR_MAX, no further grouping is to be performed.
See Example under grouping().
virtual const std::string& positive_sign() const;
Returns a string to use as the positive sign.
virtual const std::string& negative_sign() const;
Returns a string to use as the negative sign.
virtual const std::string& thousands_sep() const;
Returns a string to use as the numerical thousands separator.
std::string decimal_point_; std::string thousands_sep_; std::string grouping_; std::string int_curr_symbol_; std::string currency_symbol_; std::string mon_decimal_point_; std::string mon_thousands_sep_; std::string mon_grouping_; std::string positive_sign_; std::string negative_sign_; char int_frac_digits_; char frac_digits_; char p_cs_precedes_; char p_sep_by_space_; char n_cs_precedes_; char n_sep_by_space_; char p_sign_posn_; char n_sign_posn_;
These are defined identically as the correspondingly-named members of the Standard C Library type lconv, from <locale.h>.
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks and HydraSDO is a trademark of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.