Tools.h++ Manual

21-134 104011 Tandem Computers Incorporated
21
RWLocale
Synopsis
#include <locale.h>
#include <rw/locale.h>
(Abstract base class)
Description
RWLocale
is an abstract base class. It defines an interface for formatting dates
(including day and month names), times, numbers (including digit grouping),
and currency, to and from strings.
Note that because it is an abstract base class, there is no way to actually enforce
these goals—the description here is merely the model of how a class derived
from
RWLocale
should act.
There are three ways to use an
RWLocale
object:
By passing it to functions which expect one, such as
RWDate::asString()
.
By specifying a “global” locale by using the static member function
RWLocale::global()
. This locale is passed as the default argument to
functions that use a locale.
By “imbuing” a stream with one so that when an
RWDate
or
RWTime
is
written to a stream using
operator<<()
, the appropriate formatting will
be used automatically.
Two implementations of
RWLocale
are provided with the library:
RWLocaleSnapshot and
RWLocaleDefault
.
Class
RWLocaleSnapshot
encapsulates the Standard C library locale
facility, with two additional advantages: more than one locale can be active
at the same time; and it supports conversions from strings to other types.
Class
RWLocaleDefault
implements only the “C” locale. It is small and
cheap to construct: one is constructed automatically at program startup to
be used as the default value of
RWLocale::global()
.
Enumeration
enum CurrSymbol { NONE, LOCAL, INTL };
Controls whether no currency symbol, the local currency symbol, or the
international currency symbol should be used to format currency.