libstdc++
|
00001 // std::time_get, std::time_put implementation, GNU version -*- C++ -*- 00002 00003 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 00004 // 2009, 2010 00005 // Free Software Foundation, Inc. 00006 // 00007 // This file is part of the GNU ISO C++ Library. This library is free 00008 // software; you can redistribute it and/or modify it under the 00009 // terms of the GNU General Public License as published by the 00010 // Free Software Foundation; either version 3, or (at your option) 00011 // any later version. 00012 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 00018 // Under Section 7 of GPL version 3, you are granted additional 00019 // permissions described in the GCC Runtime Library Exception, version 00020 // 3.1, as published by the Free Software Foundation. 00021 00022 // You should have received a copy of the GNU General Public License and 00023 // a copy of the GCC Runtime Library Exception along with this program; 00024 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00025 // <http://www.gnu.org/licenses/>. 00026 00027 /** @file bits/time_members.h 00028 * This is an internal header file, included by other library headers. 00029 * Do not attempt to use it directly. @headername{locale} 00030 */ 00031 00032 // 00033 // ISO C++ 14882: 22.2.5.1.2 - time_get functions 00034 // ISO C++ 14882: 22.2.5.3.2 - time_put functions 00035 // 00036 00037 // Written by Benjamin Kosnik <bkoz@redhat.com> 00038 00039 namespace std _GLIBCXX_VISIBILITY(default) 00040 { 00041 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00042 00043 template<typename _CharT> 00044 __timepunct<_CharT>::__timepunct(size_t __refs) 00045 : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), 00046 _M_name_timepunct(_S_get_c_name()) 00047 { _M_initialize_timepunct(); } 00048 00049 template<typename _CharT> 00050 __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) 00051 : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), 00052 _M_name_timepunct(_S_get_c_name()) 00053 { _M_initialize_timepunct(); } 00054 00055 template<typename _CharT> 00056 __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, 00057 size_t __refs) 00058 : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), 00059 _M_name_timepunct(0) 00060 { 00061 if (__builtin_strcmp(__s, _S_get_c_name()) != 0) 00062 { 00063 const size_t __len = __builtin_strlen(__s) + 1; 00064 char* __tmp = new char[__len]; 00065 __builtin_memcpy(__tmp, __s, __len); 00066 _M_name_timepunct = __tmp; 00067 } 00068 else 00069 _M_name_timepunct = _S_get_c_name(); 00070 00071 __try 00072 { _M_initialize_timepunct(__cloc); } 00073 __catch(...) 00074 { 00075 if (_M_name_timepunct != _S_get_c_name()) 00076 delete [] _M_name_timepunct; 00077 __throw_exception_again; 00078 } 00079 } 00080 00081 template<typename _CharT> 00082 __timepunct<_CharT>::~__timepunct() 00083 { 00084 if (_M_name_timepunct != _S_get_c_name()) 00085 delete [] _M_name_timepunct; 00086 delete _M_data; 00087 _S_destroy_c_locale(_M_c_locale_timepunct); 00088 } 00089 00090 _GLIBCXX_END_NAMESPACE_VERSION 00091 } // namespace