time_members.h

Go to the documentation of this file.
00001 // std::time_get, std::time_put implementation, GNU 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), _M_c_locale_timepunct(NULL), 
00043       _M_name_timepunct(_S_get_c_name())
00044     { _M_initialize_timepunct(); }
00045 
00046   template<typename _CharT>
00047     __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) 
00048     : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL), 
00049       _M_name_timepunct(_S_get_c_name())
00050     { _M_initialize_timepunct(); }
00051 
00052   template<typename _CharT>
00053     __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
00054                      size_t __refs) 
00055     : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), 
00056       _M_name_timepunct(NULL)
00057     {
00058       if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
00059     {
00060       const size_t __len = __builtin_strlen(__s) + 1;
00061       char* __tmp = new char[__len];
00062       __builtin_memcpy(__tmp, __s, __len);
00063       _M_name_timepunct = __tmp;
00064     }
00065       else
00066     _M_name_timepunct = _S_get_c_name();
00067 
00068       __try
00069     { _M_initialize_timepunct(__cloc); }
00070       __catch(...)
00071     {
00072       if (_M_name_timepunct != _S_get_c_name())
00073         delete [] _M_name_timepunct;
00074       __throw_exception_again;
00075     }
00076     }
00077 
00078   template<typename _CharT>
00079     __timepunct<_CharT>::~__timepunct()
00080     { 
00081       if (_M_name_timepunct != _S_get_c_name())
00082     delete [] _M_name_timepunct;
00083       delete _M_data; 
00084       _S_destroy_c_locale(_M_c_locale_timepunct); 
00085     }
00086 
00087 _GLIBCXX_END_NAMESPACE

Generated on Thu Jul 23 21:16:28 2009 for libstdc++ by  doxygen 1.5.8