time_members.h revision 169691
1110614Skan// std::time_get, std::time_put implementation, generic version -*- C++ -*- 2110614Skan 3169691Skan// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 4110614Skan// 5110614Skan// This file is part of the GNU ISO C++ Library. This library is free 6110614Skan// software; you can redistribute it and/or modify it under the 7110614Skan// terms of the GNU General Public License as published by the 8110614Skan// Free Software Foundation; either version 2, or (at your option) 9110614Skan// any later version. 10110614Skan 11110614Skan// This library is distributed in the hope that it will be useful, 12110614Skan// but WITHOUT ANY WARRANTY; without even the implied warranty of 13110614Skan// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14110614Skan// GNU General Public License for more details. 15110614Skan 16110614Skan// You should have received a copy of the GNU General Public License along 17110614Skan// with this library; see the file COPYING. If not, write to the Free 18169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19110614Skan// USA. 20110614Skan 21110614Skan// As a special exception, you may use this file as part of a free software 22110614Skan// library without restriction. Specifically, if other files instantiate 23110614Skan// templates or use macros or inline functions from this file, or you compile 24110614Skan// this file and link it with other files to produce an executable, this 25110614Skan// file does not by itself cause the resulting executable to be covered by 26110614Skan// the GNU General Public License. This exception does not however 27110614Skan// invalidate any other reasons why the executable file might be covered by 28110614Skan// the GNU General Public License. 29110614Skan 30169691Skan/** @file time_members.h 31169691Skan * This is an internal header file, included by other library headers. 32169691Skan * You should not attempt to use it directly. 33169691Skan */ 34169691Skan 35110614Skan// 36110614Skan// ISO C++ 14882: 22.2.5.1.2 - time_get functions 37110614Skan// ISO C++ 14882: 22.2.5.3.2 - time_put functions 38110614Skan// 39110614Skan 40110614Skan// Written by Benjamin Kosnik <bkoz@redhat.com> 41110614Skan 42169691Skan_GLIBCXX_BEGIN_NAMESPACE(std) 43169691Skan 44110614Skan template<typename _CharT> 45110614Skan __timepunct<_CharT>::__timepunct(size_t __refs) 46132720Skan : facet(__refs), _M_data(NULL) 47110614Skan { 48132720Skan _M_name_timepunct = _S_get_c_name(); 49110614Skan _M_initialize_timepunct(); 50110614Skan } 51110614Skan 52110614Skan template<typename _CharT> 53132720Skan __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) 54132720Skan : facet(__refs), _M_data(__cache) 55132720Skan { 56132720Skan _M_name_timepunct = _S_get_c_name(); 57132720Skan _M_initialize_timepunct(); 58132720Skan } 59132720Skan 60132720Skan template<typename _CharT> 61110614Skan __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, 62110614Skan size_t __refs) 63132720Skan : facet(__refs), _M_data(NULL) 64110614Skan { 65169691Skan const size_t __len = std::strlen(__s) + 1; 66169691Skan char* __tmp = new char[__len]; 67169691Skan std::memcpy(__tmp, __s, __len); 68132720Skan _M_name_timepunct = __tmp; 69169691Skan 70169691Skan try 71169691Skan { _M_initialize_timepunct(__cloc); } 72169691Skan catch(...) 73169691Skan { 74169691Skan delete [] _M_name_timepunct; 75169691Skan __throw_exception_again; 76169691Skan } 77110614Skan } 78110614Skan 79110614Skan template<typename _CharT> 80110614Skan __timepunct<_CharT>::~__timepunct() 81110614Skan { 82132720Skan if (_M_name_timepunct != _S_get_c_name()) 83110614Skan delete [] _M_name_timepunct; 84132720Skan delete _M_data; 85110614Skan _S_destroy_c_locale(_M_c_locale_timepunct); 86110614Skan } 87169691Skan 88169691Skan_GLIBCXX_END_NAMESPACE 89