//  iosfwd : headerfile for the free standard C++ library
//  
//  Copyright (C) 1999 by the free standard C++ Library Team
//                        see AUTHORS for more details
//
//  Homepage : http://www.inf.fu-berlin.de/~mkrueger/fscl/
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Library General Public
//  License as published by the Free Software Foundation; either	
//  version 2 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Library General Public License for more details.
//  You should have received a copy of the GNU Library General Public
//  License along with this library; if not, write to the Free
//  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//  version : 0.1 last modified : 17.09.99


#ifndef __CPP_IOSFWD
#define __CPP_IOSFWD

#include<cstddef>
#include<cstring>

namespace std {

	typedef int  streamoff;
	typedef int  streamsize;	
	typedef int  wstreamoff;
	typedef int  wstreamsize;
	typedef int  mbstate_t;

	// 21.1, character traits:
	template<class charT>
	struct char_traits
	{
	};

	template <>
	struct char_traits<char>
	{	
		typedef char        char_type;
		typedef int         int_type;
		typedef streamoff   off_type; 
		
		typedef mbstate_t   pos_type;  // should be streampos, but mbstate_t should be OK
		
		typedef mbstate_t   state_type; 

		static void assign(char_type &c1, const char_type &c2)
		{
			c1 = c2;
		}
		
		static bool eq(const char_type &c1, const char_type &c2)
		{
			return c1 == c2;
		}

		static bool lt(const char_type &c1, const char_type &c2)
		{
			return c1 < c2;
		}
		
		static int compare(const char_type *s1, const char_type *s2, size_t n)
		{
			return strncmp((char *)s1, (char *)s2, n);
		}
		
		static size_t length(const char_type* s)
		{
			return strlen((char *)s);
		}
		
		static const char_type *find(const char_type *s, int n, const char_type& a)
		{
			while (n--)
				if (s[n] == a)
					return &s[n];
			return 0;
		}
		
		static char_type *move(char_type *s1, const char_type *s2, size_t n)
		{
			memcpy(s1, s2, n * sizeof(char_type));
			return s1;
		}
		
		static char_type *copy(char_type *s1, const char_type *s2, size_t n)
		{
			memcpy(s1, s2, n * sizeof(char_type));
			return s1;
		}
		
		static char_type *assign(char_type *s, size_t n, char_type a)
		{
			while (n--)
				s[n] = a;
			return s;
		}
		
		static int_type not_eof(const int_type &c)
		{
			return c != -10;
		}

		static char_type to_char_type(const int_type& c)
		{
			return (char_type) c;
		}

		static int_type to_int_type(const char_type& c)
		{
			return (int_type) c;
		}

		static bool eq_int_type(const int_type &c1, const int_type &c2)
		{
			return c1 == c2;
		}
		
		static int_type eof()
		{
			return -10; 
		}
	};

/* TODO :
	template <> 
	struct char_traits<wchar_t>;
*/	
	
	template <class T>
	class allocator;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_ios;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_streambuf;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_istream;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_ostream;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_iostream;
	
	template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
	class basic_stringbuf;
	
	template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
	class basic_istringstream;
	
	template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
	class basic_ostringstream;
	
	template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
	class basic_stringstream;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_filebuf;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_ifstream;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_ofstream;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_fstream;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_istreambuf_iterator;
	
	template <class charT, class traits = char_traits<charT> >
	class basic_ostreambuf_iterator;
	
	typedef basic_ios<char>       ios;
	typedef basic_ios<wchar_t>    wios;
	
	typedef basic_streambuf<char> streambuf;
	typedef basic_istream<char>   istream;
	typedef basic_ostream<char>   ostream;
	typedef basic_iostream<char>  iostream;
	
	typedef basic_stringbuf<char>     stringbuf;
	typedef basic_istringstream<char> istringstream;
	typedef basic_ostringstream<char> ostringstream;
	typedef basic_stringstream<char>  stringstream;
	
	typedef basic_filebuf<char>  filebuf;
	typedef basic_ifstream<char> ifstream;
	typedef basic_ofstream<char> ofstream;
	typedef basic_fstream<char>  fstream;
	
	typedef basic_streambuf<wchar_t> wstreambuf;
	typedef basic_istream<wchar_t>   wistream;
	typedef basic_ostream<wchar_t>   wostream;
	typedef basic_iostream<wchar_t>  wiostream;
	
	typedef basic_stringbuf<wchar_t>     wstringbuf;
	typedef basic_istringstream<wchar_t> wistringstream;
	typedef basic_ostringstream<wchar_t> wostringstream;
	typedef basic_stringstream<wchar_t>  wstringstream;
	
	typedef basic_filebuf<wchar_t>  wfilebuf;
	typedef basic_ifstream<wchar_t> wifstream;
	typedef basic_ofstream<wchar_t> wofstream;
	typedef basic_fstream<wchar_t>  wfstream;

	template<class state>
	class fpos;

	typedef fpos<char_traits<char>::state_type>    streampos;
//	typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
	
}

#endif
