home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _messages_facets.h < prev    next >
C/C++ Source or Header  |  2001-01-26  |  4KB  |  169 lines

  1. /*
  2.  * Copyright (c) 1999
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Copyright (c) 1999 
  6.  * Boris Fomitchev
  7.  *
  8.  * This material is provided "as is", with absolutely no warranty expressed
  9.  * or implied. Any use is at your own risk.
  10.  *
  11.  * Permission to use or copy this software for any purpose is hereby granted 
  12.  * without fee, provided the above notices are retained on all copies.
  13.  * Permission to modify the code and to distribute modified code is granted,
  14.  * provided the above notices are retained, and a notice that the code was
  15.  * modified is included with the above copyright notice.
  16.  *
  17.  */ 
  18.  
  19. // WARNING: This is an internal header file, included by other C++
  20. // standard library headers.  You should not attempt to use this header
  21. // file directly.
  22.  
  23.  
  24. #ifndef _STLP_INTERNAL_MESSAGES_H
  25. #define _STLP_INTERNAL_MESSAGES_H
  26.  
  27. #ifndef _STLP_IOS_BASE_H
  28. # include <stl/_ios_base.h>
  29. #endif
  30.  
  31. # ifndef _STLP_C_LOCALE_H
  32. #  include <stl/c_locale.h>
  33. # endif
  34.  
  35. #ifndef _STLP_STRING_H
  36. # include <stl/_string.h>
  37. #endif
  38.  
  39. _STLP_BEGIN_NAMESPACE
  40.  
  41. // messages facets
  42.  
  43. class messages_base {
  44. public:
  45.   typedef int catalog;
  46. };
  47.  
  48. template <class _CharT> class messages {};
  49.  
  50. class _Messages;
  51.  
  52. _STLP_TEMPLATE_NULL
  53. class _STLP_CLASS_DECLSPEC messages<char> : public locale::facet, public messages_base 
  54. {
  55.   friend class _Locale;
  56. public:
  57.   typedef messages_base::catalog catalog;
  58.   typedef char                   char_type;
  59.   typedef string    string_type;
  60.  
  61.   explicit messages(size_t __refs = 0);
  62.  
  63.   catalog open(const string& __fn, const locale& __loc) const
  64.     { return do_open(__fn, __loc); }
  65.   string_type get(catalog __c, int __set, int __msgid,
  66.           const string_type& __dfault) const
  67.     { return do_get(__c, __set, __msgid, __dfault); }
  68.   inline void close(catalog __c) const
  69.     { do_close(__c); }
  70.  
  71.   _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
  72.  
  73.   messages(_Messages*);
  74.  
  75. protected:
  76.    messages(size_t, _Locale_messages*);
  77.   ~messages();
  78.  
  79.   virtual catalog     do_open(const string& __fn, const locale& __loc) const;
  80.   virtual string_type do_get(catalog __c, int __set, int __msgid,
  81.                              const string_type& __dfault) const;
  82.   virtual void        do_close(catalog __c) const;
  83.  
  84.   void _M_initialize(const char* __name);
  85.  
  86. private:
  87.   _Messages* _M_impl;
  88. };
  89.  
  90. # if !defined (_STLP_NO_WCHAR_T)
  91.  
  92. _STLP_TEMPLATE_NULL
  93. class _STLP_CLASS_DECLSPEC messages<wchar_t> : public locale::facet, public messages_base 
  94. {
  95.   friend class _Locale;
  96. public:
  97.   typedef messages_base::catalog catalog;
  98.   typedef wchar_t                char_type;
  99.   typedef wstring  string_type;
  100.  
  101.   explicit messages(size_t __refs = 0);
  102.   
  103.   inline catalog open(const string& __fn, const locale& __loc) const
  104.     { return do_open(__fn, __loc); }
  105.   inline string_type get(catalog __c, int __set, int __msgid,
  106.                          const string_type& __dfault) const
  107.     { return do_get(__c, __set, __msgid, __dfault); }
  108.   inline void close(catalog __c) const
  109.     { do_close(__c); }
  110.  
  111.   _STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
  112.  
  113.   messages(_Messages*);
  114.  
  115. protected:
  116.  
  117.   messages(size_t, _Locale_messages*);
  118.   ~messages();
  119.  
  120.   virtual catalog     do_open(const string& __fn, const locale& __loc) const;
  121.   virtual string_type do_get(catalog __c, int __set, int __msgid,
  122.                              const string_type& __dfault) const;
  123.   virtual void        do_close(catalog __c) const;
  124.  
  125.   void _M_initialize(const char* __name);
  126.  
  127. private:
  128.   _Messages* _M_impl;
  129. };
  130.  
  131. # endif /* WCHAR_T */
  132.  
  133. template <class _CharT> class messages_byname {};
  134.  
  135. _STLP_TEMPLATE_NULL
  136. class _STLP_CLASS_DECLSPEC messages_byname<char> : public messages<char> {
  137. public:
  138.   typedef messages_base::catalog catalog;
  139.   typedef string     string_type;
  140.  
  141.   explicit messages_byname(const char* __name, size_t __refs = 0);
  142.  
  143. protected:
  144.   ~messages_byname();
  145. };
  146.  
  147. # ifndef _STLP_NO_WCHAR_T
  148. _STLP_TEMPLATE_NULL
  149. class _STLP_CLASS_DECLSPEC messages_byname<wchar_t> : public messages<wchar_t> {
  150. public:
  151.   typedef messages_base::catalog catalog;
  152.   typedef wstring                string_type;
  153.  
  154.   explicit messages_byname(const char* __name, size_t __refs = 0);
  155.  
  156. protected:
  157.   ~messages_byname();
  158. };
  159. # endif /* WCHAR_T */
  160.  
  161. _STLP_END_NAMESPACE
  162.  
  163. #endif /* _STLP_INTERNAL_MESSAGES_H */
  164.  
  165. // Local Variables:
  166. // mode:C++
  167. // End:
  168.  
  169.