RWLocaleSnapshot(3C++)

RWLocaleSnapshot - Rogue Wave library class

As shipped in IRIX 6.5. First release of IRIX 6.5.

Name
     RWLocaleSnapshot - Rogue Wave library class

Synopsis
              #include <locale.h>



              #include <rw/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.

Persistence
     None

Example
     Try this program with the environmental variable LANG set to various
     locales:

              #include <rw/rwdate.h>



              #include <rw/locale.h>
          #include <iostream.h>


              main(){



               RWLocaleSnapshot *userLocale = new RWLocaleSnapshot("");
           RWLocale::global(userLocale);
           // Print a number using the global locale:
           cout << RWLocale::global().asString(1234567.6543) << endl;
           // Now get and print a date:
           cout << "enter a date: " << flush;
           RWDate date;
           cin >> date;
           if (date.isValid())
           cout << date << endl;
           else
           cout << "bad date" << endl;
           delete userLocale;
           return 0;
          }

Enumerations
              enum
          RWDateOrder { DMY, MDY, YDM, YMD };



Public Constructor
              RWLocaleSnapshot(const char* localeName = 0);


     Constructs an RWLocale 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 simply 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).

Public Member Functions
              virtual RWCString
          asString(long) const;
          virtual RWCString
          asString(unsigned long) const;
          virtual RWCString
          asString(double f, int precision = 6,
          RWBoolean showpoint = 0) const;
          virtual RWCString
          asString(struct tm* tmbuf,char format, const RWZone& zone);
                   const;
          virtual RWCString
          asString(struct tm* tmbuf,char* format,
                   const RWZone& zone) const;
          virtual RWCString
          moneyAsString(double value,enum CurrSymbol = LOCAL) const;
          virtual RWBoolean
          stringToNum  (const RWCString&, double* fp) const;
          virtual RWBoolean
          stringToNum  (const RWCString&, long* ip  ) const;
          virtual RWBoolean
          stringToDate (const RWCString&, struct tm*) const;
          virtual RWBoolean
          stringToTime (const RWCString&, struct tm*) const;
          virtual RWBoolean
          stringToMoney(const RWCString&, double*   ,
                        RWLocale::CurrSymbol=LOCAL) const;


     Redefined from class RWLocale.  These virtual functions follow the
     interface described under class RWLocale.  They generally work by
     converting values to and from strings using the rules specified by the
     struct lconv values (see <locale.h>) encapsulated in self.

Public Data Members
              RWCString     decimal_point_;
          RWCString     thousands_sep_;
          RWCString     grouping_;
          RWCString     int_curr_symbol_;
          RWCString     currency_symbol_;
          RWCString     mon_decimal_point_;
          RWCString     mon_thousands_sep_;
          RWCString     mon_grouping_;
          RWCString     positive_sign_;
          RWCString     negative_sign_;
          char          int_frac_digits_;
          char          frac_digits_;
          char          p_cs_precedes_;
          char          p_sep_by_space_;
          char          n_cs_precedes_;
          char          n_sep_by_space_;
          char          p_sign_posn_;
          char          n_sign_posn_;


     These are defined identically as the correspondingly-named members of the
     standard C library type lconv, from <locale.h>.