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

  1. #ifndef __MESSAGES_H
  2. #define __MESSAGES_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. /***************************************************************************
  6.  *
  7.  * messages - Declarations for the Standard Library messaging facet
  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_MESSAGE__
  34. #define __STD_MESSAGE__
  35.  
  36. #ifndef __STD_RWLOCALE__
  37. #include <rw/rwlocale> 
  38. #endif
  39.  
  40. #ifndef _RWSTD_NO_NAMESPACE
  41. namespace std {
  42. #endif
  43.  
  44. struct _RWSTDExport messages_base {
  45.   typedef size_t catalog;
  46. };
  47.  
  48. #ifndef _RWSTD_NO_NAMESPACE
  49. } namespace __rwstd {
  50. #endif
  51.  
  52. // --------------------------------------
  53. // Implementation class -- messages_impl.
  54. // --------------------------------------
  55.  
  56. class _RWSTDExport messages_impl {
  57.   _RW_STD::string loc_name_;                          \
  58.  protected:
  59.   messages_impl (_RW_STD::string name);
  60.  
  61.   _RW_STD::messages_base::catalog open_cat_ (const _RW_STD::string &,const _RW_STD::locale &) const;
  62.   char *get_mess_ (_RW_STD::messages_base::catalog,int,int) const;
  63.   const _RW_STD::locale &get_loc_ (_RW_STD::messages_base::catalog) const;
  64.   void close_cat_ (_RW_STD::messages_base::catalog) const;
  65.   static _RW_STD::string get_loc_name_ (const char*);
  66. };
  67.  
  68. #ifndef _RWSTD_NO_NAMESPACE
  69. } namespace std {
  70. #endif
  71.  
  72. // ----------------------------------------------------
  73. // Standard message retrieval facet -- messages<charT>.
  74. // ----------------------------------------------------
  75.  
  76. template <class charT>
  77. class _RWSTDExportTemplate  messages: public locale::facet, public messages_base,
  78.     public __RWSTD::messages_impl
  79. {
  80.  public:
  81.   typedef charT char_type;
  82.   typedef basic_string<charT,char_traits<charT>,allocator<charT> > string_type;
  83.  
  84.   _EXPLICIT messages (size_t refs=0);
  85.  
  86.   catalog open (const string& fn, const locale& loc) const
  87.     { return do_open(fn,loc); }
  88.   string_type get (catalog c, int set, int msgid, const string_type& df) const
  89.     { return do_get(c,set,msgid,df); }
  90.   void close (catalog c) const { do_close(c); }
  91.  
  92.   static locale::id id;
  93.  
  94.   // Implementation:
  95.   enum { __facet_cat = locale::__rw_messages_category, __ok_implicit = 1 };
  96.  
  97.  protected:
  98.   virtual ~messages();
  99.  
  100.   virtual catalog do_open (const string&, const locale&) const;
  101.   virtual string_type do_get (catalog, int, int, const string_type&) const;
  102.   virtual void do_close (catalog) const;
  103.  
  104.   // Implementation:
  105.   messages (size_t refs,string);
  106.  
  107.  private:
  108.   #ifdef _RWSTD_NO_MEMBER_TEMPLATES
  109.   locale::id &__get_id (void) const { return id; }
  110.   #endif
  111. };
  112.  
  113. // -------------------------------------------------
  114. // Standard derived facet -- messages_byname<charT>.
  115. // -------------------------------------------------
  116.  
  117. template <class charT>
  118. class  messages_byname: public messages<charT> {
  119.  public:
  120.   _EXPLICIT messages_byname (const char*, size_t refs=0);
  121.  
  122.  protected:
  123.  
  124.   // Virtual members inherited from messages<charT>:
  125.   // ~messages_byname();
  126.   // catalog do_open (const string&, const locale&) const;
  127.   // string_type do_get (catalog, int, int, const string_type&) const;
  128.   // void do_close (catalog) const;
  129. };
  130.  
  131. #ifndef _RWSTD_NO_NAMESPACE
  132. } namespace __rwstd {
  133. #endif
  134.  
  135. #ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
  136.  
  137. template <class charT>
  138. inline _RW_STD::messages<charT>* create_named_facet
  139.     (_RW_STD::messages<charT>*,const char *name,size_t refs)
  140. { return new _RW_STD::messages_byname<charT>(name,refs); }
  141.  
  142. #else
  143. _RWSTD_TEMPLATE
  144. inline _RW_STD::messages<char>* create_named_facet
  145.     (_RW_STD::messages<char>*,const char *name,size_t refs)
  146. { return new _RW_STD::messages_byname<char>(name,refs); }
  147.  
  148. #ifndef _RWSTD_NO_WIDE_CHAR
  149. _RWSTD_TEMPLATE
  150. inline _RW_STD::messages<wchar_t>* create_named_facet
  151.     (_RW_STD::messages<wchar_t>*,const char *name,size_t refs)
  152. { return new _RW_STD::messages_byname<wchar_t>(name,refs); }
  153.  
  154. #endif // _RWSTD_NO_WIDE_CHAR
  155. #endif // _RWSTD_NO_FUNC_PARTIAL_SPEC
  156. #ifndef _RWSTD_NO_NAMESPACE
  157. } // namespace __rwstd
  158. #endif
  159.  
  160. #ifdef _RWSTD_COMPILE_INSTANTIATE
  161. #include <rw/messages.cc>
  162. #endif
  163. #endif /* __STD_MESSAGE__ */
  164.  
  165. #pragma option pop
  166. #endif /* __MESSAGES_H */
  167.