messages_members.cc revision 97403
164562Sgshapiro// std::messages implementation details, GNU version -*- C++ -*- 2203004Sgshapiro 364562Sgshapiro// Copyright (C) 2001, 2002 Free Software Foundation, Inc. 464562Sgshapiro// 564562Sgshapiro// This file is part of the GNU ISO C++ Library. This library is free 664562Sgshapiro// software; you can redistribute it and/or modify it under the 764562Sgshapiro// terms of the GNU General Public License as published by the 864562Sgshapiro// Free Software Foundation; either version 2, or (at your option) 964562Sgshapiro// any later version. 1064562Sgshapiro 1190792Sgshapiro// This library is distributed in the hope that it will be useful, 1264562Sgshapiro// but WITHOUT ANY WARRANTY; without even the implied warranty of 13203004Sgshapiro// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1464562Sgshapiro// GNU General Public License for more details. 1590792Sgshapiro 16168515Sgshapiro// You should have received a copy of the GNU General Public License along 1790792Sgshapiro// with this library; see the file COPYING. If not, write to the Free 1890792Sgshapiro// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 1990792Sgshapiro// USA. 2064562Sgshapiro 21157001Sgshapiro// As a special exception, you may use this file as part of a free software 22132943Sgshapiro// library without restriction. Specifically, if other files instantiate 2364562Sgshapiro// templates or use macros or inline functions from this file, or you compile 2464562Sgshapiro// this file and link it with other files to produce an executable, this 2564562Sgshapiro// file does not by itself cause the resulting executable to be covered by 26168515Sgshapiro// the GNU General Public License. This exception does not however 27132943Sgshapiro// invalidate any other reasons why the executable file might be covered by 28168515Sgshapiro// the GNU General Public License. 2964562Sgshapiro 3064562Sgshapiro// 3190792Sgshapiro// ISO C++ 14882: 22.2.7.1.2 messages virtual functions 3264562Sgshapiro// 33141858Sgshapiro 3490792Sgshapiro// Written by Benjamin Kosnik <bkoz@redhat.com> 3564562Sgshapiro 3664562Sgshapiro#include <locale> 37168515Sgshapiro 38168515Sgshapironamespace std 39168515Sgshapiro{ 40168515Sgshapiro // Specializations. 41168515Sgshapiro template<> 42168515Sgshapiro string 43168515Sgshapiro messages<char>::do_get(catalog, int, int, const string& __dfault) const 44168515Sgshapiro { 45168515Sgshapiro#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) 46168515Sgshapiro __c_locale __old = __uselocale(_M_c_locale_messages); 47168515Sgshapiro const char* __msg = const_cast<const char*>(gettext(__dfault.c_str())); 48168515Sgshapiro __uselocale(__old); 49168515Sgshapiro return string(__msg); 50168515Sgshapiro#else 51168515Sgshapiro const char* __old = setlocale(LC_ALL, _M_name_messages); 52168515Sgshapiro const char* __msg = gettext(__dfault.c_str()); 53168515Sgshapiro setlocale(LC_ALL, __old); 54173340Sgshapiro return string(__msg); 55173340Sgshapiro#endif 56168515Sgshapiro } 57168515Sgshapiro} 58168515Sgshapiro