/***************************************************************************
 *
 * byname - Declarations for the Standard Library byname classes
 *
 * $Id: byname,v 1.33 1996/10/02 01:48:00 smithey Exp $
 *
 ***************************************************************************
 *
 * (c) Copyright 1994-1996 Rogue Wave Software, Inc.
 * ALL RIGHTS RESERVED
 *
 * The software and information contained herein are proprietary to, and
 * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
 * intends to preserve as trade secrets such software and information.
 * This software is furnished pursuant to a written license agreement and
 * may be used, copied, transmitted, and stored only in accordance with
 * the terms of such license and with the inclusion of the above copyright
 * notice.  This software and information or any other copies thereof may
 * not be provided or otherwise made available to any other person.
 *
 * Notwithstanding any other lease or license that may pertain to, or
 * accompany the delivery of, this computer software and information, the
 * rights of the Government regarding its use, reproduction and disclosure
 * are as set forth in Section 52.227-19 of the FARS Computer
 * Software-Restricted Rights clause.
 * 
 * Use, duplication, or disclosure by the Government is subject to
 * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
 * Technical Data and Computer Software clause at DFARS 252.227-7013.
 * Contractor/Manufacturer is Rogue Wave Software, Inc.,
 * P.O. Box 2328, Corvallis, Oregon 97339.
 *
 * This computer software and information is distributed with "restricted
 * rights."  Use, duplication or disclosure is subject to restrictions as
 * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
 * Computer Software-Restricted Rights (April 1985)."  If the Clause at
 * 18-52.227-74 "Rights in Data General" is specified in the contract,
 * then the "Alternate III" clause applies.
 *
 **************************************************************************/

#ifndef __STD_RW_BYNAME__
#define __STD_RW_BYNAME__
//
//
//  Copyright Digital Equipment Corporation 1996. All rights reserved.
//
//  Restricted Rights: Use, duplication, or disclosure by the U.S.
//  Government is subject to restrictions as set forth in subparagraph
//  (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR
//  52.227-14 Alt. III, as applicable.
//
//  This software is proprietary to and embodies the confidential
//  technology of Digital Equipment Corporation. Possession, use, or
//  copying of this software and media is authorized only pursuant to a
//  valid written license from Digital or an authorized sublicensor.
//
//

#include <compnent.hxx>
#ifndef __USE_STD_IOSTREAM
#error "cannot include byname -- define __USE_STD_IOSTREAM to override default"
#else

#if defined(__DECCXX)
#   ifdef __PRAGMA_ENVIRONMENT
#      pragma __environment __save
#      pragma __environment __header_defaults
#   endif
#endif
       
#ifndef _RWSTD_NO_NAMESPACE
namespace std {
#endif

#if defined(__DECCXX) && !defined(__DECFIXCXXL646)
// -----------------------------------------------
// Locale Manager class used by all byname classes
// to load/restore/unload the facet's locale
// -----------------------------------------------

class _LocaleManager {
 private:
  int _category;		// LC_xxx category associated with the facet
  const char* _NewLocaleName;	// external name of facet's locale
  char *_OldLocaleInternalName;	// internal name of current program's C locale
  char *_NewLocaleInternalName; // internal name of facet's locale

 public:
  _EXPLICIT _LocaleManager(int category, const char* LocaleName);
  virtual   ~_LocaleManager();

