OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [config/] [locale/] [gnu/] [messages_members.h] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// std::messages implementation details, GNU version -*- C++ -*-
2
 
3
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
4
// Free Software Foundation, Inc.
5
//
6
// This file is part of the GNU ISO C++ Library.  This library is free
7
// software; you can redistribute it and/or modify it under the
8
// terms of the GNU General Public License as published by the
9
// Free Software Foundation; either version 3, or (at your option)
10
// any later version.
11
 
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
// GNU General Public License for more details.
16
 
17
// Under Section 7 of GPL version 3, you are granted additional
18
// permissions described in the GCC Runtime Library Exception, version
19
// 3.1, as published by the Free Software Foundation.
20
 
21
// You should have received a copy of the GNU General Public License and
22
// a copy of the GCC Runtime Library Exception along with this program;
23
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
// <http://www.gnu.org/licenses/>.
25
 
26
/** @file bits/messages_members.h
27
 *  This is an internal header file, included by other library headers.
28
 *  Do not attempt to use it directly. @headername{locale}
29
 */
30
 
31
//
32
// ISO C++ 14882: 22.2.7.1.2  messages functions
33
//
34
 
35
// Written by Benjamin Kosnik <bkoz@redhat.com>
36
 
37
#include <libintl.h>
38
 
39
namespace std _GLIBCXX_VISIBILITY(default)
40
{
41
_GLIBCXX_BEGIN_NAMESPACE_VERSION
42
 
43
  // Non-virtual member functions.
44
  template<typename _CharT>
45
     messages<_CharT>::messages(size_t __refs)
46
     : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
47
       _M_name_messages(_S_get_c_name())
48
     { }
49
 
50
  template<typename _CharT>
51
     messages<_CharT>::messages(__c_locale __cloc, const char* __s,
52
                                size_t __refs)
53
     : facet(__refs), _M_c_locale_messages(0), _M_name_messages(0)
54
     {
55
       if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
56
         {
57
           const size_t __len = __builtin_strlen(__s) + 1;
58
           char* __tmp = new char[__len];
59
           __builtin_memcpy(__tmp, __s, __len);
60
           _M_name_messages = __tmp;
61
         }
62
       else
63
         _M_name_messages = _S_get_c_name();
64
 
65
       // Last to avoid leaking memory if new throws.
66
       _M_c_locale_messages = _S_clone_c_locale(__cloc);
67
     }
68
 
69
  template<typename _CharT>
70
    typename messages<_CharT>::catalog
71
    messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
72
                           const char* __dir) const
73
    {
74
      bindtextdomain(__s.c_str(), __dir);
75
      return this->do_open(__s, __loc);
76
    }
77
 
78
  // Virtual member functions.
79
  template<typename _CharT>
80
    messages<_CharT>::~messages()
81
    {
82
      if (_M_name_messages != _S_get_c_name())
83
        delete [] _M_name_messages;
84
      _S_destroy_c_locale(_M_c_locale_messages);
85
    }
86
 
87
  template<typename _CharT>
88
    typename messages<_CharT>::catalog
89
    messages<_CharT>::do_open(const basic_string<char>& __s,
90
                              const locale&) const
91
    {
92
      // No error checking is done, assume the catalog exists and can
93
      // be used.
94
      textdomain(__s.c_str());
95
      return 0;
96
    }
97
 
98
  template<typename _CharT>
99
    void
100
    messages<_CharT>::do_close(catalog) const
101
    { }
102
 
103
   // messages_byname
104
   template<typename _CharT>
105
     messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
106
     : messages<_CharT>(__refs)
107
     {
108
       if (this->_M_name_messages != locale::facet::_S_get_c_name())
109
         {
110
           delete [] this->_M_name_messages;
111
           if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0)
112
             {
113
               const size_t __len = __builtin_strlen(__s) + 1;
114
               char* __tmp = new char[__len];
115
               __builtin_memcpy(__tmp, __s, __len);
116
               this->_M_name_messages = __tmp;
117
             }
118
           else
119
             this->_M_name_messages = locale::facet::_S_get_c_name();
120
         }
121
 
122
       if (__builtin_strcmp(__s, "C") != 0
123
           && __builtin_strcmp(__s, "POSIX") != 0)
124
         {
125
           this->_S_destroy_c_locale(this->_M_c_locale_messages);
126
           this->_S_create_c_locale(this->_M_c_locale_messages, __s);
127
         }
128
     }
129
 
130
_GLIBCXX_END_NAMESPACE_VERSION
131
} // namespace

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.