Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide


Module:  Essential Tools Module   Group:  Internationalization

Does not inherit

Local Index



#include <locale.h>
#include <rw/locale.h>
(Abstract base class)


RWLocale is an abstract base class. It defines an interface that formats the conversion of strings to and from dates and times. It formats dates (including day and month names), times, currency, and numbers (including digit grouping).

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:

The library provides two main implementations of RWLocale. These subclasses each allow more than one locale to be active at a time, and they also support conversion from strings to other types. They include:




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;
asString(const struct tm* tmbuf,const char* format, 
         const RWZone& zone) const;
const RWLocale*
imbue(ios& stream) const;
virtual const RWCString& 
locale_name() 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;
virtual RWBoolean 
stringToNum (const RWCString&, unsigned long*) const = 0;

NOTE -- If you are using the C locale, you must omit commas as thousands separators. Because the default locale is likely to be C for many English-speaking programmers, numbers with commas separating the thousands may be rejected. This is true even in a locale where English is the dominant language.
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

const RWLocale*
static const RWLocale*
global(const RWLocale* loc);
static const RWLocale&
static const RWLocale*
imbue(std::ios& s);
static const RWLocale&
static const RWLocale*
unimbue(std::ios& s);

Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks 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.