117721Speter// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
217721Speter
317721Speter// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
417721Speter//
517721Speter// This file is part of the GNU ISO C++ Library.  This library is free
632785Speter// software; you can redistribute it and/or modify it under the
717721Speter// terms of the GNU General Public License as published by the
817721Speter// Free Software Foundation; either version 2, or (at your option)
917721Speter// any later version.
1017721Speter
1117721Speter// This library is distributed in the hope that it will be useful,
1217721Speter// but WITHOUT ANY WARRANTY; without even the implied warranty of
1317721Speter// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1417721Speter// GNU General Public License for more details.
1517721Speter
1617721Speter// You should have received a copy of the GNU General Public License along
1725839Speter// with this library; see the file COPYING.  If not, write to the Free
1825839Speter// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
1925839Speter// USA.
2025839Speter
2117721Speter// As a special exception, you may use this file as part of a free software
2217721Speter// library without restriction.  Specifically, if other files instantiate
2317721Speter// templates or use macros or inline functions from this file, or you compile
2417721Speter// this file and link it with other files to produce an executable, this
2517721Speter// file does not by itself cause the resulting executable to be covered by
2625839Speter// the GNU General Public License.  This exception does not however
2725839Speter// invalidate any other reasons why the executable file might be covered by
2825839Speter// the GNU General Public License.
2925839Speter
3025839Speter/** @file time_members.h
3125839Speter *  This is an internal header file, included by other library headers.
3225839Speter *  You should not attempt to use it directly.
3317721Speter */
3417721Speter
3517721Speter//
3617721Speter// ISO C++ 14882: 22.2.5.1.2 - time_get functions
3717721Speter// ISO C++ 14882: 22.2.5.3.2 - time_put functions
3817721Speter//
3917721Speter
4017721Speter// Written by Benjamin Kosnik <bkoz@redhat.com>
4117721Speter
4225839Speter_GLIBCXX_BEGIN_NAMESPACE(std)
4317721Speter
4417721Speter  template<typename _CharT>
4517721Speter    __timepunct<_CharT>::__timepunct(size_t __refs)
4617721Speter    : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
4717721Speter      _M_name_timepunct(_S_get_c_name())
4817721Speter    { _M_initialize_timepunct(); }
4917721Speter
5017721Speter  template<typename _CharT>
5117721Speter    __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
5217721Speter    : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
5317721Speter      _M_name_timepunct(_S_get_c_name())
5417721Speter    { _M_initialize_timepunct(); }
5517721Speter
5617721Speter  template<typename _CharT>
5717721Speter    __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
5817721Speter				     size_t __refs)
5917721Speter    : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
6017721Speter      _M_name_timepunct(NULL)
6117721Speter    {
6254427Speter      const size_t __len = std::strlen(__s) + 1;
6317721Speter      char* __tmp = new char[__len];
6417721Speter      std::memcpy(__tmp, __s, __len);
6525839Speter      _M_name_timepunct = __tmp;
6632785Speter
6732785Speter      try
6825839Speter	{ _M_initialize_timepunct(__cloc); }
6917721Speter      catch(...)
7025839Speter	{
7125839Speter	  delete [] _M_name_timepunct;
7232785Speter	  __throw_exception_again;
7317721Speter	}
7417721Speter    }
7517721Speter
7617721Speter  template<typename _CharT>
7725839Speter    __timepunct<_CharT>::~__timepunct()
7817721Speter    {
7917721Speter      if (_M_name_timepunct != _S_get_c_name())
8017721Speter	delete [] _M_name_timepunct;
8117721Speter      delete _M_data;
8217721Speter      _S_destroy_c_locale(_M_c_locale_timepunct);
8317721Speter    }
8417721Speter
8517721Speter_GLIBCXX_END_NAMESPACE
8617721Speter