/*

cls_2: Curl Like Syntax
Yauheni A. Akhotnikau (C) 2001-2003
eao197@yahoo.com
-------------------------------------------------

Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:

1. This software 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.

2. The origin of this software must not be misrepresented, either by
   explicit claim or by omission.

3. Altered versions must be plainly marked as such, and must not be
   misrepresented as being the original software.

-------------------------------------------------

*/
#if !defined( _CLS_2__IS_FILE_HPP_ )
#define _CLS_2__IS_FILE_HPP_

#include <stdio.h>

#include <auto_ptr_3/h/vect_ptr.hpp>

#include <cls_2/h/cls.hpp>

namespace cls_2 {

//
// input_stream_file_t
//

/*
	Input stream from file
*/
class	input_stream_file_t :
	public input_stream_t {
	public :
		input_stream_file_t( const char * file_name );
		virtual ~input_stream_file_t( void );

		bool
		is_open() const;

		int
		query_last_io_result() const;

		const char *
		query_file_name() const;

		virtual unsigned int
		query_line() const;

		// Returns value from ret_code_t
		virtual int
		get( char & ch );

		// Returns previous char to the stream
		virtual void
		back();

	protected :
		auto_ptr_3::vect_ptr_t< char >	m_file_name;
		FILE *	m_file;
		auto_ptr_3::vect_ptr_t< char >	m_buf;
		size_t	m_size;
		size_t	m_pos;
		unsigned int	m_line;

		// Result from last I/O operation
		int	m_errno;

		int
		lo_get_ch( char & ch );

		void
		lo_back_ch( void );
};

} /* namespace cls_2 */

#endif