  virtual int _SetNewLocale();
  virtual int _RestoreOldLocale();
};

#endif

// ----------------------------------------------
// Standard derived facet -- ctype_byname<charT>.
// ----------------------------------------------

// Specialization for char.  Uses the passed name to build an appropriate mask
// table and upper-to-lower translate tables, which it passes to the base class
// class ctype<char> constructor.  The do_xxx virtual member functions are all
// inherited from the base class.

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExport ctype_byname<char> : public ctype<char> {
 public:
  _EXPLICIT ctype_byname (const char*, size_t refs=0);

 protected:
  virtual ~ctype_byname ();

 private:
  // Constructor helper function:
  static const mask *get_mask_table (const char*);
};


// -------------------------------------------------------
// Standard facet specialization -- ctype_byname<wchar_t>.
// -------------------------------------------------------

#ifndef _RWSTD_NO_WIDE_CHAR

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExport ctype_byname<wchar_t> : public ctype<wchar_t> {
 public:
  _EXPLICIT ctype_byname (const char*, size_t refs=0);

 protected:
  virtual ~ctype_byname();


#if defined(__DECCXX) && !defined(__DECFIXCXXL646)
  virtual bool do_is (mask m, wchar_t c) const;
  virtual const wchar_t* do_is (const wchar_t*, const wchar_t*, mask*) const;
  virtual const wchar_t* do_scan_is (mask,const wchar_t*,const wchar_t*) const;
  virtual const wchar_t* do_scan_not (mask,const wchar_t*,const wchar_t*) const;
  virtual wchar_t        do_toupper (wchar_t) const;
  virtual const wchar_t* do_toupper (wchar_t* low, const wchar_t* high) const;
  virtual wchar_t        do_tolower (wchar_t) const;
  virtual const wchar_t* do_tolower (wchar_t* low, const wchar_t* high) const;
// Virtual member functions inherited from ctype<wchar_t>:
// virtual wchar_t        do_widen (char) const;
// virtual const char*    do_widen (const char*, const char*, wchar_t*) const;
// virtual char           do_narrow (wchar_t, char dfault) const;
// virtual const wchar_t* do_narrow (const wchar_t* lo, const wchar_t* hi,
//                                   char dfault, char* dest) const;

 private:
  _LocaleManager* _LocaleManagerPtr;
  static mask mask_of (wchar_t);

#else
// Virtual member functions inherited from ctype<wchar_t>:
// virtual bool do_is (mask m, wchar_t c) const;
// virtual const wchar_t* do_is (const wchar_t*, const wchar_t*, mask*) const;
// virtual const wchar_t* do_scan_is (mask,const wchar_t*,const wchar_t*) const;
// virtual const wchar_t* do_scan_not (mask,const wchar_t*,const wchar_t*) const;
// virtual wchar_t        do_toupper (wchar_t) const;
// virtual const wchar_t* do_toupper (wchar_t* low, const wchar_t* high) const;
// virtual wchar_t        do_tolower (wchar_t) const;
// virtual const wchar_t* do_tolower (wchar_t* low, const wchar_t* high) const;
//
// virtual wchar_t        do_widen (char) const;
// virtual const char*    do_widen (const char*, const char*, wchar_t*) const;
// virtual char           do_narrow (wchar_t, char dfault) const;
// virtual const wchar_t* do_narrow (const wchar_t* lo, const wchar_t* hi,
//                                   char dfault, char* dest) const;
#endif
};

#endif // _RWSTD_NO_WIDE_CHAR

// ----------------------------------------------
// Standard derived facet -- ctype_byname<charT>.
// ----------------------------------------------

template <class charT>
class _RWSTDExport ctype_byname: public ctype<charT> {
 public:
  _EXPLICIT ctype_byname (const char*, size_t refs=0):
      ctype<charT>(refs) { }

 protected:
  virtual ~ctype_byname() { }

// Virtual member functions inherited from ctype<charT>:
// virtual bool do_is (mask m, charT c) const;
// virtual const charT* do_is (const charT*, const charT*, mask* vec) const;
// virtual const charT* do_scan_is (mask m, const charT*, const charT*) const;
// virtual const charT* do_scan_not (mask m, const charT*, const charT*) const;
// virtual charT        do_toupper (charT) const;
// virtual const charT* do_toupper (charT* low, const charT* high) const;
// virtual charT        do_tolower (charT) const;
// virtual const charT* do_tolower (charT* low, const charT* high) const;
//
// virtual charT        do_widen (char) const;
// virtual const char*  do_widen (const char*,const char*, charT* dest) const;
// virtual char         do_narrow (charT, char dfault) const;
// virtual const charT* do_narrow (const charT* lo, const charT* hi,
//                                 char dfault, char* dest) const;
};

// -----------------------------------------------------------------
// Standard derived facet -- codecvt_byname<internT,externT,stateT>.
// -----------------------------------------------------------------

template <class internT, class externT, class stateT>
class _RWSTDExport codecvt_byname: public codecvt<internT,externT,stateT> {
 public:
  
