OSDN Git Service

2004-04-16 Paolo Carlini <pcarlini@suse.de>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / config / locale / generic / monetary_members.cc
1 // std::moneypunct implementation details, generic version -*- C++ -*-
2
3 // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING.  If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction.  Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License.  This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 //
31 // ISO C++ 14882: 22.2.6.3.2  moneypunct virtual functions
32 //
33
34 // Written by Benjamin Kosnik <bkoz@redhat.com>
35
36 #include <locale>
37
38 namespace std
39 {
40   // Construct and return valid pattern consisting of some combination of:
41   // space none symbol sign value
42   money_base::pattern
43   money_base::_S_construct_pattern(char, char, char)
44   { return _S_default_pattern; }
45
46   template<> 
47     void
48     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*)
49     {
50       // "C" locale.
51       if (!_M_data)
52         _M_data = new __moneypunct_cache<char, true>;
53
54       _M_data->_M_decimal_point = '.';
55       _M_data->_M_thousands_sep = ',';
56       _M_data->_M_grouping = "";
57       _M_data->_M_grouping_size = 0;
58       _M_data->_M_curr_symbol = "";
59       _M_data->_M_curr_symbol_size = 0;
60       _M_data->_M_positive_sign = "";
61       _M_data->_M_positive_sign_size = 0;
62       _M_data->_M_negative_sign = "";
63       _M_data->_M_negative_sign_size = 0;
64       _M_data->_M_frac_digits = 0;
65       _M_data->_M_pos_format = money_base::_S_default_pattern;
66       _M_data->_M_neg_format = money_base::_S_default_pattern;
67
68       for (size_t __i = 0; __i < money_base::_S_end; ++__i)
69         _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
70     }
71
72   template<> 
73     void
74     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*)
75     {
76       // "C" locale.
77       if (!_M_data)
78         _M_data = new __moneypunct_cache<char, false>;
79
80       _M_data->_M_decimal_point = '.';
81       _M_data->_M_thousands_sep = ',';
82       _M_data->_M_grouping = "";
83       _M_data->_M_grouping_size = 0;
84       _M_data->_M_curr_symbol = "";
85       _M_data->_M_curr_symbol_size = 0;
86       _M_data->_M_positive_sign = "";
87       _M_data->_M_positive_sign_size = 0;
88       _M_data->_M_negative_sign = "";
89       _M_data->_M_negative_sign_size = 0;
90       _M_data->_M_frac_digits = 0;
91       _M_data->_M_pos_format = money_base::_S_default_pattern;
92       _M_data->_M_neg_format = money_base::_S_default_pattern;
93
94       for (size_t __i = 0; __i < money_base::_S_end; ++__i)
95         _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
96     }
97
98   template<> 
99     moneypunct<char, true>::~moneypunct()
100     { delete _M_data; }
101
102   template<> 
103     moneypunct<char, false>::~moneypunct()
104     { delete _M_data; }
105
106 #ifdef _GLIBCXX_USE_WCHAR_T
107   template<> 
108     void
109     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, 
110                                                         const char*)
111     {
112       // "C" locale
113       if (!_M_data)
114         _M_data = new __moneypunct_cache<wchar_t, true>;
115
116       _M_data->_M_decimal_point = L'.';
117       _M_data->_M_thousands_sep = L',';
118       _M_data->_M_grouping = "";
119       _M_data->_M_grouping_size = 0;
120       _M_data->_M_curr_symbol = L"";
121       _M_data->_M_curr_symbol_size = 0;
122       _M_data->_M_positive_sign = L"";
123       _M_data->_M_positive_sign_size = 0;      
124       _M_data->_M_negative_sign = L"";
125       _M_data->_M_negative_sign_size = 0;      
126       _M_data->_M_frac_digits = 0;
127       _M_data->_M_pos_format = money_base::_S_default_pattern;
128       _M_data->_M_neg_format = money_base::_S_default_pattern;
129
130       for (size_t __i = 0; __i < money_base::_S_end; ++__i)
131         _M_data->_M_atoms[__i] =
132           static_cast<wchar_t>(money_base::_S_atoms[__i]);
133     }
134
135   template<> 
136     void
137     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, 
138                                                          const char*)
139     {
140       // "C" locale
141       if (!_M_data)
142         _M_data = new __moneypunct_cache<wchar_t, false>;
143
144       _M_data->_M_decimal_point = L'.';
145       _M_data->_M_thousands_sep = L',';
146       _M_data->_M_grouping = "";
147       _M_data->_M_grouping_size = 0;
148       _M_data->_M_curr_symbol = L"";
149       _M_data->_M_curr_symbol_size = 0;
150       _M_data->_M_positive_sign = L"";
151       _M_data->_M_positive_sign_size = 0;
152       _M_data->_M_negative_sign = L"";
153       _M_data->_M_negative_sign_size = 0;
154       _M_data->_M_frac_digits = 0;
155       _M_data->_M_pos_format = money_base::_S_default_pattern;
156       _M_data->_M_neg_format = money_base::_S_default_pattern;
157
158       for (size_t __i = 0; __i < money_base::_S_end; ++__i)
159         _M_data->_M_atoms[__i] =
160           static_cast<wchar_t>(money_base::_S_atoms[__i]);
161     }
162
163   template<> 
164     moneypunct<wchar_t, true>::~moneypunct()
165     { delete _M_data; }
166
167   template<> 
168     moneypunct<wchar_t, false>::~moneypunct()
169     { delete _M_data; }
170 #endif
171 }