]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libstdc++-v3/contrib/libstdc++-v3-4.3.3/src/locale_facets.cc
Inital import
[l4.git] / l4 / pkg / libstdc++-v3 / contrib / libstdc++-v3-4.3.3 / src / locale_facets.cc
1 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2 // 2006, 2007
3 // 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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 #include <locale>
31
32 _GLIBCXX_BEGIN_NAMESPACE(std)
33
34   // Definitions for static const data members of time_base.
35   template<> 
36     const char*
37     __timepunct_cache<char>::_S_timezones[14] =
38     { 
39       "GMT", "HST", "AKST", "PST", "MST", "CST", "EST", "AST", "NST", "CET", 
40       "IST", "EET", "CST", "JST"  
41     };
42  
43 #ifdef _GLIBCXX_USE_WCHAR_T
44   template<> 
45     const wchar_t*
46     __timepunct_cache<wchar_t>::_S_timezones[14] =
47     { 
48       L"GMT", L"HST", L"AKST", L"PST", L"MST", L"CST", L"EST", L"AST", 
49       L"NST", L"CET", L"IST", L"EET", L"CST", L"JST"  
50     };
51 #endif
52
53   // Definitions for static const data members of money_base.
54   const money_base::pattern 
55   money_base::_S_default_pattern =  { {symbol, sign, none, value} };
56
57   const char* money_base::_S_atoms = "-0123456789";
58
59   const char* __num_base::_S_atoms_in = "-+xX0123456789abcdefABCDEF";
60   const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
61
62   // _GLIBCXX_RESOLVE_LIB_DEFECTS
63   // According to the resolution of DR 231, about 22.2.2.2.2, p11,
64   // "str.precision() is specified in the conversion specification".
65   void
66   __num_base::_S_format_float(const ios_base& __io, char* __fptr, char __mod)
67   {
68     ios_base::fmtflags __flags = __io.flags();
69     *__fptr++ = '%';
70     // [22.2.2.2.2] Table 60
71     if (__flags & ios_base::showpos)
72       *__fptr++ = '+';
73     if (__flags & ios_base::showpoint)
74       *__fptr++ = '#';
75
76     // As per DR 231: _always_, not only when 
77     // __flags & ios_base::fixed || __prec > 0
78     *__fptr++ = '.';
79     *__fptr++ = '*';
80
81     if (__mod)
82       *__fptr++ = __mod;
83     ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
84     // [22.2.2.2.2] Table 58
85     if (__fltfield == ios_base::fixed)
86       *__fptr++ = 'f';
87     else if (__fltfield == ios_base::scientific)
88       *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
89     else
90       *__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
91     *__fptr = '\0';
92   }
93
94   bool
95   __verify_grouping(const char* __grouping, size_t __grouping_size,
96                     const string& __grouping_tmp)
97   {
98     const size_t __n = __grouping_tmp.size() - 1;
99     const size_t __min = std::min(__n, size_t(__grouping_size - 1));
100     size_t __i = __n;
101     bool __test = true;
102     
103     // Parsed number groupings have to match the
104     // numpunct::grouping string exactly, starting at the
105     // right-most point of the parsed sequence of elements ...
106     for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
107       __test = __grouping_tmp[__i] == __grouping[__j];
108     for (; __i && __test; --__i)
109       __test = __grouping_tmp[__i] == __grouping[__min];
110     // ... but the first parsed grouping can be <= numpunct
111     // grouping (only do the check if the numpunct char is > 0
112     // because <= 0 means any size is ok).
113     if (static_cast<signed char>(__grouping[__min]) > 0)
114       __test &= __grouping_tmp[0] <= __grouping[__min];
115     return __test;
116   }
117
118 _GLIBCXX_END_NAMESPACE