  typedef internT intern_type;
  typedef externT extern_type;
  typedef stateT state_type; 

  _EXPLICIT codecvt_byname (const char*, size_t refs=0);

 protected:
  virtual ~codecvt_byname();

  virtual codecvt_base::result do_out(stateT&, 
          const internT*, const internT*, const internT*&,
          externT*, externT*, externT*&) const;

  virtual codecvt_base::result do_in(stateT&,
    const externT*, const externT*, const externT*&,
          internT*, internT*, internT*&) const;

  virtual bool do_always_noconv () const _RWSTD_THROW_SPEC_NULL;

// Virtual member functions inherited from codecvt<,,>:
// virtual int do_length (const stateT &state, const fromT* from,
//     const fromT* end, size_t max) const;
// virtual int do_max_length() const _RWSTD_THROW_SPEC_NULL;
};

// ------------------------------------------------------------------------
// Standard facet specialization -- codecvt_byname<wchar_t,char,mbstate_t>.
// ------------------------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL646)

#ifndef _RWSTD_NO_WIDE_CHAR
#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExport codecvt_byname<wchar_t,char,mbstate_t> : public codecvt<wchar_t,char,mbstate_t> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  
  _EXPLICIT codecvt_byname (const char*, size_t refs=0);

 protected:
  virtual ~codecvt_byname();

  virtual codecvt_base::result do_out(mbstate_t&, 
          const wchar_t*, const wchar_t*, const wchar_t*&,
          char*, char*, char*&) const;

  virtual codecvt_base::result do_in(mbstate_t&,
          const char*, const char*, const char*&,
          wchar_t*, wchar_t*, wchar_t*&) const;

  virtual bool do_always_noconv () const _RWSTD_THROW_SPEC_NULL;

  virtual int do_encoding() const _RWSTD_THROW_SPEC_NULL;

  virtual int do_length (const mbstate_t&, const char*,
          const char*, size_t) const;

  virtual int do_max_length() const _RWSTD_THROW_SPEC_NULL;
};

#endif // __RWSTD_NO_WIDE_CHAR

#endif

// -------------------------------------------------
// Standard derived facet -- numpunct_byname<charT>.
// -------------------------------------------------

template <class charT>
class _RWSTDExportTemplate numpunct_byname: public numpunct<charT> {
 public:
  _EXPLICIT numpunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~numpunct_byname();

// Virtual member functions inherited from numpunct<charT>:
// virtual char_type   do_decimal_point() const;
// virtual char_type   do_thousands_sep() const;
// virtual string      do_grouping() const;
// virtual string_type do_truename() const;
// virtual string_type do_falsename() const;
};

// -------------------------------------------------------
// Standard facet specialization -- numpunct_byname<char>.
// -------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL646)

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate numpunct_byname<char> : public numpunct<char> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT numpunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~numpunct_byname();

// Virtual member functions inherited from numpunct<charT>:
// virtual char_type   do_decimal_point() const;
// virtual char_type   do_thousands_sep() const;
// virtual string      do_grouping() const;
// virtual string_type do_truename() const;
// virtual string_type do_falsename() const;
};

// ----------------------------------------------------------
// Standard facet specialization -- numpunct_byname<wchar_t>.
// ----------------------------------------------------------

#ifndef _RWSTD_NO_WIDE_CHAR

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate numpunct_byname<wchar_t> : public numpunct<wchar_t> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT numpunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~numpunct_byname();

  virtual char_type   do_decimal_point() const;
  virtual char_type   do_thousands_sep() const;
  virtual string      do_grouping() const;
  virtual string_type do_truename() const;
  virtual string_type do_falsename() const;
};

#endif // __RWSTD_NO_WIDE_CHAR

#endif

// ------------------------------------------------
// Standard derived facet -- collate_byname<charT>.
// ------------------------------------------------

