/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: ByteToCharSingleByte.h,v 1.10 2003/01/11 14:05:31 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_TEXT_ENC_BYTETOCHARSINGLEBYTE_H
# define INCLUDE_JAKELIB2_TEXT_ENC_BYTETOCHARSINGLEBYTE_H
#include "ByteToCharConverter.h"

namespace jakelib {
  namespace util {
    class CharArray;
  }
  namespace text {
    namespace enc {

      /**
       * \c ByteToCharSingleByte is the base class of all character
       * conversion classes that provide conversion of single byte
       * character encodings like \c ISO-8859-xx or \c ASCII.
       *
       * @class ByteToCharSingleByte
       * @version $Id: ByteToCharSingleByte.h,v 1.10 2003/01/11 14:05:31 florian Exp $
       * @author Florian 'Overflo' Wolff (florian@donuz.de)
       */
      class ByteToCharSingleByte : public ByteToCharConverter
	{
	public:

          /**
           * Creates a new ByteToCharSingleByte converter for a given
           * encoding and a given conversion table.
           *
           * Used internally by sub-classes.
           * Call \c ByteToCharConverter::getConverter() instead of this
           * constroctur to get an instance.
           */
	  ByteToCharSingleByte(char* characterEncoding, const jchar* conversionTable);

          /**
           * Takes a number of bytes from an input stream
           * and converts them to unicode characters.
           *
           * Stops if the input stream ends or a given number of output
           * characters has been written.
           *
           * @param inputStream The input stream to read the input bytes from
           * @param output      Pointer to a \c jchar array where the output
           *                    will be written
           * @param len         Number of characters to be written.
           *                    \c output must provide enough space to
           *                    contain \c len characters
           * @return The number of characters that have actually been written.
           *         Equals the number of bytes that have been read from the 
           *         input stream.
           */
	  int convert(jakelib::io::InputStream* inputStream,
		      jchar* output, int len);

	protected:

          /** The conversion table. */
	  const jchar* conversionTable;

	  JAKELIB_DECLARE_CLASS(ByteToCharSingleByte);
	};
    }
  }
}

#endif
