Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWLocale

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

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:

Two implementations of RWLocale are provided with the library:

Persistence

None

Enumeration

enum 
CurrSymbol { NONE, LOCAL, INTL };

Public Member Functions

virtual RWCString
asString(long) const = 0;
virtual RWCString
asString(unsigned long) const = 0;
virtual RWCString
asString(double f, int precision = 6,
RWBoolean showpoint = 0) const = 0;
virtual RWCString
asString(const struct tm* tmbuf,char format, 
const RWZone& zone=RWZone::local()) const = 0;
RWCString
asString(const struct tm* tmbuf,const char* format, 
         const RWZone& zone) const;
const RWLocale*
imbue(ios& stream) const;
virtual RWCString
moneyAsString(double value,enum CurrSymbol = LOCAL) 
              const = 0;
virtual int
monthIndex(const RWCString&) const = 0;
virtual RWBoolean
stringToNum(const RWCString&, double* fp) const = 0;
virtual RWBoolean
stringToNum(const RWCString&, long* ip) const = 0;

In Table 1 below, examples are given (in parenthesis). For those formats that do not use all members of the struct tm, only those members that are actually used are noted [in brackets].

Table 1. Formatting characters used by strftime()

Format character
Meaning
Example
a
Abbreviated weekday name [from tm::tm_wday]
Sun
A
Full weekday name [from tm::tm_wday]
Sunday
b
Abbreviated month name
Feb
B
Full month name
February
c
Date and time [may use all members]
Feb 29 14:34:56 1984
d
Day of the month
29
H
Hour of the 24-hour day
14
I
Hour of the 12-hour day
02
j
Day of the year, from 001 [from tm::tm_yday]
60
m
Month of the year, from 01
02
M
Minutes after the hour
34
p
AM/PM indicator, if any
AM
S
Seconds after the minute
56
U
Sunday week of the year, from 00 [from tm::tm_yday and tm::tm_wday]
 
w
Day of the week, with 0 for Sunday
0
W
Monday week of the year, from 00 [from tm::tm_yday and tm::tm_wday]
 
x
Date [uses tm::tm_yday in some locales]
Feb 29 1984
X
Time
14:34:56
y
Year of the century, from 00 (deprecated)
84
Y
Year
1984
Z
Time zone name [from tm::tm_isdst]
PST or PDT
virtual RWBoolean
stringToDate(const RWCString&, struct tm*) const = 0;
virtual RWBoolean
stringToMoney(const RWCString&, double*,
              RWLocale::CurrSymbol=LOCAL) const = 0;
virtual RWBoolean
stringToTime(const RWCString&, struct tm*) const = 0;
virtual int
weekdayIndex(const RWCString&) const = 0;

Static Public Member Functions

static const RWLocale&
of(ios&);
static const RWLocale*
global(const RWLocale* loc);
static const RWLocale&
global();
const RWLocale*
defaultLocale();


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.