Tools.h++ Manual

104011 Tandem Computers Incorporated 21-139
21
RWLocaleSnapshot
RWLocaleSnapshot
|
RWLocale
Synopsis
#include <locale.h>
#include /locale.h
RWLocaleSnapshot ourLocale(""); // encapsulate user's
formats
Description The class
RWLocaleSnapshot
implements the
RWLocale
interface using Standard C library facilities. To use it, the program creates an
RWLocaleSnapshot
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 learn everything it can about 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
Standard C library facilities.
Note –
RWLocaleSnapshot
does not encapsulate character set, collation, or
message information.
Class
RWLocaleSnapshot
has a set of public data members initialized by its
constructor with information extracted from its execution environment.
Example Try this program with the environmental variable
LANG
set to various locales:
Code Example 21-3
#include <locale.h>
#include <rw/locale.h>
main()
{
RWLocale::global(new RWLocaleSnapshot(""));
// Print a number using the global locale: