rwlogo
HydraExpress 4.7

HydraExpress C++ API Reference Guide

Product Documentation:
   Documentation Home

List of all members | Public Member Functions
rwsf::LocaleSnapshot Class Reference

Creates a snapshot of a locale by querying the program's environment to determine the formatting conventions in effect at the moment of instantiation. More...

#include <rwsf/core/LocaleSnapshot.h>

Inheritance diagram for rwsf::LocaleSnapshot:
rwsf::Locale

Public Member Functions

 LocaleSnapshot (const char *localeName=0)
 
virtual const std::string & currency_symbol () const
 
virtual const std::string & decimal_point () const
 
virtual char frac_digits () const
  More...
 
virtual const std::string & grouping () const
 
virtual const std::string & int_curr_symbol () const
 
virtual char int_frac_digits () const
  More...
 
virtual const std::string & locale_name () const
 
virtual const std::string & mon_decimal_point () const
 
virtual const std::string & mon_grouping () const
 
virtual const std::string & mon_thousands_sep () const
 
virtual char n_cs_precedes () const
  More...
 
virtual char n_sep_by_space () const
  More...
 
virtual char n_sign_posn () const
  More...
 
virtual const std::string & negative_sign () const
  More...
 
virtual char p_cs_precedes () const
  More...
 
virtual char p_sep_by_space () const
  More...
 
virtual char p_sign_posn () const
  More...
 
virtual const std::string & positive_sign () const
  More...
 
virtual const std::string & thousands_sep () const
 
- Public Member Functions inherited from rwsf::Locale
std::string asString (const struct tm *, const char *format, const rwsf::TimeZone &=rwsf::TimeZone::local()) const
 

Additional Inherited Members

- Public Types inherited from rwsf::Locale
enum  CurrSymbol { NONE, LOCAL, INTL }
 
- Static Public Member Functions inherited from rwsf::Locale
static const LocaledefaultLocale ()
 
static const Localeglobal ()
 
static const Localeglobal (const Locale *loc)
 
static void releaseCache ()
 

Detailed Description

The class rwsf::LocaleSnapshot implements the rwsf::Locale interface using Standard C Library facilities. To use it, the program creates an rwsf::LocaleSnapshot 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 determine the formatting conventions in effect at the moment of instantiation. When done, the locale can then be switched and another instance of rwsf::LocaleSnapshot created.

By creating multiple instances of rwsf::LocaleSnapshot, 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
rwsf::LocaleSnapshot does not encapsulate character set, collation, or message information.

Class rwsf::LocaleSnapshot 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 rwsf::Locale interface that operate on objects of type rwsf::LocaleSnapshot, see the rwsf::Locale class description.

For more information on using locales, see the chapter on internationalization in the Web Service Development Guide.

Constructor & Destructor Documentation

rwsf::LocaleSnapshot::LocaleSnapshot ( const char *  localeName = 0)

Constructs an rwsf::Locale object by extracting formats from the global locale environment. It uses the Standard C Library function 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).

Member Function Documentation

virtual const std::string& rwsf::LocaleSnapshot::currency_symbol ( ) const
virtual

Returns a string to use as the currency symbol for this locale.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::decimal_point ( ) const
virtual

Returns a string to use as the numerical decimal separator.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::frac_digits ( ) const
virtual

Returns the number of local fractional digits.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::grouping ( ) const
virtual

Returns a string identifying the number of digits to be included in a numerical group. A group is simply the digits between adjacent thousands 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 0, the previous element is used repeatedly for the remainder of the digits.
  • If the value is equal to CHAR_MAX, no further grouping is to be performed.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::int_curr_symbol ( ) const
virtual

Returns a string to use as the international currency symbol.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::int_frac_digits ( ) const
virtual

Returns the number of international fractional digits.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::locale_name ( ) const
virtual

Returns the name of the encapsulated std::locale.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::mon_decimal_point ( ) const
virtual

Returns a string to use as the monetary decimal separator.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::mon_grouping ( ) const
virtual

Returns a string identifying the number of digits to be included in a numerical group. A group is simply the digits between adjacent thousands 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 0, the previous element is used repeatedly for the remainder of the digits.
  • If the value is equal to CHAR_MAX, no further grouping is to be performed.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::mon_thousands_sep ( ) const
virtual

Returns a string to use as the monetary thousands separator.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::n_cs_precedes ( ) const
virtual

Returns 1 if the return from currency_symbol() precedes a negative value, or 0 if it succeeds a negative value.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::n_sep_by_space ( ) const
virtual

Returns 1 if the return from currency_symbol() must be separated by a space from a negative value, or 0 if no space is required.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::n_sign_posn ( ) const
virtual

Returns one of the following values, depending on the local currency system's requirements (for negative quantities):

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::negative_sign ( ) const
virtual

Returns the string to use as the negative sign.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::p_cs_precedes ( ) const
virtual

Returns 1 if the return from currency_symbol() precedes a positive value, or 0 if it succeeds a positive value.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::p_sep_by_space ( ) const
virtual

Returns 1 if the return from currency_symbol() must be separated by a space from a positive value, or 0 if no space is required.

Implements rwsf::Locale.

virtual char rwsf::LocaleSnapshot::p_sign_posn ( ) const
virtual

Returns one of the following values, depending on the local currency system's requirements (for positive quantities):

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::positive_sign ( ) const
virtual

Returns the string to use as the positive sign.

Implements rwsf::Locale.

virtual const std::string& rwsf::LocaleSnapshot::thousands_sep ( ) const
virtual

Returns a string to use as the numerical thousands separator.

Implements rwsf::Locale.


Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.