time_members.h

Go to the documentation of this file.
00001 // std::time_get, std::time_put implementation, generic version -*- C++ -*-
00002 
00003 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 3, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // Under Section 7 of GPL version 3, you are granted additional
00018 // permissions described in the GCC Runtime Library Exception, version
00019 // 3.1, as published by the Free Software Foundation.
00020 
00021 // You should have received a copy of the GNU General Public License and
00022 // a copy of the GCC Runtime Library Exception along with this program;
00023 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00024 // <http://www.gnu.org/licenses/>.
00025 
00026 /** @file time_members.h
00027  *  This is an internal header file, included by other library headers.
00028  *  You should not attempt to use it directly.
00029  */
00030 
00031 //
00032 // ISO C++ 14882: 22.2.5.1.2 - time_get functions
00033 // ISO C++ 14882: 22.2.5.3.2 - time_put functions
00034 //
00035 
00036 // Written by Benjamin Kosnik <bkoz@redhat.com>
00037 
00038 _GLIBCXX_BEGIN_NAMESPACE(std)
00039 
00040   template<typename _CharT>
00041     __timepunct<_CharT>::__timepunct(size_t __refs) 
00042     : facet(__refs), _M_data(NULL)
00043     { 
00044       _M_name_timepunct = _S_get_c_name();
00045       _M_initialize_timepunct(); 
00046     }
00047 
00048   template<typename _CharT>
00049     __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) 
00050     : facet(__refs), _M_data(__cache)
00051     { 
00052       _M_name_timepunct = _S_get_c_name();
00053       _M_initialize_timepunct(); 
00054     }
00055 
00056   template<typename _CharT>
00057     __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, 
00058                      size_t __refs) 
00059     : facet(__refs), _M_data(NULL)
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

Generated on 21 Nov 2011 for libstdc++ by  doxygen 1.6.1