1110614Skan// std::time_get, std::time_put implementation, GNU 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), _M_c_locale_timepunct(NULL),
47169691Skan      _M_name_timepunct(_S_get_c_name())
48132720Skan    { _M_initialize_timepunct(); }
49110614Skan
50110614Skan  template<typename _CharT>
51132720Skan    __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
52132720Skan    : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
53169691Skan      _M_name_timepunct(_S_get_c_name())
54132720Skan    { _M_initialize_timepunct(); }
55132720Skan
56132720Skan  template<typename _CharT>
57132720Skan    __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
58117397Skan				     size_t __refs)
59132720Skan    : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
60169691Skan      _M_name_timepunct(NULL)
61110614Skan    {
62169691Skan      const size_t __len = std::strlen(__s) + 1;
63169691Skan      char* __tmp = new char[__len];
64169691Skan      std::memcpy(__tmp, __s, __len);
65132720Skan      _M_name_timepunct = __tmp;
66169691Skan
67169691Skan      try
68169691Skan	{ _M_initialize_timepunct(__cloc); }
69169691Skan      catch(...)
70169691Skan	{
71169691Skan	  delete [] _M_name_timepunct;
72169691Skan	  __throw_exception_again;
73169691Skan	}
74110614Skan    }
75110614Skan
76110614Skan  template<typename _CharT>
77110614Skan    __timepunct<_CharT>::~__timepunct()
78110614Skan    {
79132720Skan      if (_M_name_timepunct != _S_get_c_name())
80110614Skan	delete [] _M_name_timepunct;
81132720Skan      delete _M_data;
82110614Skan      _S_destroy_c_locale(_M_c_locale_timepunct);
83110614Skan    }
84169691Skan
85169691Skan_GLIBCXX_END_NAMESPACE
86