template <class charT>
class _RWSTDExport collate_byname: public collate<charT> {
 public:
  typedef basic_string<charT,char_traits<charT>,
                                allocator<void> > string_type;

  _EXPLICIT collate_byname (const char*, size_t refs=0);

 protected:
  virtual ~collate_byname();

  // Virtual member functions overridden from collate<charT>.
  virtual int do_compare (const charT* low1, const charT* high1,
                          const charT* low2, const charT* high2) const;
  virtual string_type do_transform (const charT* low, const charT* high) const;

#if defined(__DECCXX) && !defined(__DECFIXCXXL646)
  virtual long do_hash (const charT* low, const charT* high) const;
#else
  // The remaining virtual function (do_hash) is inherited from collate<charT>
  // in this implementation.
#endif

 private:
  // Implementation.
  string_type collate_name_;
};

// ------------------------------------------------------
// Standard facet specialization -- collate_byname<char>.
// ------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL646)

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template<>
#endif
class _RWSTDExport collate_byname<char>: public collate<char> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT collate_byname (const char*, size_t refs=0);

 protected:
  virtual ~collate_byname ();

  // Virtual member functions, override functions in collate<char>.
  virtual int do_compare (const char* low1, const char* high1,
                          const char* low2, const char* high2) const;
  virtual string_type do_transform (const char* low, const char* high) const;

#if defined(__DECCXX) && !defined(__DECFIXCXXL663)
  virtual long do_hash(const char* low, const char* high) const;
#else
  long do_hash(const char* low, const char* high) const;
#endif

 private:
  // Implementation.
  string collate_name_;
};

// ---------------------------------------------------------
// Standard facet specialization -- collate_byname<wchar_t>.
// ---------------------------------------------------------

#ifndef _RWSTD_NO_WIDE_CHAR

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template<>
#endif
class _RWSTDExport collate_byname<wchar_t>: public collate<wchar_t> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT collate_byname (const char*, size_t refs=0);

 protected:
  virtual ~collate_byname ();

  // Virtual member functions, override functions in collate<char>.
  virtual int do_compare (const wchar_t* low1, const wchar_t* high1,
                          const wchar_t* low2, const wchar_t* high2) const;
  virtual string_type do_transform (const wchar_t* low, const wchar_t* high) const;

#if defined(__DECCXX) && !defined(__DECFIXCXXL663)
  virtual long do_hash(const wchar_t* low, const wchar_t* high) const;
#else
  long do_hash(const wchar_t* low, const wchar_t* high) const;
#endif

 private:
  // Implementation.
  string collate_name_;
};

#endif // __RWSTD_NO_WIDE_CHAR

#endif

// -------------------------------------------------
// Standard derived facet -- time_get_byname<charT>.
// -------------------------------------------------

template <class charT, class InputIterator>
class _RWSTDExportTemplate time_get_byname: public time_get<charT,InputIterator> {
 public:
  _EXPLICIT time_get_byname (const char*, size_t refs=0);

 protected:
  virtual ~time_get_byname();

// Virtual member functions inherited from time_get<charT,InputIterator>:
// virtual dateorder do_date_order()  const;
// virtual iter_type do_get_time (iter_type i, iter_type e, ios_base&,
//                                ios_base::iostate &err, tm* t) const;
// virtual iter_type do_get_date (iter_type i, iter_type e, ios_base&,
//                                ios_base::iostate &err, tm* t) const;
// virtual iter_type do_get_weekday (iter_type i, iter_type e, ios_base&,
//                                ios_base::iostate &err, tm* t) const;
// virtual iter_type do_get_monthname (iter_type i, iter_type e, ios_base&,
//                                ios_base::iostate &err, tm* t) const;
// virtual iter_type do_get_year (iter_type i, iter_type e, ios_base&,
//                                ios_base::iostate &err, tm* t) const;
};

// -------------------------------------------------
// Standard derived facet -- time_put_byname<charT>.
// -------------------------------------------------

