// -*- c++ -*-

/*
 * 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: PrintWriter.h,v 1.23 2003/09/09 19:17:13 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_IO_PRINTWRITER_H
# define INCLUDE_JAKELIB2_IO_PRINTWRITER_H
# include "BufferedWriter.h"

namespace jakelib {
  namespace io {
    class OutputStream;

    /**
     * @class PrintWriter
     * @version $Id: PrintWriter.h,v 1.23 2003/09/09 19:17:13 florian Exp $
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     */
    class PrintWriter : public Writer
    {
    public:
      PrintWriter(OutputStream* output, jboolean autoflush = false);
      PrintWriter(Writer* output, jboolean autoflush = false);

      ~PrintWriter();
      void println();
      void print(char* str);
      void print(jakelib::lang::Object* obj);
      void print(jakelib::lang::Object& obj);
      void println(char* str);
      void println(jakelib::lang::Object* obj);
      void println(jakelib::lang::Object& obj);
      void print(jchar c);
      void println(jchar c);

      void close();
      void flush();
      void write(jchar* buf, int offset, int len);

      /**
       * C-style \c printf() method.
       *
       * \b Example:
       * \code
       * System::out->printf(`"Hello %S, it's %2i:%02i."`, `"world"`, 15, 45);
       * \endcode
       *
       * <b>Formatter codes:</b>
       * \li <tt>\%i</tt> Integer (\c jint)
       * \li <tt>\%l</tt> Long (\c jlong)
       * \li <tt>\%s</tt> C-style string (\c jbyte)
       * \li <tt>\%S</tt> Jakelib String (\c jakelib::lang::String*)
       * \li <tt>\%f</tt> Float (\c jfloat)
       * \li <tt>\%d</tt> Double (\c jdouble)
       * \li <tt>\%c</tt> Character (\c jchar)
       * \li <tt>\%\%</tt> Percent sign (\c %)
       */
      void printf(jakelib::lang::String *format, ...);
  
    protected:
      Writer* output;
      jboolean autoflush;

      JAKELIB_DECLARE_CLASS(PrintWriter);
    };

  }
}
#endif

