messages_members.cc revision 102782
1255852Sdteske// std::messages implementation details, GNU version -*- C++ -*-
2255852Sdteske
3255852Sdteske// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4255852Sdteske//
5255852Sdteske// This file is part of the GNU ISO C++ Library.  This library is free
6255852Sdteske// software; you can redistribute it and/or modify it under the
7255852Sdteske// terms of the GNU General Public License as published by the
8255852Sdteske// Free Software Foundation; either version 2, or (at your option)
9255852Sdteske// any later version.
10255852Sdteske
11255852Sdteske// This library is distributed in the hope that it will be useful,
12255852Sdteske// but WITHOUT ANY WARRANTY; without even the implied warranty of
13255852Sdteske// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14255852Sdteske// GNU General Public License for more details.
15255852Sdteske
16255852Sdteske// You should have received a copy of the GNU General Public License along
17255852Sdteske// with this library; see the file COPYING.  If not, write to the Free
18255852Sdteske// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19255852Sdteske// USA.
20255852Sdteske
21255852Sdteske// As a special exception, you may use this file as part of a free software
22255852Sdteske// library without restriction.  Specifically, if other files instantiate
23255852Sdteske// templates or use macros or inline functions from this file, or you compile
24255852Sdteske// this file and link it with other files to produce an executable, this
25255852Sdteske// file does not by itself cause the resulting executable to be covered by
26255852Sdteske// the GNU General Public License.  This exception does not however
27255852Sdteske// invalidate any other reasons why the executable file might be covered by
28255852Sdteske// the GNU General Public License.
29255852Sdteske
30255852Sdteske//
31255852Sdteske// ISO C++ 14882: 22.2.7.1.2  messages virtual functions
32255852Sdteske//
33255852Sdteske
34255852Sdteske// Written by Benjamin Kosnik <bkoz@redhat.com>
35255852Sdteske
36255852Sdteske#include <locale>
37255852Sdteske
38255852Sdteskenamespace std
39255852Sdteske{
40255852Sdteske  // Specializations.
41255852Sdteske  template<>
42255852Sdteske    string
43255852Sdteske    messages<char>::do_get(catalog, int, int, const string& __dfault) const
44255852Sdteske    {
45255852Sdteske#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
46255852Sdteske      __c_locale __old = __uselocale(_M_c_locale_messages);
47255852Sdteske      const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
48255852Sdteske      __uselocale(__old);
49255852Sdteske      return string(__msg);
50255852Sdteske#else
51255852Sdteske      char* __old = strdup(setlocale(LC_ALL, NULL));
52255852Sdteske      setlocale(LC_ALL, _M_name_messages);
53255852Sdteske      const char* __msg = gettext(__dfault.c_str());
54255852Sdteske      setlocale(LC_ALL, __old);
55255852Sdteske      free(__old);
56255852Sdteske      return string(__msg);
57255852Sdteske#endif
58255852Sdteske    }
59255852Sdteske}
60255852Sdteske