template <class charT, class OutputIterator>
class _RWSTDExportTemplate time_put_byname: public time_put<charT,OutputIterator> {
 public:
  _EXPLICIT time_put_byname (const char*, size_t refs=0);

 protected:
  virtual ~time_put_byname();

// Virtual member functions inherited from time_put<charT,OutputIterator>:
// virtual iter_type do_put (iter_type s, ios_base&, char_type fill,
//                           const tm* t, char format, char modifier) const;
};

// --------------------------------------------------------
// Standard derived facet -- moneypunct_byname<charT,Intl>.
// --------------------------------------------------------

template <class charT, bool Intl>
class _RWSTDExportTemplate moneypunct_byname: public moneypunct<charT,Intl> {
 public:
  _EXPLICIT moneypunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~moneypunct_byname();

// Virtual member functions inherited from moneypunct<charT,Intl>:
// virtual char_type     do_decimal_point () const;
// virtual char_type     do_thousands_sep () const;
// virtual string        do_grouping ()      const;
// virtual string_type   do_curr_symbol ()   const;
// virtual string_type   do_positive_sign () const;
// virtual string_type   do_negative_sign () const;
// virtual int           do_frac_digits ()   const;
// virtual pattern       do_pos_format ()    const;
// virtual pattern       do_neg_format ()    const;
};

// --------------------------------------------------------------
// Standard facet specialization -- moneypunct_byname<char,true>.
// --------------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL646)

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate moneypunct_byname<char,true> : public moneypunct<char,true> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT moneypunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~moneypunct_byname();

// Virtual member functions inherited from moneypunct<charT,Intl>:
// virtual char_type     do_decimal_point () const;
// virtual char_type     do_thousands_sep () const;
// virtual string        do_grouping ()      const;
// virtual string_type   do_curr_symbol ()   const;
// virtual string_type   do_positive_sign () const;
// virtual string_type   do_negative_sign () const;
// virtual int           do_frac_digits ()   const;
// virtual pattern       do_pos_format ()    const;
// virtual pattern       do_neg_format ()    const;
};

// ---------------------------------------------------------------
// Standard facet specialization -- moneypunct_byname<char,false>.
// ---------------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate moneypunct_byname<char,false> : public moneypunct<char,false> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT moneypunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~moneypunct_byname();

// Virtual member functions inherited from moneypunct<charT,Intl>:
// virtual char_type     do_decimal_point () const;
// virtual char_type     do_thousands_sep () const;
// virtual string        do_grouping ()      const;
// virtual string_type   do_curr_symbol ()   const;
// virtual string_type   do_positive_sign () const;
// virtual string_type   do_negative_sign () const;
// virtual int           do_frac_digits ()   const;
// virtual pattern       do_pos_format ()    const;
// virtual pattern       do_neg_format ()    const;
};

// -----------------------------------------------------------------
// Standard facet specialization -- moneypunct_byname<wchar_t,true>.
// -----------------------------------------------------------------

#ifndef _RWSTD_NO_WIDE_CHAR

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate moneypunct_byname<wchar_t,true> : public moneypunct<wchar_t,true> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT moneypunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~moneypunct_byname();


// Virtual member functions inherited from moneypunct<charT,Intl>:
// virtual char_type     do_decimal_point () const;
// virtual char_type     do_thousands_sep () const;
// virtual string        do_grouping ()      const;
// virtual string_type   do_curr_symbol ()   const;
// virtual string_type   do_positive_sign () const;
// virtual string_type   do_negative_sign () const;
// virtual int           do_frac_digits ()   const;
// virtual pattern       do_pos_format ()    const;
// virtual pattern       do_neg_format ()    const;
};


// ------------------------------------------------------------------
// Standard facet specialization -- moneypunct_byname<wchar_t,false>.
// ------------------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate moneypunct_byname<wchar_t,false> : public moneypunct<wchar_t,false> {

 private:
  _LocaleManager* _LocaleManagerPtr;

 public:
  _EXPLICIT moneypunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~moneypunct_byname();

#if defined(__DECCXX) && !defined(__DECFIXCXXL688)
  virtual string_type   do_curr_symbol ()   const;
