SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Creates an snapshot of a locale by querying the program's environment to determine the formatting conventions in effect at the moment of instantiation. More...
#include <rw/tools/localesnapshot.h>
Public Member Functions | |
RWLocaleSnapshot () | |
RWLocaleSnapshot (const char *localeName) | |
RWCString | asString (const struct tm *t, const char *fmt, const RWZone &z=RWZone::local()) const |
virtual RWCString | asString (const struct tm *, char, const RWZone &=RWZone::local()) const |
virtual RWCString | asString (long) const |
virtual RWCString | asString (unsigned long) const |
virtual RWCString | asString (double, int=6, bool=0) const |
virtual RWCString | asString (long double, int=10, bool=0) const |
virtual const RWCString & | currency_symbol () const |
virtual const RWCString & | decimal_point () const |
virtual const RWCString & | grouping () const |
virtual const RWCString & | int_curr_symbol () const |
virtual const RWCString & | locale_name () const |
virtual const RWCString & | mon_decimal_point () const |
virtual const RWCString & | mon_grouping () const |
virtual const RWCString & | mon_thousands_sep () const |
virtual RWCString | moneyAsString (double, RWLocaleSnapshot::CurrSymbol=LOCAL) const |
virtual int | monthIndex (const RWCString &) const |
virtual const RWCString & | negative_sign () const |
virtual const RWCString & | positive_sign () const |
virtual bool | stringToDate (const RWCString &, struct tm *) const |
virtual bool | stringToMoney (const RWCString &, double *, RWLocaleSnapshot::CurrSymbol=LOCAL) const |
virtual bool | stringToNum (const RWCString &, double *) const |
virtual bool | stringToNum (const RWCString &, long *) const |
virtual bool | stringToNum (const RWCString &, unsigned long *) const |
virtual bool | stringToTime (const RWCString &, struct tm *) const |
virtual const RWCString & | thousands_sep () const |
virtual int | weekdayIndex (const RWCString &) const |
Public Member Functions inherited from RWLocale | |
RWCString | asString (const struct tm *tmbuf, const char *format, const RWZone &zone=RWZone::local()) const |
const RWLocale * | imbue (std::ios &stream) const |
Additional Inherited Members | |
Public Types inherited from RWLocale | |
enum | CurrSymbol { NONE, LOCAL, INTL } |
Static Public Member Functions inherited from RWLocale | |
static const RWLocale * | defaultLocale () |
static const RWLocale & | global () |
static const RWLocale * | global (const RWLocale *loc) |
static const RWLocale & | of (std::ios &stream) |
static const RWLocale * | unimbue (std::ios &stream) |
The class RWLocaleSnapshot implements the RWLocale interface using C Standard Library facilities. To use it, the program creates an RWLocaleSnapshot instance. The constructor of the instance queries the program's environment (using C Standard 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 RWLocaleSnapshot created.
By creating multiple instances of RWLocaleSnapshot, your program can have more than one locale active at the same time, something that is difficult to do with the C Standard Library facilities.
Class RWLocaleSnapshot 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 RWLocale interface that operate on objects of type RWLocaleSnapshot, see the RWLocale class description.
Program output:
RWLocaleSnapshot::RWLocaleSnapshot | ( | ) |
Constructs an RWLocale object by extracting formats from the current locale environment.
RWLocaleSnapshot::RWLocaleSnapshot | ( | const char * | localeName | ) |
Constructs an RWLocale object by extracting formats from the global locale environment. It uses the C++ Standard Library function std::setlocale() to set the named locale, and then restores the previous global locale after formats have been extracted. If localeName is 0, it 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
).
RWCString RWLocaleSnapshot::asString | ( | const struct tm * | t, |
const char * | fmt, | ||
const RWZone & | z = RWZone::local() |
||
) | const |
Redefined from RWLocale
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the currency symbol for this locale.
Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the numerical decimal separator.
Implements RWLocale.
|
inlinevirtual |
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.
CHAR_MAX
, no further grouping is to be performed.Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the international currency symbol.
Implements RWLocale.
|
inlinevirtual |
Returns the name of the encapsulated std::locale.
Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the monetary decimal separator.
Implements RWLocale.
|
inlinevirtual |
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 CHAR_MAX
, no further grouping is to be performed.
See Example under grouping().
Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the monetary thousands separator.
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Interprets its argument as a full or abbreviated month name, returning values 1 through 12 to represent (respectively) January through December, or 0 for an error. Ignores leading white space.
Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the negative sign.
Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the positive sign.
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
virtual |
Redefined from RWLocale
Implements RWLocale.
|
inlinevirtual |
Returns a string to use as the numerical thousands separator.
Implements RWLocale.
|
virtual |
Interprets its argument as a full or abbreviated weekday name, returning values 1 through 7 to represent (respectively) Monday through Sunday, or 0 for an error.
Implements RWLocale.
RWCString RWLocaleSnapshot::currency_symbol_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::decimal_point_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::frac_digits_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::grouping_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::int_curr_symbol_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::int_frac_digits_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::mon_decimal_point_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::mon_grouping_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::mon_thousands_sep_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::n_cs_precedes_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::n_sep_by_space_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::n_sign_posn_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::negative_sign_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::p_cs_precedes_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::p_sep_by_space_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
char RWLocaleSnapshot::p_sign_posn_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::positive_sign_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
RWCString RWLocaleSnapshot::thousands_sep_ |
Defined identically as the correspondingly-named member of the C++ Standard Library type std::lconv.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |