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

  1. #ifndef __MESSAGES_CC
  2. #define __MESSAGES_CC
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. /***************************************************************************
  5.  *
  6.  * messages.cc - Definitions for the Standard Library messaging facet
  7.  *
  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 _RWSTD_NO_NAMESPACE
  34. namespace std {
  35. #endif
  36.  
  37. // ---------------------------------------
  38. // Facet messages<charT> member templates.
  39. // ---------------------------------------
  40.  
  41. template <class charT>
  42. locale::id messages<charT>::id;
  43.  
  44. template <class charT>
  45. messages<charT>::messages (size_t refs):
  46.     locale::facet(refs,locale::messages), __RWSTD::messages_impl("C")
  47. { }
  48.  
  49. template <class charT>
  50. messages<charT>::messages (size_t refs,string name):
  51.     locale::facet(refs,locale::messages), __RWSTD::messages_impl(name)
  52. { }
  53.  
  54. template <class charT>
  55. messages<charT>::~messages() { }
  56.  
  57. template <class charT>
  58. messages_base::catalog
  59. messages<charT>::do_open (const string &cat_name,const locale &loc) const
  60. {
  61.   return open_cat_(cat_name,loc);
  62. }
  63.  
  64. template <class charT>
  65. _TYPENAME messages<charT>::string_type
  66. messages<charT>::do_get (messages_base::catalog cat,
  67.     int set,int msgid,const string_type &dflt) const
  68. {
  69.   char *text=get_mess_(cat,set,msgid);
  70.  
  71.   // The following is wrong -- it should be using codecvt instead of
  72.   // ctype.widen, but this requires an effective codecvt implementation ...
  73.  
  74.   if (text) {
  75.   const _RW_STD::ctype<charT>& ct =
  76. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  77.     _RW_STD::use_facet<_RW_STD::ctype<charT> >(get_loc_(cat));
  78. #else
  79.     _RW_STD::use_facet(get_loc_(cat), (_RW_STD::ctype<charT>*)0);
  80. #endif
  81.  
  82. #ifndef _RWSTD_STRICT_ANSI
  83.     return ct.widen(string(text));
  84. #else
  85.     charT* __theText = new charT[strlen(text)];
  86.     ct.widen(text, text+strlen(text), __theText);
  87.     return string_type(__theText);
  88. #endif
  89.  
  90.   }
  91.   return dflt;
  92. }
  93.  
  94. template <class charT>
  95. void messages<charT>::do_close (messages_base::catalog cat) const
  96. {
  97.   close_cat_(cat);
  98. }
  99. // ----------------------------------------------------------
  100. // Messages by-name member templates: messages_byname<charT>.
  101. // ----------------------------------------------------------
  102.  
  103. template <class charT>
  104. messages_byname<charT>::messages_byname (const char *name, size_t refs):
  105.     messages<charT>(refs,__RWSTD::messages_impl::get_loc_name_(name))
  106. { }
  107.  
  108. #ifndef _RWSTD_NO_NAMESPACE
  109. } // namespace std
  110. #endif
  111.  
  112. #pragma option pop
  113. #endif /* __MESSAGES_CC */
  114.