#endif

// Virtual member functions inherited from moneypunct<charT,Intl>:
// virtual char_type     do_decimal_point () const;
// virtual char_type     do_thousands_sep () const;
// virtual string        do_grouping ()      const;
// virtual string_type   do_curr_symbol ()   const;
// virtual string_type   do_positive_sign () const;
// virtual string_type   do_negative_sign () const;
// virtual int           do_frac_digits ()   const;
// virtual pattern       do_pos_format ()    const;
// virtual pattern       do_neg_format ()    const;
};

#endif // __RWSTD_NO_WIDE_CHAR

#endif 

// -------------------------------------------------
// Standard derived facet -- messages_byname<charT>.
// -------------------------------------------------

template <class charT>
class _RWSTDExportTemplate messages_byname: public messages<charT> {
 public:
  _EXPLICIT messages_byname (const char*, size_t refs=0);

 protected:

#if defined(__DECCXX) && !defined(__DECFIXCXXL664)
  virtual ~messages_byname();
#endif

  // Virtual members inherited from messages<charT>:
  // catalog do_open (const string&, const locale&) const;
  // string_type do_get (catalog, int, int, const string_type&) const;
  // void do_close (catalog) const;
};

#if defined(__DECCXX) && !defined(__DECFIXCXXL646)
// -------------------------------------------------------
// Standard facet specialization -- messages_byname<char>.
// -------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate messages_byname<char> : public messages<char> {
 public:
  _EXPLICIT messages_byname (const char*, size_t refs=0);

 protected:
  virtual ~messages_byname();

  virtual catalog do_open (const string&, const locale&) const;
  virtual string_type do_get (catalog, int, int, const string_type&) const;
  virtual void do_close (catalog) const;
};

// ----------------------------------------------------------
// Standard facet specialization -- messages_byname<wchar_t>.
// ----------------------------------------------------------

#ifndef _RWSTD_NO_WIDE_CHAR

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class _RWSTDExportTemplate messages_byname<wchar_t> : public messages<wchar_t> {
 public:
  _EXPLICIT messages_byname (const char*, size_t refs=0);

 protected:
  virtual ~messages_byname();

  virtual catalog do_open (const string&, const locale&) const;
  virtual string_type do_get (catalog, int, int, const string_type&) const;
  virtual void do_close (catalog) const;

 private:
  wchar_t *msg_;
};

#endif // __RWSTD_NO_WIDE_CHAR

#endif

