home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / Rw / rwlocale.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  21.9 KB  |  620 lines

  1. #ifndef __RWLOCALE_H
  2. #define __RWLOCALE_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. /***************************************************************************
  6.  *
  7.  * locale - Declarations for the Standard Library locale classes
  8.  *
  9.  ***************************************************************************
  10.  *
  11.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  12.  *
  13.  * This computer software is owned by Rogue Wave Software, Inc. and is
  14.  * protected by U.S. copyright laws and other laws and by international
  15.  * treaties.  This computer software is furnished by Rogue Wave Software,
  16.  * Inc. pursuant to a written license agreement and may be used, copied,
  17.  * transmitted, and stored only in accordance with the terms of such
  18.  * license and with the inclusion of the above copyright notice.  This
  19.  * computer software or any other copies thereof may not be provided or
  20.  * otherwise made available to any other person.
  21.  *
  22.  * U.S. Government Restricted Rights.  This computer software is provided
  23.  * with Restricted Rights.  Use, duplication, or disclosure by the
  24.  * Government is subject to restrictions as set forth in subparagraph (c)
  25.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  26.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  27.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  28.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  29.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  30.  *
  31.  **************************************************************************/
  32.  
  33. #ifndef __STD_RWLOCALE__
  34. #define __STD_RWLOCALE__ 1
  35.  
  36. #include <rw/rwstderr.h>
  37.  
  38. #ifndef __STD_RWCOMPILER_H__
  39. #include <stdcomp.h>
  40. #endif
  41.  
  42. #ifndef __STD_STRING__
  43. #include <string>
  44. #endif
  45.  
  46. #ifndef __STD_IOSFWD__
  47. #include <iosfwd>
  48. #endif
  49.  
  50. #ifndef _RWSTD_NO_NEW_HEADER
  51. #include <ctime>
  52. #else
  53. #include <time.h>
  54. #endif
  55.  
  56. #ifndef _RWSTD_NO_BAD_CAST
  57. #include <typeinfo>
  58. #endif
  59.  
  60. // In case these are (wrongly!) defined as macros in <cctype>.
  61.  
  62. #undef isspace
  63. #undef isprint
  64. #undef iscntrl
  65. #undef isupper
  66. #undef islower
  67. #undef isalpha
  68. #undef isdigit
  69. #undef ispunct
  70. #undef isxdigit
  71. #undef isalnum
  72. #undef isgraph
  73. #undef toupper
  74. #undef tolower
  75.  
  76. #ifndef _RWSTD_NO_NAMESPACE
  77. namespace __rwstd {
  78. #endif
  79.  
  80. #ifdef _RWSTD_LOCALIZED_ERRORS
  81.   extern const unsigned int _RWSTDExport __rw_LocaleNotPresent;
  82. #else
  83.   extern const char _RWSTDExportFunc(*) __rw_LocaleNotPresent;
  84. #endif
  85.  
  86. #ifndef _RWSTD_NO_NAMESPACE
  87. } namespace std {
  88. #endif
  89.  
  90. // Forward declarations of functions and classes specified by the locale clause
  91. // of the C++ Standard Library working paper.
  92.  
  93. class _RWSTDExport locale;
  94.  
  95. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  96.   template <class Facet> inline const Facet& use_facet (const locale&);
  97.   template <class Facet>
  98.     inline bool has_facet (const locale&) _RWSTD_THROW_SPEC_NULL;
  99. #else
  100.   template <class Facet>
  101.     _RWSTD_TRICKY_INLINE const Facet& use_facet (const locale&, Facet*);
  102.   template <class Facet>
  103.     inline bool has_facet (const locale&, Facet*) _RWSTD_THROW_SPEC_NULL;
  104. #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  105.  
  106. template <class charT> inline bool isspace  (charT c, const locale&);
  107. template <class charT> inline bool isprint  (charT c, const locale&);
  108. template <class charT> inline bool iscntrl  (charT c, const locale&);
  109. template <class charT> inline bool isupper  (charT c, const locale&);
  110. template <class charT> inline bool islower  (charT c, const locale&);
  111. template <class charT> inline bool isalpha  (charT c, const locale&);
  112. template <class charT> inline bool isdigit  (charT c, const locale&);
  113. template <class charT> inline bool ispunct  (charT c, const locale&);
  114. template <class charT> inline bool isxdigit (charT c, const locale&);
  115. template <class charT> inline bool isalnum  (charT c, const locale&);
  116. template <class charT> inline bool isgraph  (charT c, const locale&);
  117.  
  118. template <class charT> inline charT toupper (charT c, const locale&);
  119. template <class charT> inline charT tolower (charT c, const locale&);
  120.  
  121. class ctype_base;
  122. template <class charT> class ctype;
  123. _RWSTD_TEMPLATE class _RWSTDExport ctype<char>;
  124. template <class charT> class ctype_byname;
  125. _RWSTD_TEMPLATE class _RWSTDExport ctype_byname<char>;
  126. class codecvt_base;
  127. template  <class internT, class externT, class stateT> class codecvt;
  128. _RWSTD_TEMPLATE class _RWSTDExport codecvt<char,char,mbstate_t>;     // (imp)
  129.  
  130. #ifndef _RWSTD_NO_WIDE_CHAR
  131. _RWSTD_TEMPLATE class _RWSTDExport ctype<wchar_t>;               // (imp)
  132. _RWSTD_TEMPLATE class _RWSTDExport ctype_byname<wchar_t>;
  133. _RWSTD_TEMPLATE class _RWSTDExport codecvt<wchar_t,char,mbstate_t>;  // (imp)
  134. #endif // _RWSTD_NO_WIDE_CHAR
  135.  
  136. template <class internT, class externT, class stateT> class codecvt_byname;
  137.  
  138. template <class charT,
  139.     class InputIterator _RWSTD_COMPLEX_DEFAULT(istreambuf_iterator<charT>)>
  140.     class num_get;
  141. template <class charT,
  142.     class OutputIterator _RWSTD_COMPLEX_DEFAULT(ostreambuf_iterator<charT>)>
  143.     class num_put;
  144. template <class charT> class numpunct;
  145. template <class charT> class numpunct_byname;
  146.  
  147. template <class charT> class collate;
  148. template <class charT> class collate_byname;
  149.  
  150. class time_base;
  151. template <class charT,
  152.     class InputIterator _RWSTD_COMPLEX_DEFAULT(istreambuf_iterator<charT>)>
  153.     class time_get;
  154. template <class charT,
  155.     class InputIterator _RWSTD_COMPLEX_DEFAULT(istreambuf_iterator<charT>)>
  156.     class time_get_byname;
  157. template <class charT,
  158.     class OutputIterator _RWSTD_COMPLEX_DEFAULT(ostreambuf_iterator<charT>)>
  159.     class time_put;
  160. template <class charT,
  161.     class OutputIterator _RWSTD_COMPLEX_DEFAULT(ostreambuf_iterator<charT>)>
  162.     class time_put_byname;
  163.  
  164. class _RWSTDExport money_base;
  165. template <class charT,
  166.     class InputIterator _RWSTD_COMPLEX_DEFAULT(istreambuf_iterator<charT>)>
  167.     class money_get;
  168. template <class charT,
  169.     class OutputIterator _RWSTD_COMPLEX_DEFAULT(ostreambuf_iterator<charT>)>
  170.     class money_put;
  171. template <class charT, bool Intl _RWSTD_SIMPLE_DEFAULT(false)>
  172.     class moneypunct;
  173. template <class charT, bool Intl _RWSTD_SIMPLE_DEFAULT(false)>
  174.     class moneypunct_byname;
  175.  
  176. class messages_base;
  177. template <class charT> class messages;
  178. template <class charT> class messages_byname;
  179.  
  180. // Instantiations that go in the library:
  181.  
  182. #ifdef __TURBOC__
  183.  
  184. typedef istreambuf_iterator<char,char_traits<char> > __isit;
  185. typedef ostreambuf_iterator<char,char_traits<char> > __osit;
  186.  
  187. template class _RWSTDExport codecvt_byname<char,char,mbstate_t>;
  188. template class _RWSTDExport num_get<char,__isit>;
  189. template class _RWSTDExport num_put<char,__osit>;
  190. template class _RWSTDExport numpunct<char>;
  191. template class _RWSTDExport numpunct_byname<char>;
  192. template class _RWSTDExport collate<char>;
  193. template class _RWSTDExport collate_byname<char>;
  194. template class _RWSTDExport time_get<char,__isit>;
  195. template class _RWSTDExport time_put<char,__osit>;
  196. template class _RWSTDExport money_get<char,__isit>;
  197. template class _RWSTDExport money_put<char,__osit>;
  198. template class _RWSTDExport moneypunct<char,false>;
  199. template class _RWSTDExport moneypunct<char,true>;
  200. template class _RWSTDExport moneypunct_byname<char,false>;
  201. template class _RWSTDExport moneypunct_byname<char,true>;
  202. template class _RWSTDExport messages<char>;
  203. template class _RWSTDExport messages_byname<char>;
  204.  
  205. #ifndef _RWSTD_NO_WIDE_CHAR
  206.  
  207. typedef istreambuf_iterator<wchar_t,char_traits<wchar_t> > __wisit;
  208. typedef ostreambuf_iterator<wchar_t,char_traits<wchar_t> > __wosit;
  209.  
  210. template class _RWSTDExport codecvt_byname<wchar_t,wchar_t,mbstate_t>;
  211. template class _RWSTDExport num_get<wchar_t,__wisit>;
  212. template class _RWSTDExport num_put<wchar_t,__wosit>;
  213. template class _RWSTDExport numpunct<wchar_t>;
  214. template class _RWSTDExport numpunct_byname<wchar_t>;
  215. template class _RWSTDExport collate<wchar_t>;
  216. template class _RWSTDExport collate_byname<wchar_t>;
  217. template class _RWSTDExport time_get<wchar_t,__wisit>;
  218. template class _RWSTDExport time_put<wchar_t,__wosit>;
  219. template class _RWSTDExport money_get<wchar_t,__wisit>;
  220. template class _RWSTDExport money_put<wchar_t,__wosit>;
  221. template class _RWSTDExport moneypunct<wchar_t,false>;
  222. template class _RWSTDExport moneypunct<wchar_t,true>;
  223. template class _RWSTDExport moneypunct_byname<wchar_t,false>;
  224. template class _RWSTDExport moneypunct_byname<wchar_t,true>;
  225. template class _RWSTDExport messages<wchar_t>;
  226. template class _RWSTDExport messages_byname<wchar_t>;
  227.  
  228. #endif // _RWSTD_NO_WIDE_CHAR
  229.  
  230. #endif // __TURBOC__
  231.  
  232. #ifndef _RWSTD_NO_NAMESPACE
  233. } // namespace std
  234. #endif
  235.  
  236. #ifndef __STD_RW_LOCIMPL__
  237. #include <rw/locimpl>
  238. #endif
  239.  
  240. #ifndef _RWSTD_NO_NAMESPACE
  241. namespace std {
  242. #endif
  243.  
  244. // -------------
  245. // Class locale.
  246. // -------------
  247.  
  248. class _RWSTDExport locale {
  249.  public:
  250.   class facet;
  251.   class id;
  252.  
  253.   friend class facet;
  254.   friend class id;
  255.  
  256.   typedef int category;
  257.  
  258.   // The following constants identify standard categories of facets.  The
  259.   // standard specifies them as const members of type category (i.e. as const
  260.   // ints).  For compilers that can't initialize const members here, we define
  261.   // them as members of an anonymous enum instead.
  262.  
  263.   // Some compilers get confused by the name collision of these constants with
  264.   // the facet templates collate, ctype and messages.  As a work-around, we
  265.   // also define non-standard names of the form __rw_xxx_category for these
  266.   // three categories.  If you have one of the confused compilers (i.e. if
  267.   // _RWSTD_CONFUSED_ENUM_SCOPE is #defined for you), you must use these non-
  268.   // standard category names.
  269.  
  270.   #ifndef _RWSTD_CONFUSED_ENUM_SCOPE
  271.   #define _RWSTD_CATEGORY_NAMES                             \
  272.     collate = 0x0010, ctype = 0x0020, monetary = 0x0040,    \
  273.     numeric = 0x0080, time  = 0x0100, messages = 0x0200,    \
  274.     all     = 0x03f0, none  = 0x0000
  275.   #else
  276.   #define _RWSTD_CATEGORY_NAMES                             \
  277.     monetary = 0x0040, numeric = 0x0080, time  = 0x0100,    \
  278.     all      = 0x03f0, none  = 0x0000
  279.   #endif
  280.  
  281.   #define _RWSTD_IMPLEMENTATION_VALS                                  \
  282.     __rw_collate_category  = 0x0010, __rw_ctype_category    = 0x0020, \
  283.     __rw_messages_category = 0x0200, __rw_Clib_LC_constants = 0x000F, \
  284.     __rw_num_categories    = 6,      __rw_first_category    = 0x0010
  285.  
  286.   #ifndef _RWSTD_NO_STI_SIMPLE
  287.   static const category _RWSTD_CATEGORY_NAMES, _RWSTD_IMPLEMENTATION_VALS;
  288.   #else
  289.   enum { _RWSTD_CATEGORY_NAMES, _RWSTD_IMPLEMENTATION_VALS };
  290.   #endif
  291.  
  292.   #undef _RWSTD_CATEGORY_NAMES
  293.   #undef _RWSTD_IMPLEMENTATION_VALS
  294.  
  295.   // The default constructor creates a copy of the current global locale.
  296.   // This is the locale specified in the most recent call to locale::global().
  297.   // If locale::global() has not been called, it is the classic "C" locale.
  298.  
  299.   inline locale () _RWSTD_THROW_SPEC_NULL;
  300.  
  301.   // The copy constructor (and the assignment operator, below) can be used
  302.   // freely.  Like a string, most of a locale's contents are in a separate,
  303.   // reference-counted implementation object, so copying and assigning locales
  304.   // has little overhead.
  305.  
  306.   inline locale (const locale& other) _RWSTD_THROW_SPEC_NULL;
  307.  
  308.   // The following constructor creates a locale composed of by-name facets and
  309.   // assigns it a name.  The valid arguments are "", "C", and a set of strings
  310.   // defined by the compiler vendor.  These cause the facets of the locale to
  311.   // be obtained, respectively, from the user's preferred locale, from the
  312.   // classic locale, or from the compiler's locale database.  (In many cases,
  313.   // the preferred locale is specified by environment variables such as LANG
  314.   // or LC_ALL.)  If the argument is not recognized, the constructor throws
  315.   // runtime_error.
  316.  
  317.   _EXPLICIT locale (const char* name);
  318.  
  319.   // The following constructor copies its first argument except for the facets
  320.   // in the categories identified by the third argument, which are obtained by
  321.   // name using the second argument.  Can throw runtime_error.
  322.  
  323.   locale (const locale& other, const char* name, category);
  324.  
  325.   // The following templatized constructor is only available if your compiler
  326.   // supports member function templates.  It copies its first argument except
  327.   // the single facet of type Facet, which it gets from the second argument.
  328.  
  329.   #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  330.  
  331.   template <class Facet>
  332.   inline locale (const locale& other,Facet* f);
  333.  
  334.   #else
  335.  
  336.   // If your compiler does not support member function templates, we provide
  337.   // the following work-around to let you accrete facets onto a locale.  This
  338.   // constructor copies its first argument except for the single facet of the
  339.   // type of the second argument, for which it uses the second argument.
  340.   //
  341.   // To determine the type of the second argument, it calls the non-standard
  342.   // virtual method __get_id in the second argument.  If you are creating your
  343.   // own facet types on a compiler that does not support member templates, you
  344.   // must code a __get_id member as follows in each new base class facet (i.e.
  345.   // in each facet class that has its own static member id of type locale::id):
  346.   //
  347.   //    virtual locale::id &__get_id (void) const { return id; }
  348.   //
  349.   // See the __get_id members in the standard facets below for examples.
  350.  
  351.   inline locale (const locale& other, facet* f);
  352.  
  353.   #endif // _RWSTD_NO_MEMBER_TEMPLATES
  354.  
  355.   // The following constructor copies its first argument except for the facets
  356.   // in the categories identified by the third argument, which are obtained
  357.   // from the second argument.
  358.  
  359.   locale (const locale &other, const locale &second, category);
  360.  
  361.   // The destructor is non-virtual.  Other classes are not supposed to be
  362.   // derived from locale.
  363.  
  364.   ~locale ()
  365.   {
  366.     __RWSTD::ref_counted::remove_reference(__imp);
  367.   }
  368.  
  369.   const locale& operator = (const locale& other) _RWSTD_THROW_SPEC_NULL;
  370.  
  371.   // The following member function template is available only if your compiler
  372.   // supports member templates that are templatized on types that don't appear
  373.   // in the argument list.  It returns a copy of this locale (*this) except
  374.   // the single facet of type Facet, which it gets from the other locale.
  375.  
  376.   #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  377.   #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  378.   template <class Facet>
  379.   inline locale combine (const locale& other) const;
  380.   #endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  381.   #endif // _RWSTD_NO_MEMBER_TEMPLATES
  382.  
  383.   // The following returns the locale name, or "*" if the locale is unnamed.
  384.  
  385.   string name () const;
  386.  
  387.   // Two locales are equal if they are the same object, or one is a copy of the
  388.   // other (i.e. they have the same implementation object), or both are named
  389.   // and their names are the same.
  390.  
  391.   bool operator == (const locale& other) const;
  392.   bool operator != (const locale& other) const { return !(*this==other); }
  393.  
  394.   // The following templatized operator () satisfies STL requirements for a
  395.   // comparator predicate template argument for comparing strings according to
  396.   // the collating sequence of the locale.  It lets you use a locale directly
  397.   // as a comparator using syntax like sort(v.begin(),v.end(),loc), where v is
  398.   // a vector of some string type and loc is a locale.  If your compiler does
  399.   // not support member function templates, we provide explicit support for
  400.   // string and (if applicable) wstring.
  401.  
  402.   #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  403.   template <class charT, class Traits, class Allocator>
  404.   bool operator() (const basic_string<charT,Traits,Allocator>& s1,
  405.                    const basic_string<charT,Traits,Allocator>& s2) const;
  406.   #else
  407.   bool operator() (const string &s1,const string &s2) const;
  408.   #ifndef _RWSTD_NO_WIDE_CHAR
  409.   bool operator() (const wstring &s1,const wstring &s2) const;
  410.   #endif
  411.   #endif
  412.  
  413.   // Static members.
  414.  
  415.   static locale global (const locale&);  // Replaces the current global locale
  416.   static const locale &classic ();       // Returns the classic "C" locale
  417.  
  418.   // class facet -- base class for locale feature sets.
  419.  
  420.   // Any class deriving from facet that wants to be perceived as a distinct
  421.   // facet, as opposed to a re-implementation of an existing facet, must
  422.   // declare a static member: static std::locale::id id;
  423.  
  424.   class facet: public __RWSTD::facet_imp {
  425.     friend class __RWSTD::locale_imp;
  426.     friend class locale;
  427.    protected:
  428.     _EXPLICIT facet (size_t refs=0,int cat=0):
  429.         __RWSTD::facet_imp(refs,cat) { }
  430.  
  431.     virtual ~facet() { }
  432.  
  433.     #ifdef _RWSTD_NO_MEMBER_TEMPLATES
  434.     virtual id &__get_id (void) const=0;
  435.     #endif
  436.  
  437.    private:
  438.     facet (const facet&);           // not defined
  439.     void operator = (const facet&); // not defined
  440.   };
  441.  
  442.   // class id -- facet type identifier.
  443.  
  444.   // This is mostly an implementation class.  It is used internally as an index
  445.   // to find facets within a locale.  Each distinct facet (i.e. each T that can
  446.   // be the parameter of a use_facet<T> call) has a unique static member of type
  447.   // locale::id named id.  The class is made public to enable extension of the
  448.   // set of standard facets.  Objects of this type don't need to be constructed
  449.   // or referenced in any other circumstances.
  450.  
  451.   class id: private __RWSTD::locale_id_imp {
  452.     _RWSTD_FRIEND_USE_HAS_FACET
  453.     friend class locale;
  454. #if defined ( _MSC_VER ) || defined (__TURBOC__)
  455.    public:
  456. #endif
  457. #ifdef _HPACC_
  458.     operator size_t () const { return __RWSTD::locale_id_imp::__id_value; }
  459. #else
  460.     operator size_t () const { return __id_value; }
  461. #endif
  462.  
  463.     // The private copy constructor and assignment operator help restrict the
  464.     // class to its intended use.  The copy constructor prevents the compiler
  465.     // from generating a do-nothing default constructor, so we provide one.
  466.     // We omit the constructors on compilers that don't support static template
  467.     // members with constructors.
  468.  
  469. #ifndef _RWSTD_NO_STATIC_DEF3
  470.    public:
  471.     id () { }
  472.    private:
  473.     id (const id&);
  474. #endif
  475.    private:
  476.     void operator = (const id&);
  477.   };
  478.  
  479.  private:
  480.  
  481.   // Implementation.
  482.   friend class __RWSTD::locale_imp;
  483.   _RWSTD_FRIEND_USE_HAS_FACET
  484.  
  485. #if defined ( _MSC_VER ) || defined (__TURBOC__)
  486.  public:
  487. #endif
  488.  
  489.   // The only data member is a pointer to a ref-counted implementation object:
  490.   __RWSTD::locale_imp *__imp;
  491.  
  492.   // Typedef for the implementation-defined call-back functions that must be
  493.   // passed to __make_explicit (below).
  494.   typedef __RWSTD::facet_maker_func __facet_maker_func;
  495.  
  496.   // The following function retrieves an implicit facet from a cache,
  497.   // or creates one if needed (via call to the passed call-back
  498.   // function), and makes it an explicit facet of the locale.
  499.  
  500.   __RWSTD::facet_imp * __make_explicit (const id &facet_id, bool ok_implicit,
  501.        category facet_cat, __facet_maker_func maker) const;
  502.  
  503.   inline __RWSTD::facet_imp *get_facet (size_t) const;
  504.  
  505. #if defined(_MSC_VER) && !defined(__BORLANDC__)
  506.  private:
  507. #endif
  508.  
  509.   void __install (__RWSTD::facet_imp *f, const id& i) const;
  510.  
  511.   static __RWSTD::locale_imp *__the_classic_locale;
  512.   static __RWSTD::locale_imp *__the_native_locale;
  513.   static __RWSTD::locale_imp *__global;
  514.  
  515.   // Construct a locale from an implementation object.
  516.   inline _EXPLICIT locale (__RWSTD::locale_imp *m);
  517.  
  518.  private:
  519.   // We have to say private again in case _RWSTD_FRIEND_USE_HAS_FACET evaluated
  520.   // to public:
  521.  
  522.   // Create initial implementation objects.
  523.   static void init ();
  524. };
  525.  
  526. #undef _RWSTD_FRIEND_USE_HAS_FACET
  527.  
  528. // ----------------------------
  529. // Class locale inline members.
  530. // ----------------------------
  531.  
  532. // Private constructor for use by implementation, constructs a locale from
  533. // a locale_imp implementation object.
  534. inline locale::locale (__RWSTD::locale_imp *m): __imp(m) {
  535.   if (!__global) init();
  536.   __RWSTD::ref_counted::add_reference(__imp);
  537. }
  538.  
  539. // Default constructor, returns a copy of the current global locale.
  540. inline locale::locale () _RWSTD_THROW_SPEC_NULL {
  541.   if (!__global) init(); // This is not throw() ... something has to give.
  542.   __RWSTD::ref_counted::add_reference(__imp=__global);
  543. }
  544.  
  545. // Copy constructor.
  546. inline locale::locale (const locale& other) _RWSTD_THROW_SPEC_NULL {
  547.   __RWSTD::ref_counted::add_reference(__imp=other.__imp);
  548. }
  549.  
  550. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  551.  
  552. // Constructor to accrete or replace a single facet.
  553. template <class Facet>
  554. inline locale::locale (const locale& other, Facet* f)
  555. {
  556.   if (f) {
  557.     __imp=new __RWSTD::locale_imp (*other.__imp,1);
  558.     __install(f,Facet::id);
  559.     __imp->named_=false;
  560.   } else
  561.     __RWSTD::ref_counted::add_reference(__imp=other.__imp);
  562. }
  563.  
  564. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  565.  
  566. template <class Facet>
  567. inline locale locale::combine (const locale& other) const
  568. {
  569.   return locale (*this,&use_facet<Facet>(other));
  570. }
  571.  
  572. #endif /* _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE */
  573.  
  574. #else
  575.  
  576. inline locale::locale (const locale& other, facet* f):
  577.     __imp(new __RWSTD::locale_imp (*other.__imp,1))
  578. {
  579.   __install(f,f->__get_id());
  580.   __imp->named_=false;
  581. }
  582.  
  583. #endif // _RWSTD_NO_MEMBER_TEMPLATES
  584. // Private implementation helper function.
  585. inline __RWSTD::facet_imp* locale::get_facet (size_t i) const {
  586.   return __imp->get_facet(i);
  587. }
  588.  
  589. #ifndef _RWSTD_NO_NAMESPACE
  590. } namespace __rwstd {
  591. #endif
  592. // -------------------------------------------------------
  593. // Implementation function template -- create_named_facet.
  594. // -------------------------------------------------------
  595. // 
  596. // The default for facets with no derived byname version is to create a facet
  597. // with classic ("C") behavior, ignoring the passed name.
  598.  
  599. template <class Facet>
  600. inline Facet* create_named_facet (Facet*,const char* /* name */ ,size_t refs)
  601. {
  602.   return new Facet(refs);
  603. }
  604.  
  605. #ifndef _RWSTD_NO_NAMESPACE
  606. } // namespace __rwstd
  607. #endif
  608.  
  609. // Get declarations for vendor-defined extensions, such as 
  610. // declarations of the facets of the native ("") locale.
  611. #include <rw/vendor>
  612.  
  613. #ifdef _RWSTD_NO_TEMPLATE_REPOSITORY
  614. #include <rw/rwlocale.cc>
  615. #endif
  616.  
  617. #endif // __STD_RWLOCALE__
  618. #pragma option pop
  619. #endif /* __RWLOCALE_H */
  620.