]>
Commit | Line | Data |
---|---|---|
1c26d8fd BK |
1 | // std::time_get, std::time_put implementation, generic version -*- C++ -*- |
2 | ||
a945c346 | 3 | // Copyright (C) 2001-2024 Free Software Foundation, Inc. |
1c26d8fd BK |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
1c26d8fd BK |
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 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
1c26d8fd | 24 | |
f910786b | 25 | /** @file bits/time_members.h |
143c27b0 | 26 | * This is an internal header file, included by other library headers. |
f910786b | 27 | * Do not attempt to use it directly. @headername{locale} |
143c27b0 BK |
28 | */ |
29 | ||
1c26d8fd BK |
30 | // |
31 | // ISO C++ 14882: 22.2.5.1.2 - time_get functions | |
32 | // ISO C++ 14882: 22.2.5.3.2 - time_put functions | |
33 | // | |
34 | ||
35 | // Written by Benjamin Kosnik <bkoz@redhat.com> | |
36 | ||
12ffa228 BK |
37 | namespace std _GLIBCXX_VISIBILITY(default) |
38 | { | |
39 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
143c27b0 | 40 | |
1c26d8fd | 41 | template<typename _CharT> |
f92ab29f | 42 | __timepunct<_CharT>::__timepunct(size_t __refs) |
445877a9 | 43 | : facet(__refs), _M_data(0) |
f92ab29f | 44 | { |
bb1b12ec | 45 | _M_name_timepunct = _S_get_c_name(); |
f92ab29f | 46 | _M_initialize_timepunct(); |
fea4065d BK |
47 | } |
48 | ||
49 | template<typename _CharT> | |
f92ab29f | 50 | __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) |
fea4065d | 51 | : facet(__refs), _M_data(__cache) |
f92ab29f | 52 | { |
bb1b12ec | 53 | _M_name_timepunct = _S_get_c_name(); |
f92ab29f | 54 | _M_initialize_timepunct(); |
1c26d8fd BK |
55 | } |
56 | ||
57 | template<typename _CharT> | |
f92ab29f CG |
58 | __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, |
59 | size_t __refs) | |
445877a9 | 60 | : facet(__refs), _M_data(0) |
f697c80d PC |
61 | { |
62 | if (__builtin_strcmp(__s, _S_get_c_name()) != 0) | |
63 | { | |
64 | const size_t __len = __builtin_strlen(__s) + 1; | |
65 | char* __tmp = new char[__len]; | |
66 | __builtin_memcpy(__tmp, __s, __len); | |
67 | _M_name_timepunct = __tmp; | |
68 | } | |
69 | else | |
70 | _M_name_timepunct = _S_get_c_name(); | |
ab940869 | 71 | |
bc2631e0 | 72 | __try |
ab940869 | 73 | { _M_initialize_timepunct(__cloc); } |
bc2631e0 | 74 | __catch(...) |
f697c80d PC |
75 | { |
76 | if (_M_name_timepunct != _S_get_c_name()) | |
77 | delete [] _M_name_timepunct; | |
ab940869 PC |
78 | __throw_exception_again; |
79 | } | |
1c26d8fd BK |
80 | } |
81 | ||
82 | template<typename _CharT> | |
83 | __timepunct<_CharT>::~__timepunct() | |
f92ab29f | 84 | { |
bb1b12ec | 85 | if (_M_name_timepunct != _S_get_c_name()) |
1c26d8fd | 86 | delete [] _M_name_timepunct; |
fea4065d | 87 | delete _M_data; |
f92ab29f | 88 | _S_destroy_c_locale(_M_c_locale_timepunct); |
1c26d8fd | 89 | } |
143c27b0 | 90 | |
12ffa228 BK |
91 | _GLIBCXX_END_NAMESPACE_VERSION |
92 | } // namespace |