#ifndef _RWSTD_NO_NAMESPACE
} namespace __rwstd { // Leave std, enter implementation namespace
#endif


#if defined(__DECCXX) && !defined(__DECFIXCXXL646)

// --------------------------------------------------
// Standard derived facet -- timepunct_byname<charT>.
// --------------------------------------------------

template <class charT>
class timepunct_byname: public timepunct<charT> {
 public:
  _EXPLICIT timepunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~timepunct_byname();

// Virtual member functions inherited from timepunct<charT>:
// virtual string_type do_dayname (int day, bool abbreviated) const;
// virtual string_type do_monthname (int month, bool abbreviated) const;
// virtual string_type do_ordinal (int number) const;
};

// --------------------------------------------------------
// Standard facet specialization -- timepunct_byname<char>.
// --------------------------------------------------------

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class timepunct_byname<char> : public timepunct<char> {

 public:
  _EXPLICIT timepunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~timepunct_byname();

  virtual string_type do_dayname (int day, bool abbreviated) const;
  virtual string_type do_monthname (int month, bool abbreviated) const;
// Virtual member functions inherited from timepunct<charT>:
// virtual string_type do_ordinal (int number) const;

 private:
  char* WeekDayName[7][2];
  char* MonthName[12][2];
};

// -----------------------------------------------------------
// Standard facet specialization -- timepunct_byname<wchar_t>.
// -----------------------------------------------------------

#ifndef _RWSTD_NO_WIDE_CHAR

#if defined(__DECCXX) && !defined(__DECFIXCXXL508)
template <>
#endif
class timepunct_byname<wchar_t> : public timepunct<wchar_t> {

 public:
  _EXPLICIT timepunct_byname (const char*, size_t refs=0);

 protected:
  virtual ~timepunct_byname();

  virtual string_type do_dayname (int day, bool abbreviated) const;
  virtual string_type do_monthname (int month, bool abbreviated) const;
// Virtual member functions inherited from timepunct<charT>:
// virtual string_type do_ordinal (int number) const;

 private:
  wchar_t* WeekDayName[7][2];
  wchar_t* MonthName[12][2];
};

#endif // _RWSTD_NO_WIDE_CHAR

#endif

// -------------------------------------------------------
// Implementation function template -- create_named_facet.
// -------------------------------------------------------

inline ctype<char>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (ctype<char>*,const char *name,size_t refs)
{ return new ctype_byname<char>(name,refs); }

#ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC

template <class charT>
inline collate<charT>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (collate<charT>*,const char *name,size_t refs)
{ return new collate_byname<charT>(name,refs); }

template <class charT>
inline numpunct<charT>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (numpunct<charT>*,const char *name,size_t refs)
{ return new numpunct_byname<charT>(name,refs); }

template <class charT,bool Intl>
inline moneypunct<charT,Intl>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (moneypunct<charT,Intl>*,const char *name,size_t refs)
{ return new moneypunct_byname<charT,Intl>(name,refs); }

template <class charT>
inline messages<charT>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (messages<charT>*,const char *name,size_t refs)
{ return new messages_byname<charT>(name,refs); }

#else

inline collate<char>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (collate<char>*,const char *name,size_t refs)
{ return new collate_byname<char>(name,refs); }

inline numpunct<char>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (numpunct<char>*,const char *name,size_t refs)
{ return new numpunct_byname<char>(name,refs); }

inline moneypunct<char,false>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (moneypunct<char,false>*,const char *name,size_t refs)
{ return new moneypunct_byname<char,false>(name,refs); }

inline moneypunct<char,true>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (moneypunct<char,true>*,const char *name,size_t refs)
{ return new moneypunct_byname<char,true>(name,refs); }

inline messages<char>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (messages<char>*,const char *name,size_t refs)
{ return new messages_byname<char>(name,refs); }

#ifndef _RWSTD_NO_WIDE_CHAR

inline collate<wchar_t>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (collate<wchar_t>*,const char *name,size_t refs)
{ return new collate_byname<wchar_t>(name,refs); }

inline numpunct<wchar_t>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (numpunct<wchar_t>*,const char *name,size_t refs)
{ return new numpunct_byname<wchar_t>(name,refs); }

inline moneypunct<wchar_t,false>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (moneypunct<wchar_t,false>*,const char *name,size_t refs)
{ return new moneypunct_byname<wchar_t,false>(name,refs); }

inline moneypunct<wchar_t,true>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (moneypunct<wchar_t,true>*,const char *name,size_t refs)
{ return new moneypunct_byname<wchar_t,true>(name,refs); }

inline messages<wchar_t>* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (messages<wchar_t>*,const char *name,size_t refs)
{ return new messages_byname<wchar_t>(name,refs); }

#endif // _RWSTD_NO_WIDE_CHAR
#endif // _RWSTD_NO_FUNC_PARTIAL_SPEC

// The default for facets with no derived byname version is to create a facet
// with classic ("C") behavior, ignoring the passed name.

template <class Facet>
inline Facet* _RWSTDExport _RWSTD_IMP_DECL(create_named_facet)
    (Facet*,const char*,size_t refs)
{
  return new Facet(refs);
}

#ifndef _RWSTD_NO_NAMESPACE
} // namespace __rwstd
#endif


#ifdef _RWSTD_COMPILE_INSTANTIATE
#include <byname.cc>
#endif

#if defined(__DECCXX)
#   ifdef __PRAGMA_ENVIRONMENT
#      pragma __environment __restore
#   endif
#endif

#endif // __USE_STD_IOSTREAM

#endif // __STD_RW_BYNAME__
