]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libstdc++-v3/contrib/libstdc++-v3-4.6/config/locale/gnu/time_members.h
update
[l4.git] / l4 / pkg / libstdc++-v3 / contrib / libstdc++-v3-4.6 / config / locale / gnu / time_members.h
1 // std::time_get, std::time_put implementation, GNU version -*- C++ -*-
2
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 // 2009, 2010
5 // Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library.  This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
12
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17
18 // Under Section 7 of GPL version 3, you are granted additional
19 // permissions described in the GCC Runtime Library Exception, version
20 // 3.1, as published by the Free Software Foundation.
21
22 // You should have received a copy of the GNU General Public License and
23 // a copy of the GCC Runtime Library Exception along with this program;
24 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25 // <http://www.gnu.org/licenses/>.
26
27 /** @file bits/time_members.h
28  *  This is an internal header file, included by other library headers.
29  *  Do not attempt to use it directly. @headername{locale}
30  */
31
32 //
33 // ISO C++ 14882: 22.2.5.1.2 - time_get functions
34 // ISO C++ 14882: 22.2.5.3.2 - time_put functions
35 //
36
37 // Written by Benjamin Kosnik <bkoz@redhat.com>
38
39 namespace std _GLIBCXX_VISIBILITY(default)
40 {
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
42
43   template<typename _CharT>
44     __timepunct<_CharT>::__timepunct(size_t __refs) 
45     : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), 
46       _M_name_timepunct(_S_get_c_name())
47     { _M_initialize_timepunct(); }
48
49   template<typename _CharT>
50     __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) 
51     : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), 
52       _M_name_timepunct(_S_get_c_name())
53     { _M_initialize_timepunct(); }
54
55   template<typename _CharT>
56     __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
57                                      size_t __refs) 
58     : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), 
59       _M_name_timepunct(0)
60     {
61       if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
62         {
63           const size_t __len = __builtin_strlen(__s) + 1;
64           char* __tmp = new char[__len];
65           __builtin_memcpy(__tmp, __s, __len);
66           _M_name_timepunct = __tmp;
67         }
68       else
69         _M_name_timepunct = _S_get_c_name();
70
71       __try
72         { _M_initialize_timepunct(__cloc); }
73       __catch(...)
74         {
75           if (_M_name_timepunct != _S_get_c_name())
76             delete [] _M_name_timepunct;
77           __throw_exception_again;
78         }
79     }
80
81   template<typename _CharT>
82     __timepunct<_CharT>::~__timepunct()
83     { 
84       if (_M_name_timepunct != _S_get_c_name())
85         delete [] _M_name_timepunct;
86       delete _M_data; 
87       _S_destroy_c_locale(_M_c_locale_timepunct); 
88     }
89
90 _GLIBCXX_END_NAMESPACE_VERSION
91 } // namespace