Blame qtools/qtextstream.cpp

Packit 1c1d7e
/****************************************************************************
Packit 1c1d7e
** 
Packit 1c1d7e
**
Packit 1c1d7e
** Implementation of QTextStream class
Packit 1c1d7e
**
Packit 1c1d7e
** Created : 940922
Packit 1c1d7e
**
Packit 1c1d7e
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
Packit 1c1d7e
**
Packit 1c1d7e
** This file is part of the tools module of the Qt GUI Toolkit.
Packit 1c1d7e
**
Packit 1c1d7e
** This file may be distributed under the terms of the Q Public License
Packit 1c1d7e
** as defined by Trolltech AS of Norway and appearing in the file
Packit 1c1d7e
** LICENSE.QPL included in the packaging of this file.
Packit 1c1d7e
**
Packit 1c1d7e
** This file may be distributed and/or modified under the terms of the
Packit 1c1d7e
** GNU General Public License version 2 as published by the Free Software
Packit 1c1d7e
** Foundation and appearing in the file LICENSE.GPL included in the
Packit 1c1d7e
** packaging of this file.
Packit 1c1d7e
**
Packit 1c1d7e
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
Packit 1c1d7e
** licenses may use this file in accordance with the Qt Commercial License
Packit 1c1d7e
** Agreement provided with the Software.
Packit 1c1d7e
**
Packit 1c1d7e
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
Packit 1c1d7e
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit 1c1d7e
**
Packit 1c1d7e
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
Packit 1c1d7e
**   information about Qt Commercial License Agreements.
Packit 1c1d7e
** See http://www.trolltech.com/qpl/ for QPL licensing information.
Packit 1c1d7e
** See http://www.trolltech.com/gpl/ for GPL licensing information.
Packit 1c1d7e
**
Packit 1c1d7e
** Contact info@trolltech.com if any conditions of this licensing are
Packit 1c1d7e
** not clear to you.
Packit 1c1d7e
**
Packit 1c1d7e
**********************************************************************/
Packit 1c1d7e
Packit 1c1d7e
#include "qtextstream.h"
Packit 1c1d7e
Packit 1c1d7e
#ifndef QT_NO_TEXTSTREAM
Packit 1c1d7e
#include "qtextcodec.h"
Packit 1c1d7e
#include "qregexp.h"
Packit 1c1d7e
#include "qbuffer.h"
Packit 1c1d7e
#include "qfile.h"
Packit 1c1d7e
#include <stdio.h>
Packit 1c1d7e
#include <ctype.h>
Packit 1c1d7e
#include <stdlib.h>
Packit 1c1d7e
Packit 1c1d7e
#if defined(_OS_WIN32_)
Packit 1c1d7e
#include <windows.h>
Packit 1c1d7e
#endif
Packit 1c1d7e
Packit 1c1d7e
// NOT REVISED
Packit 1c1d7e
/*!
Packit 1c1d7e
  \class QTextStream qtextstream.h
Packit 1c1d7e
Packit 1c1d7e
  \brief The QTextStream class provides basic functions for reading and
Packit 1c1d7e
  writing text using a QIODevice.
Packit 1c1d7e
Packit 1c1d7e
  \ingroup io
Packit 1c1d7e
Packit 1c1d7e
  \define endl
Packit 1c1d7e
  \define bin
Packit 1c1d7e
  \define oct
Packit 1c1d7e
  \define dec
Packit 1c1d7e
  \define hex
Packit 1c1d7e
  \define flush
Packit 1c1d7e
  \define ws
Packit 1c1d7e
Packit 1c1d7e
  The text stream class has a functional interface that is very
Packit 1c1d7e
  similar to that of the standard C++ iostream class.  The difference
Packit 1c1d7e
  between iostream and QTextStream is that our stream operates on a
Packit 1c1d7e
  QIODevice, which is easily subclassed, while iostream operates on
Packit 1c1d7e
  FILE * pointers, which can not be subclassed.
Packit 1c1d7e
Packit 1c1d7e
  Qt provides several global functions similar to the ones in iostream:
Packit 1c1d7e
  
    Packit 1c1d7e
      
  • \c bin sets the QTextStream to read/write binary numbers
  • Packit 1c1d7e
      
  • \c oct sets the QTextStream to read/write octal numbers
  • Packit 1c1d7e
      
  • \c dec sets the QTextStream to read/write decimal numbers
  • Packit 1c1d7e
      
  • \c hex sets the QTextStream to read/write hexadecimal numbers
  • Packit 1c1d7e
      
  • \c endl forces a line break
  • Packit 1c1d7e
      
  • \c flush forces the QIODevice to flush any buffered data
  • Packit 1c1d7e
      
  • \c ws eats any available white space (on input)
  • Packit 1c1d7e
      
  • \c reset resets the QTextStream to its default mode (see reset()).
  • Packit 1c1d7e
      
    Packit 1c1d7e
    Packit 1c1d7e
      \warning By default, QTextStream will automatically detect whether
    Packit 1c1d7e
      integers in the stream are in decimal, octal, hexadecimal or binary
    Packit 1c1d7e
      format when reading from the stream. In particular, a leading '0'
    Packit 1c1d7e
      signifies octal, ie. the sequence "0100" will be interpreted as
    Packit 1c1d7e
      64.
    Packit 1c1d7e
    Packit 1c1d7e
      The QTextStream class reads and writes text and it is not
    Packit 1c1d7e
      appropriate for dealing with binary data (but QDataStream is).
    Packit 1c1d7e
    Packit 1c1d7e
      By default output of Unicode text (ie. QString) is done using the
    Packit 1c1d7e
      local 8-bit encoding.  This can be changed using the setEncoding()
    Packit 1c1d7e
      method.  For input, the QTextStream will auto-detect standard
    Packit 1c1d7e
      Unicode "byte order marked" text files, but otherwise the local
    Packit 1c1d7e
      8-bit encoding is used.
    Packit 1c1d7e
    Packit 1c1d7e
      \sa QDataStream
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    /*
    Packit 1c1d7e
      \class QTSManip qtextstream.h
    Packit 1c1d7e
    Packit 1c1d7e
      \brief The QTSManip class is an internal helper class for the
    Packit 1c1d7e
      QTextStream.
    Packit 1c1d7e
    Packit 1c1d7e
      It is generally a very bad idea to use this class directly in
    Packit 1c1d7e
      application programs.
    Packit 1c1d7e
    Packit 1c1d7e
      \internal
    Packit 1c1d7e
    Packit 1c1d7e
      This class makes it possible to give the QTextStream function objects
    Packit 1c1d7e
      with arguments, like this:
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        QTextStream cout( stdout, IO_WriteOnly );
    Packit 1c1d7e
        cout << setprecision( 8 );		// QTSManip used here!
    Packit 1c1d7e
        cout << 3.14159265358979323846;
    Packit 1c1d7e
      \endcode
    Packit 1c1d7e
    Packit 1c1d7e
      The setprecision() function returns a QTSManip object.
    Packit 1c1d7e
      The QTSManip object contains a pointer to a member function in
    Packit 1c1d7e
      QTextStream and an integer argument.
    Packit 1c1d7e
      When serializing a QTSManip into a QTextStream, the function
    Packit 1c1d7e
      is executed with the argument.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    /*! \fn QTSManip::QTSManip (QTSMFI m, int a)
    Packit 1c1d7e
    Packit 1c1d7e
      Constructs a QTSManip object which will call \a m (a member function
    Packit 1c1d7e
      in QTextStream which accepts a single int) with argument \a a when
    Packit 1c1d7e
      QTSManip::exec() is called.  Used internally in e.g. endl:
    Packit 1c1d7e
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        s << "some text" << endl << "more text";
    Packit 1c1d7e
      \endcode
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    /*! \fn void QTSManip::exec (QTextStream& s)
    Packit 1c1d7e
    Packit 1c1d7e
      Calls the member function specified in the constructor, for object
    Packit 1c1d7e
      \a s.  Used internally in e.g. endl:
    Packit 1c1d7e
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        s << "some text" << endl << "more text";
    Packit 1c1d7e
      \endcode
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    /*****************************************************************************
    Packit 1c1d7e
      QTextStream member functions
    Packit 1c1d7e
     *****************************************************************************/
    Packit 1c1d7e
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
    #undef  CHECK_STREAM_PRECOND
    Packit 1c1d7e
    #define CHECK_STREAM_PRECOND  if ( !dev ) {				\
    Packit 1c1d7e
    				qWarning( "QTextStream: No device" );	\
    Packit 1c1d7e
    				return *this; }
    Packit 1c1d7e
    #else
    Packit 1c1d7e
    #define CHECK_STREAM_PRECOND
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    #define I_SHORT		0x0010
    Packit 1c1d7e
    #define I_INT		0x0020
    Packit 1c1d7e
    #define I_LONG		0x0030
    Packit 1c1d7e
    #define I_TYPE_MASK	0x00f0
    Packit 1c1d7e
    Packit 1c1d7e
    #define I_BASE_2	QTS::bin
    Packit 1c1d7e
    #define I_BASE_8	QTS::oct
    Packit 1c1d7e
    #define I_BASE_10	QTS::dec
    Packit 1c1d7e
    #define I_BASE_16	QTS::hex
    Packit 1c1d7e
    #define I_BASE_MASK	(QTS::bin | QTS::oct | QTS::dec | QTS::hex)
    Packit 1c1d7e
    Packit 1c1d7e
    #define I_SIGNED	0x0100
    Packit 1c1d7e
    #define I_UNSIGNED	0x0200
    Packit 1c1d7e
    #define I_SIGN_MASK	0x0f00
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    static const QChar QEOF = QChar((ushort)0xffff); //guaranteed not to be a character.
    Packit 1c1d7e
    Packit 1c1d7e
    const int QTextStream::basefield   = I_BASE_MASK;
    Packit 1c1d7e
    const int QTextStream::adjustfield = ( QTextStream::left |
    Packit 1c1d7e
    				       QTextStream::right |
    Packit 1c1d7e
    				       QTextStream::internal );
    Packit 1c1d7e
    const int QTextStream::floatfield  = ( QTextStream::scientific |
    Packit 1c1d7e
    				       QTextStream::fixed );
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    class QTextStreamPrivate {
    Packit 1c1d7e
    public:
    Packit 1c1d7e
    #ifndef QT_NO_TEXTCODEC
    Packit 1c1d7e
        QTextStreamPrivate() : decoder( 0 ), sourceType( NotSet ) {}
    Packit 1c1d7e
        ~QTextStreamPrivate() { delete decoder; }
    Packit 1c1d7e
        QTextDecoder *decoder;		//???
    Packit 1c1d7e
    #else
    Packit 1c1d7e
        QTextStreamPrivate() : sourceType( NotSet ) {}
    Packit 1c1d7e
        ~QTextStreamPrivate() { }
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        QString ungetcBuf;
    Packit 1c1d7e
    Packit 1c1d7e
        enum SourceType { NotSet, IODevice, String, ByteArray, File };
    Packit 1c1d7e
        SourceType sourceType;
    Packit 1c1d7e
    };
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    // skips whitespace and returns the first non-whitespace character
    Packit 1c1d7e
    QChar QTextStream::eat_ws()
    Packit 1c1d7e
    {
    Packit 1c1d7e
        QChar c;
    Packit 1c1d7e
        do { c = ts_getc(); } while ( c != QEOF && ts_isspace(c) );
    Packit 1c1d7e
        return c;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    void QTextStream::init()
    Packit 1c1d7e
    {
    Packit 1c1d7e
        // ### ungetcBuf = QEOF;
    Packit 1c1d7e
        dev = 0;					// no device set
    Packit 1c1d7e
        fstrm = owndev = FALSE;
    Packit 1c1d7e
        mapper = 0;
    Packit 1c1d7e
        d = new QTextStreamPrivate;
    Packit 1c1d7e
        doUnicodeHeader = TRUE;	 //default to autodetect
    Packit 1c1d7e
        latin1 = TRUE;		 // ### should use local?
    Packit 1c1d7e
        internalOrder = QChar::networkOrdered(); //default to network order
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Constructs a data stream that has no IO device.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream::QTextStream()
    Packit 1c1d7e
    {
    Packit 1c1d7e
        init();
    Packit 1c1d7e
        setEncoding( Locale ); //###
    Packit 1c1d7e
        reset();
    Packit 1c1d7e
        d->sourceType = QTextStreamPrivate::NotSet;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Constructs a text stream that uses the IO device \a iod.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream::QTextStream( QIODevice *iod )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        init();
    Packit 1c1d7e
        setEncoding( Locale ); //###
    Packit 1c1d7e
        dev = iod;					// set device
    Packit 1c1d7e
        reset();
    Packit 1c1d7e
        d->sourceType = QTextStreamPrivate::IODevice;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    // TODO: use special-case handling of this case in QTextStream, and
    Packit 1c1d7e
    //	 simplify this class to only deal with QChar or QString data.
    Packit 1c1d7e
    class QStringBuffer : public QIODevice {
    Packit 1c1d7e
    public:
    Packit 1c1d7e
        QStringBuffer( QString* str );
    Packit 1c1d7e
        ~QStringBuffer();
    Packit 1c1d7e
        bool  open( int m );
    Packit 1c1d7e
        void  close();
    Packit 1c1d7e
        void  flush();
    Packit 1c1d7e
        uint  size() const;
    Packit 1c1d7e
        int   at()   const;
    Packit 1c1d7e
        bool  at( int pos );
    Packit 1c1d7e
        int   readBlock( char *p, uint len );
    Packit 1c1d7e
        int writeBlock( const char *p, uint len );
    Packit 1c1d7e
        int   getch();
    Packit 1c1d7e
        int   putch( int ch );
    Packit 1c1d7e
        int   ungetch( int ch );
    Packit 1c1d7e
    protected:
    Packit 1c1d7e
        QString* s;
    Packit 1c1d7e
    Packit 1c1d7e
    private:        // Disabled copy constructor and operator=
    Packit 1c1d7e
        QStringBuffer( const QStringBuffer & );
    Packit 1c1d7e
        QStringBuffer &operator=( const QStringBuffer & );
    Packit 1c1d7e
    };
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    QStringBuffer::QStringBuffer( QString* str )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        s = str;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    QStringBuffer::~QStringBuffer()
    Packit 1c1d7e
    {
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    bool QStringBuffer::open( int m )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        if ( !s ) {
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
    	qWarning( "QStringBuffer::open: No string" );
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
    	return FALSE;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( isOpen() ) {                           // buffer already open
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
    	qWarning( "QStringBuffer::open: Buffer already open" );
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
    	return FALSE;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        setMode( m );
    Packit 1c1d7e
        if ( m & IO_Truncate ) {                    // truncate buffer
    Packit 1c1d7e
    	s->truncate( 0 );
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( m & IO_Append ) {                      // append to end of buffer
    Packit 1c1d7e
    	ioIndex = s->length()*(int)sizeof(QChar);
    Packit 1c1d7e
        } else {
    Packit 1c1d7e
    	ioIndex = 0;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        setState( IO_Open );
    Packit 1c1d7e
        setStatus( 0 );
    Packit 1c1d7e
        return TRUE;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    void QStringBuffer::close()
    Packit 1c1d7e
    {
    Packit 1c1d7e
        if ( isOpen() ) {
    Packit 1c1d7e
    	setFlags( IO_Direct );
    Packit 1c1d7e
    	ioIndex = 0;
    Packit 1c1d7e
        }
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    void QStringBuffer::flush()
    Packit 1c1d7e
    {
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    uint QStringBuffer::size() const
    Packit 1c1d7e
    {
    Packit 1c1d7e
        return s ? s->length()*(int)sizeof(QChar) : 0;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    int  QStringBuffer::at()   const
    Packit 1c1d7e
    {
    Packit 1c1d7e
        return ioIndex;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    bool QStringBuffer::at( int pos )
    Packit 1c1d7e
    {
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
        if ( !isOpen() ) {
    Packit 1c1d7e
    	qWarning( "QStringBuffer::at: Buffer is not open" );
    Packit 1c1d7e
    	return FALSE;
    Packit 1c1d7e
        }
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        if ( (uint)pos >= s->length()*2 ) {
    Packit 1c1d7e
    #if defined(CHECK_RANGE)
    Packit 1c1d7e
    	qWarning( "QStringBuffer::at: Index %d out of range", pos );
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
    	return FALSE;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        ioIndex = pos;
    Packit 1c1d7e
        return TRUE;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    int  QStringBuffer::readBlock( char *p, uint len )
    Packit 1c1d7e
    {
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
        CHECK_PTR( p );
    Packit 1c1d7e
        if ( !isOpen() ) {                          // buffer not open
    Packit 1c1d7e
    	qWarning( "QStringBuffer::readBlock: Buffer not open" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( !isReadable() ) {                      // reading not permitted
    Packit 1c1d7e
    	qWarning( "QStringBuffer::readBlock: Read operation not permitted" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        if ( (uint)ioIndex + len > s->length()*sizeof(QChar) ) {
    Packit 1c1d7e
    	// overflow
    Packit 1c1d7e
    	if ( (uint)ioIndex >= s->length()*sizeof(QChar) ) {
    Packit 1c1d7e
    	    setStatus( IO_ReadError );
    Packit 1c1d7e
    	    return -1;
    Packit 1c1d7e
    	} else {
    Packit 1c1d7e
    	    len = s->length()*2 - (uint)ioIndex;
    Packit 1c1d7e
    	}
    Packit 1c1d7e
        }
    Packit 1c1d7e
        memcpy( p, ((const char*)(s->unicode()))+ioIndex, len );
    Packit 1c1d7e
        ioIndex += len;
    Packit 1c1d7e
        return len;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    int QStringBuffer::writeBlock( const char *p, uint len )
    Packit 1c1d7e
    {
    Packit 1c1d7e
    #if defined(CHECK_NULL)
    Packit 1c1d7e
        if ( p == 0 && len != 0 )
    Packit 1c1d7e
    	qWarning( "QStringBuffer::writeBlock: Null pointer error" );
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
        if ( !isOpen() ) {                          // buffer not open
    Packit 1c1d7e
    	qWarning( "QStringBuffer::writeBlock: Buffer not open" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( !isWritable() ) {                      // writing not permitted
    Packit 1c1d7e
    	qWarning( "QStringBuffer::writeBlock: Write operation not permitted" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( ioIndex&1 ) {
    Packit 1c1d7e
    	qWarning( "QStringBuffer::writeBlock: non-even index - non Unicode" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( len&1 ) {
    Packit 1c1d7e
    	qWarning( "QStringBuffer::writeBlock: non-even length - non Unicode" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        s->replace(ioIndex/2, len/2, (QChar*)p, len/2);
    Packit 1c1d7e
        ioIndex += len;
    Packit 1c1d7e
        return len;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    int QStringBuffer::getch()
    Packit 1c1d7e
    {
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
        if ( !isOpen() ) {                          // buffer not open
    Packit 1c1d7e
    	qWarning( "QStringBuffer::getch: Buffer not open" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( !isReadable() ) {                      // reading not permitted
    Packit 1c1d7e
    	qWarning( "QStringBuffer::getch: Read operation not permitted" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        if ( (uint)ioIndex >= s->length()*2 ) {           // overflow
    Packit 1c1d7e
    	setStatus( IO_ReadError );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        return *((char*)s->unicode() + ioIndex++);
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    int QStringBuffer::putch( int ch )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        char c = ch;
    Packit 1c1d7e
        if ( writeBlock(&c,1) < 0 )
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        else
    Packit 1c1d7e
    	return ch;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    int QStringBuffer::ungetch( int ch )
    Packit 1c1d7e
    {
    Packit 1c1d7e
    #if defined(CHECK_STATE)
    Packit 1c1d7e
        if ( !isOpen() ) {                          // buffer not open
    Packit 1c1d7e
    	qWarning( "QStringBuffer::ungetch: Buffer not open" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        if ( !isReadable() ) {                      // reading not permitted
    Packit 1c1d7e
    	qWarning( "QStringBuffer::ungetch: Read operation not permitted" );
    Packit 1c1d7e
    	return -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        if ( ch != -1 ) { // something to do with eof
    Packit 1c1d7e
    	if ( ioIndex )
    Packit 1c1d7e
    	    ioIndex--;
    Packit 1c1d7e
    	else
    Packit 1c1d7e
    	    ch = -1;
    Packit 1c1d7e
        }
    Packit 1c1d7e
        return ch;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Constructs a text stream that operates on a Unicode QString through an
    Packit 1c1d7e
      internal device.
    Packit 1c1d7e
    Packit 1c1d7e
      If you set an encoding or codec with setEncoding() or setCodec(), this
    Packit 1c1d7e
      setting is ignored for text streams that operate on QString.
    Packit 1c1d7e
    Packit 1c1d7e
      Example:
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        QString str;
    Packit 1c1d7e
        QTextStream ts( &str, IO_WriteOnly );
    Packit 1c1d7e
        ts << "pi = " << 3.14;			// str == "pi = 3.14"
    Packit 1c1d7e
      \endcode
    Packit 1c1d7e
    Packit 1c1d7e
      Writing data to the text stream will modify the contents of the string.
    Packit 1c1d7e
      The string will be expanded when data is written beyond the end of the
    Packit 1c1d7e
      string. Note that the string will not be truncated:
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        QString str = "pi = 3.14";
    Packit 1c1d7e
        QTextStream ts( &str, IO_WriteOnly );
    Packit 1c1d7e
        ts <<  "2+2 = " << 2+2; 		// str == "2+2 = 414"
    Packit 1c1d7e
      \endcode
    Packit 1c1d7e
    Packit 1c1d7e
      Note that since QString is Unicode, you should not use readRawBytes()
    Packit 1c1d7e
      or writeRawBytes() on such a stream.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream::QTextStream( QString* str, int filemode )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        // TODO: optimize for this case as it becomes more common
    Packit 1c1d7e
        //        (see QStringBuffer above)
    Packit 1c1d7e
        init();
    Packit 1c1d7e
        dev = new QStringBuffer( str );
    Packit 1c1d7e
        ((QStringBuffer *)dev)->open( filemode );
    Packit 1c1d7e
        owndev = TRUE;
    Packit 1c1d7e
        setEncoding(RawUnicode);
    Packit 1c1d7e
        reset();
    Packit 1c1d7e
        d->sourceType = QTextStreamPrivate::String;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*! \obsolete
    Packit 1c1d7e
    Packit 1c1d7e
      This constructor is equivalent to the constructor taking a QString*
    Packit 1c1d7e
      parameter.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream::QTextStream( QString& str, int filemode )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        init();
    Packit 1c1d7e
        dev = new QStringBuffer( &str );
    Packit 1c1d7e
        ((QStringBuffer *)dev)->open( filemode );
    Packit 1c1d7e
        owndev = TRUE;
    Packit 1c1d7e
        setEncoding(RawUnicode);
    Packit 1c1d7e
        reset();
    Packit 1c1d7e
        d->sourceType = QTextStreamPrivate::String;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Constructs a text stream that operates on a byte array through an
    Packit 1c1d7e
      internal QBuffer device.
    Packit 1c1d7e
    Packit 1c1d7e
      Example:
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        QByteArray array;
    Packit 1c1d7e
        QTextStream ts( array, IO_WriteOnly );
    Packit 1c1d7e
        ts << "pi = " << 3.14 << '\0';		// array == "pi = 3.14"
    Packit 1c1d7e
      \endcode
    Packit 1c1d7e
    Packit 1c1d7e
      Writing data to the text stream will modify the contents of the array.
    Packit 1c1d7e
      The array will be expanded when data is written beyond the end of the
    Packit 1c1d7e
      string.
    Packit 1c1d7e
    Packit 1c1d7e
      Same example, using a QBuffer:
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        QByteArray array;
    Packit 1c1d7e
        QBuffer buf( array );
    Packit 1c1d7e
        buf.open( IO_WriteOnly );
    Packit 1c1d7e
        QTextStream ts( &buf );
    Packit 1c1d7e
        ts << "pi = " << 3.14 << '\0';		// array == "pi = 3.14"
    Packit 1c1d7e
        buf.close();
    Packit 1c1d7e
      \endcode
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream::QTextStream( QByteArray a, int mode )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        init();
    Packit 1c1d7e
        dev = new QBuffer( a );
    Packit 1c1d7e
        ((QBuffer *)dev)->open( mode );
    Packit 1c1d7e
        owndev = TRUE;
    Packit 1c1d7e
        setEncoding( Locale ); //### Locale???
    Packit 1c1d7e
        reset();
    Packit 1c1d7e
        d->sourceType = QTextStreamPrivate::ByteArray;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Constructs a text stream that operates on an existing file handle \e fh
    Packit 1c1d7e
      through an internal QFile device.
    Packit 1c1d7e
    Packit 1c1d7e
      Example:
    Packit 1c1d7e
      \code
    Packit 1c1d7e
        QTextStream cout( stdout, IO_WriteOnly );
    Packit 1c1d7e
        QTextStream cin ( stdin,  IO_ReadOnly );
    Packit 1c1d7e
        QTextStream cerr( stderr, IO_WriteOnly );
    Packit 1c1d7e
     \endcode
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream::QTextStream( FILE *fh, int mode )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        init();
    Packit 1c1d7e
        setEncoding( Locale ); //###
    Packit 1c1d7e
        dev = new QFile;
    Packit 1c1d7e
        ((QFile *)dev)->open( mode, fh );
    Packit 1c1d7e
        fstrm = owndev = TRUE;
    Packit 1c1d7e
        reset();
    Packit 1c1d7e
        d->sourceType = QTextStreamPrivate::File;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Destructs the text stream.
    Packit 1c1d7e
    Packit 1c1d7e
      The destructor does not affect the current IO device.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream::~QTextStream()
    Packit 1c1d7e
    {
    Packit 1c1d7e
        if ( owndev )
    Packit 1c1d7e
    	delete dev;
    Packit 1c1d7e
        delete d;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Positions the read pointer at the first non-whitespace character.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    void QTextStream::skipWhiteSpace()
    Packit 1c1d7e
    {
    Packit 1c1d7e
        ts_ungetc( eat_ws() );
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      \fn Encoding QTextStream::encoding() const
    Packit 1c1d7e
    Packit 1c1d7e
      Returns the encoding mode of the stream.
    Packit 1c1d7e
    Packit 1c1d7e
      \sa setEncoding()
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Tries to read len characters from the stream and stores them in \a buf.
    Packit 1c1d7e
      Returns the number of characters really read.
    Packit 1c1d7e
      Attention: There will no QEOF appended if the read reaches the end of
    Packit 1c1d7e
      the file. EOF is reached when the return value does not equal \a len.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    uint QTextStream::ts_getbuf( QChar* buf, uint len )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        if( len<1 )
    Packit 1c1d7e
    	return 0;
    Packit 1c1d7e
    Packit 1c1d7e
        uint rnum=0;   // the number of QChars really read
    Packit 1c1d7e
    Packit 1c1d7e
        if ( d && d->ungetcBuf.length() ) {
    Packit 1c1d7e
    	while( rnum < len && rnum < d->ungetcBuf.length() ) {
    Packit 1c1d7e
    	    buf[rnum] = d->ungetcBuf.constref(rnum);
    Packit 1c1d7e
    	    rnum++;
    Packit 1c1d7e
    	}
    Packit 1c1d7e
    	d->ungetcBuf = d->ungetcBuf.mid( rnum );
    Packit 1c1d7e
    	if ( rnum >= len )
    Packit 1c1d7e
    	    return rnum;
    Packit 1c1d7e
        }
    Packit 1c1d7e
    Packit 1c1d7e
        // we use dev->ungetch() for one of the bytes of the unicode
    Packit 1c1d7e
        // byte-order mark, but a local unget hack for the other byte:
    Packit 1c1d7e
        int ungetHack = EOF;
    Packit 1c1d7e
    Packit 1c1d7e
        if ( doUnicodeHeader ) {
    Packit 1c1d7e
    	doUnicodeHeader = FALSE; //only at the top
    Packit 1c1d7e
    	int c1 = dev->getch();
    Packit 1c1d7e
    	if ( c1 == EOF )
    Packit 1c1d7e
    	    return rnum;
    Packit 1c1d7e
    	int c2 = dev->getch();
    Packit 1c1d7e
    	if ( c1 == 0xfe && c2 == 0xff ) {
    Packit 1c1d7e
    	    mapper = 0;
    Packit 1c1d7e
    	    latin1 = FALSE;
    Packit 1c1d7e
    	    internalOrder = QChar::networkOrdered();   //network order
    Packit 1c1d7e
    	} else if ( c1 == 0xff && c2 == 0xfe ) {
    Packit 1c1d7e
    	    mapper = 0;
    Packit 1c1d7e
    	    latin1 = FALSE;
    Packit 1c1d7e
    	    internalOrder = !QChar::networkOrdered();   //reverse network order
    Packit 1c1d7e
    	} else {
    Packit 1c1d7e
    	    if ( c2 != EOF ) {
    Packit 1c1d7e
    	 	dev->ungetch( c2 );
    Packit 1c1d7e
    		ungetHack = c1;
    Packit 1c1d7e
    	    } else {
    Packit 1c1d7e
    	 	dev->ungetch( c1 );
    Packit 1c1d7e
    		// note that a small possible bug might hide here
    Packit 1c1d7e
    		// here, if only the first byte of a file has made it
    Packit 1c1d7e
    		// so far, and that first byte is half of the
    Packit 1c1d7e
    		// byte-order mark, then the utfness will not be
    Packit 1c1d7e
    		// detected.  whether or not this is a bug depends on
    Packit 1c1d7e
    		// taste.  I can't really decide.
    Packit 1c1d7e
    	    }
    Packit 1c1d7e
    	}
    Packit 1c1d7e
        }
    Packit 1c1d7e
    Packit 1c1d7e
    #ifndef QT_NO_TEXTCODEC
    Packit 1c1d7e
        if ( mapper ) {
    Packit 1c1d7e
    	bool shortRead = FALSE;
    Packit 1c1d7e
    	if ( !d->decoder )
    Packit 1c1d7e
    	    d->decoder = mapper->makeDecoder();
    Packit 1c1d7e
    	while( rnum < len ) {
    Packit 1c1d7e
    	    QString s;
    Packit 1c1d7e
    	    bool readBlock = !( len == 1+rnum );
    Packit 1c1d7e
    	    while ( TRUE ) {
    Packit 1c1d7e
    		// for efficiency: normally read a whole block
    Packit 1c1d7e
    		if ( readBlock ) {
    Packit 1c1d7e
    		    // guess buffersize; this may be wrong (too small or too
    Packit 1c1d7e
    		    // big). But we can handle this (either iterate reading
    Packit 1c1d7e
    		    // or use ungetcBuf).
    Packit 1c1d7e
    		    // Note that this might cause problems for codecs where
    Packit 1c1d7e
    		    // one byte can result in >1 Unicode Characters if bytes
    Packit 1c1d7e
    		    // are written to the stream in the meantime (loss of
    Packit 1c1d7e
    		    // synchronicity).
    Packit 1c1d7e
    		    uint rlen = len - rnum;
    Packit 1c1d7e
    		    char *cbuf = new char[ rlen ];
    Packit 1c1d7e
    		    if ( ungetHack != EOF ) {
    Packit 1c1d7e
    			rlen = 1+dev->readBlock( cbuf+1, rlen-1 );
    Packit 1c1d7e
    			cbuf[0] = (char)ungetHack;
    Packit 1c1d7e
    			ungetHack = EOF;
    Packit 1c1d7e
    		    } else {
    Packit 1c1d7e
    			rlen = dev->readBlock( cbuf, rlen );
    Packit 1c1d7e
    		    }
    Packit 1c1d7e
    		    s  += d->decoder->toUnicode( cbuf, rlen );
    Packit 1c1d7e
    		    delete[] cbuf;
    Packit 1c1d7e
    		    // use buffered reading only for the first time, because we
    Packit 1c1d7e
    		    // have to get the stream synchronous again (this is easier
    Packit 1c1d7e
    		    // with single character reading)
    Packit 1c1d7e
    		    readBlock = FALSE;
    Packit 1c1d7e
    		}
    Packit 1c1d7e
    		// get stream (and codec) in sync
    Packit 1c1d7e
    		int c;
    Packit 1c1d7e
    		if ( ungetHack == EOF ) {
    Packit 1c1d7e
    		    c = dev->getch();
    Packit 1c1d7e
    		} else {
    Packit 1c1d7e
    		    c = ungetHack;
    Packit 1c1d7e
    		    ungetHack = EOF;
    Packit 1c1d7e
    		}
    Packit 1c1d7e
    		if ( c == EOF ) {
    Packit 1c1d7e
    		    shortRead = TRUE;
    Packit 1c1d7e
    		    break;
    Packit 1c1d7e
    		}
    Packit 1c1d7e
    		char b = c;
    Packit 1c1d7e
    		uint lengthBefore = s.length();
    Packit 1c1d7e
    		s  += d->decoder->toUnicode( &b, 1 );
    Packit 1c1d7e
    		if ( s.length() > lengthBefore )
    Packit 1c1d7e
    		    break; // it seems we are in sync now
    Packit 1c1d7e
    	    }
    Packit 1c1d7e
    	    uint i = 0;
    Packit 1c1d7e
    	    while( rnum < len && i < s.length() )
    Packit 1c1d7e
    		buf[rnum++] = s.constref(i++);
    Packit 1c1d7e
    	    if ( s.length() > i )
    Packit 1c1d7e
    		// could be = but append is clearer
    Packit 1c1d7e
    		d->ungetcBuf.append( s.mid( i ) );
    Packit 1c1d7e
    	    if ( shortRead )
    Packit 1c1d7e
    		return rnum;
    Packit 1c1d7e
    	}
    Packit 1c1d7e
        } else
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        if ( latin1 ) {
    Packit 1c1d7e
    	if ( len == 1+rnum ) {
    Packit 1c1d7e
    	    // use this method for one character because it is more efficient
    Packit 1c1d7e
    	    // (arnt doubts whether it makes a difference, but lets it stand)
    Packit 1c1d7e
    	    int c = (ungetHack == EOF) ? dev->getch() : ungetHack;
    Packit 1c1d7e
    	    if ( c != EOF )
    Packit 1c1d7e
    		buf[rnum++] = (char)c;
    Packit 1c1d7e
    	} else {
    Packit 1c1d7e
    	    if ( ungetHack != EOF ) {
    Packit 1c1d7e
    		buf[rnum++] = (char)ungetHack;
    Packit 1c1d7e
    		ungetHack = EOF;
    Packit 1c1d7e
    	    }
    Packit 1c1d7e
    	    char *cbuf = new char[len - rnum];
    Packit 1c1d7e
    	    while ( !dev->atEnd() && rnum < len ) {
    Packit 1c1d7e
    		uint rlen = len - rnum;
    Packit 1c1d7e
    		rlen = dev->readBlock( cbuf, rlen );
    Packit 1c1d7e
    		uint i = 0;
    Packit 1c1d7e
    		while( i < rlen )
    Packit 1c1d7e
    		    buf[rnum++] = cbuf[i++];
    Packit 1c1d7e
    	    }
    Packit 1c1d7e
    	    delete[] cbuf;
    Packit 1c1d7e
    	}
    Packit 1c1d7e
        } else { // UCS-2 or UTF-16
    Packit 1c1d7e
    	if ( len == 1+rnum ) {
    Packit 1c1d7e
    	    int c1 = (ungetHack == EOF) ? dev->getch() : ungetHack;
    Packit 1c1d7e
    	    if ( c1 == EOF )
    Packit 1c1d7e
    		return rnum;
    Packit 1c1d7e
    	    int c2 = dev->getch();
    Packit 1c1d7e
    	    if ( c2 == EOF )
    Packit 1c1d7e
    		return rnum;
    Packit 1c1d7e
    	    if ( isNetworkOrder() )
    Packit 1c1d7e
    		buf[rnum++] = QChar( c2, c1 );
    Packit 1c1d7e
    	    else
    Packit 1c1d7e
    		buf[rnum++] = QChar( c1, c2 );
    Packit 1c1d7e
    	} else {
    Packit 1c1d7e
    	    char *cbuf = new char[ 2*( len - rnum ) ]; // for paranoids: overflow possible
    Packit 1c1d7e
    	    while ( !dev->atEnd() && rnum < len ) {
    Packit 1c1d7e
    		uint rlen = 2 * ( len-rnum );
    Packit 1c1d7e
    		if ( ungetHack != EOF ) {
    Packit 1c1d7e
    		    rlen = 1+dev->readBlock( cbuf+1, rlen-1 );
    Packit 1c1d7e
    		    cbuf[0] = (char)ungetHack;
    Packit 1c1d7e
    		    ungetHack = EOF;
    Packit 1c1d7e
    		} else {
    Packit 1c1d7e
    		    rlen = dev->readBlock( cbuf, rlen );
    Packit 1c1d7e
    		}
    Packit 1c1d7e
    		// We can't use an odd number of bytes, so put it back. But
    Packit 1c1d7e
    		// do it only if we are capable of reading more -- normally
    Packit 1c1d7e
    		// there should not be an odd number, but the file might be
    Packit 1c1d7e
    		// truncated or not in UTF-16...
    Packit 1c1d7e
    		if ( (rlen & 1) == 1 )
    Packit 1c1d7e
    		    if ( !dev->atEnd() )
    Packit 1c1d7e
    			dev->ungetch( cbuf[--rlen] );
    Packit 1c1d7e
    		uint i = 0;
    Packit 1c1d7e
    		if ( isNetworkOrder() ) {
    Packit 1c1d7e
    		    while( i < rlen ) {
    Packit 1c1d7e
    			buf[rnum++] = QChar( cbuf[i+1], cbuf[i] );
    Packit 1c1d7e
    			i+=2;
    Packit 1c1d7e
    		    }
    Packit 1c1d7e
    		} else {
    Packit 1c1d7e
    		    while( i < rlen ) {
    Packit 1c1d7e
    			buf[rnum++] = QChar( cbuf[i], cbuf[i+1] );
    Packit 1c1d7e
    			i+=2;
    Packit 1c1d7e
    		    }
    Packit 1c1d7e
    		}
    Packit 1c1d7e
    	    }
    Packit 1c1d7e
    	    delete[] cbuf;
    Packit 1c1d7e
    	}
    Packit 1c1d7e
        }
    Packit 1c1d7e
        return rnum;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Puts one character to the stream.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    void QTextStream::ts_putc( QChar c )
    Packit 1c1d7e
    {
    Packit 1c1d7e
    #ifndef QT_NO_TEXTCODEC
    Packit 1c1d7e
        if ( mapper ) {
    Packit 1c1d7e
    	int len = 1;
    Packit 1c1d7e
    	QString s = c;
    Packit 1c1d7e
    	QCString block = mapper->fromUnicode( s, len );
    Packit 1c1d7e
    	dev->writeBlock( block, len );
    Packit 1c1d7e
        } else
    Packit 1c1d7e
    #endif
    Packit 1c1d7e
        if ( latin1 ) {
    Packit 1c1d7e
    	if( c.row() )
    Packit 1c1d7e
    	    dev->putch( '?' ); //######unknown character???
    Packit 1c1d7e
    	else
    Packit 1c1d7e
    	    dev->putch( c.cell() );
    Packit 1c1d7e
        } else {
    Packit 1c1d7e
    	if ( doUnicodeHeader ) {
    Packit 1c1d7e
    	    doUnicodeHeader = FALSE;
    Packit 1c1d7e
    	    ts_putc( QChar::byteOrderMark );
    Packit 1c1d7e
    	}
    Packit 1c1d7e
    	if ( internalOrder ) {
    Packit 1c1d7e
    	    dev->writeBlock( (char*)&c, sizeof(QChar) );
    Packit 1c1d7e
    	} else if ( isNetworkOrder() ) {
    Packit 1c1d7e
    	    dev->putch(c.row());
    Packit 1c1d7e
    	    dev->putch(c.cell());
    Packit 1c1d7e
    	} else {
    Packit 1c1d7e
    	    dev->putch(c.cell());
    Packit 1c1d7e
    	    dev->putch(c.row());
    Packit 1c1d7e
    	}
    Packit 1c1d7e
        }
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Puts one character to the stream.
    Packit 1c1d7e
    */
    Packit 1c1d7e
    void QTextStream::ts_putc(int ch)
    Packit 1c1d7e
    {
    Packit 1c1d7e
        ts_putc(QChar((ushort)ch));
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    bool QTextStream::ts_isdigit(QChar c)
    Packit 1c1d7e
    {
    Packit 1c1d7e
        return c.isDigit();
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    bool QTextStream::ts_isspace( QChar c )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        return c.isSpace();
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    void QTextStream::ts_ungetc( QChar c )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        if ( c.unicode() == 0xffff )
    Packit 1c1d7e
    	return;
    Packit 1c1d7e
    Packit 1c1d7e
        d->ungetcBuf.prepend( c );
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Reads \e len bytes from the stream into \e e s and returns a reference to
    Packit 1c1d7e
      the stream.
    Packit 1c1d7e
    Packit 1c1d7e
      The buffer \e s must be preallocated.
    Packit 1c1d7e
    Packit 1c1d7e
      Note that no encoding is done by this function.
    Packit 1c1d7e
    Packit 1c1d7e
      \warning The behaviour of this function is undefined unless the
    Packit 1c1d7e
      stream's encoding is set to Unicode or Latin1.
    Packit 1c1d7e
    Packit 1c1d7e
      \sa QIODevice::readBlock()
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream &QTextStream::readRawBytes( char *s, uint len )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        dev->readBlock( s, len );
    Packit 1c1d7e
        return *this;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Writes the \e len bytes from \e s to the stream and returns a reference to
    Packit 1c1d7e
      the stream.
    Packit 1c1d7e
    Packit 1c1d7e
      Note that no encoding is done by this function.
    Packit 1c1d7e
    Packit 1c1d7e
      \sa QIODevice::writeBlock()
    Packit 1c1d7e
    */
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream &QTextStream::writeRawBytes( const char* s, uint len )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        dev->writeBlock( s, len );
    Packit 1c1d7e
        return *this;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream &QTextStream::writeBlock( const char* p, uint len )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        if ( doUnicodeHeader ) {
    Packit 1c1d7e
    	doUnicodeHeader = FALSE;
    Packit 1c1d7e
    	if ( !mapper && !latin1 )
    Packit 1c1d7e
    	    ts_putc( QChar::byteOrderMark );
    Packit 1c1d7e
        }
    Packit 1c1d7e
        //All QCStrings and const char* are defined to be in Latin1
    Packit 1c1d7e
        if ( !mapper && latin1 ) {
    Packit 1c1d7e
    	dev->writeBlock( p, len );
    Packit 1c1d7e
        } else if ( !mapper && internalOrder ) {
    Packit 1c1d7e
    	QChar *u = new QChar[len];
    Packit 1c1d7e
    	for (uint i=0; i
    Packit 1c1d7e
    	    u[i] = p[i];
    Packit 1c1d7e
    	dev->writeBlock( (char*)u, len*(int)sizeof(QChar) );
    Packit 1c1d7e
    	delete [] u;
    Packit 1c1d7e
        } else {
    Packit 1c1d7e
    	for (uint i=0; i
    Packit 1c1d7e
    	    ts_putc( (uchar)p[i] );
    Packit 1c1d7e
        }
    Packit 1c1d7e
        return *this;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    QTextStream &QTextStream::writeBlock( const QChar* p, uint len )
    Packit 1c1d7e
    {
    Packit 1c1d7e
        if ( !mapper && !latin1 && internalOrder ) {
    Packit 1c1d7e
    	if ( doUnicodeHeader ) {
    Packit 1c1d7e
    	    doUnicodeHeader = FALSE;
    Packit 1c1d7e
    	    ts_putc( QChar::byteOrderMark );
    Packit 1c1d7e
    	}
    Packit 1c1d7e
    	dev->writeBlock( (char*)p, (int)sizeof(QChar)*len );
    Packit 1c1d7e
        } else {
    Packit 1c1d7e
    	for (uint i=0; i
    Packit 1c1d7e
    	    ts_putc( p[i] );
    Packit 1c1d7e
        }
    Packit 1c1d7e
        return *this;
    Packit 1c1d7e
    }
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    Packit 1c1d7e
    /*!
    Packit 1c1d7e
      Resets the text stream.
    Packit 1c1d7e
    Packit 1c1d7e
      
      Packit 1c1d7e
        
    • All flags are set to 0.
    • Packit 1c1d7e
        
    • The field width is set to 0.
    • Packit 1c1d7e
        
    • The fill character is set to ' ' (space).
    • Packit 1c1d7e
        
    • The precision is set to 6.
    • Packit 1c1d7e
        
      Packit 1c1d7e
      Packit 1c1d7e
        \sa setf(), width(), fill(), precision()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      void QTextStream::reset()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          fflags = 0;
      Packit 1c1d7e
          fwidth = 0;
      Packit 1c1d7e
          fillchar = ' ';
      Packit 1c1d7e
          fprec = 6;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        \fn QIODevice *QTextStream::device() const
      Packit 1c1d7e
        Returns the IO device currently set.
      Packit 1c1d7e
        \sa setDevice(), unsetDevice()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Sets the IO device to \a iod.
      Packit 1c1d7e
        \sa device(), unsetDevice()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      void QTextStream::setDevice( QIODevice *iod )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          if ( owndev ) {
      Packit 1c1d7e
      	delete dev;
      Packit 1c1d7e
      	owndev = FALSE;
      Packit 1c1d7e
          }
      Packit 1c1d7e
          dev = iod;
      Packit 1c1d7e
          d->sourceType = QTextStreamPrivate::IODevice;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Unsets the IO device.	 Equivalent to setDevice( 0 ).
      Packit 1c1d7e
        \sa device(), setDevice()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      void QTextStream::unsetDevice()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          setDevice( 0 );
      Packit 1c1d7e
          d->sourceType = QTextStreamPrivate::NotSet;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        \fn bool QTextStream::atEnd() const
      Packit 1c1d7e
        Returns TRUE if the IO device has reached the end position (end of
      Packit 1c1d7e
        stream or file) or if there is no IO device set.
      Packit 1c1d7e
      Packit 1c1d7e
        Returns FALSE if the current position of the read/write head of the IO
      Packit 1c1d7e
        device is somewhere before the end position.
      Packit 1c1d7e
      Packit 1c1d7e
        \sa QIODevice::atEnd()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      /*!\fn bool QTextStream::eof() const
      Packit 1c1d7e
      Packit 1c1d7e
        \obsolete
      Packit 1c1d7e
      Packit 1c1d7e
        This function has been renamed to atEnd().
      Packit 1c1d7e
      Packit 1c1d7e
        \sa QIODevice::atEnd()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      /*****************************************************************************
      Packit 1c1d7e
        QTextStream read functions
      Packit 1c1d7e
       *****************************************************************************/
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a \c char from the stream and returns a reference to the stream.
      Packit 1c1d7e
        Note that whitespace is skipped.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( char &c )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          c = eat_ws();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a \c char from the stream and returns a reference to the stream.
      Packit 1c1d7e
        Note that whitespace is \e not skipped.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( QChar &c )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          c = ts_getc();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      ulong QTextStream::input_bin()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          ulong val = 0;
      Packit 1c1d7e
          QChar ch = eat_ws();
      Packit 1c1d7e
          int dv = ch.digitValue();
      Packit 1c1d7e
          while (  dv == 0 || dv == 1 ) {
      Packit 1c1d7e
      	val = ( val << 1 ) + dv;
      Packit 1c1d7e
      	ch = ts_getc();
      Packit 1c1d7e
      	dv = ch.digitValue();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          if ( ch != QEOF )
      Packit 1c1d7e
      	ts_ungetc( ch );
      Packit 1c1d7e
          return val;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      ulong QTextStream::input_oct()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          ulong val = 0;
      Packit 1c1d7e
          QChar ch = eat_ws();
      Packit 1c1d7e
          int dv = ch.digitValue();
      Packit 1c1d7e
          while ( dv >= 0 && dv <= 7 ) {
      Packit 1c1d7e
      	val = ( val << 3 ) + dv;
      Packit 1c1d7e
      	ch = ts_getc();
      Packit 1c1d7e
      	dv = ch.digitValue();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          if ( dv == 8 || dv == 9 ) {
      Packit 1c1d7e
      	while ( ts_isdigit(ch) )
      Packit 1c1d7e
      	    ch = ts_getc();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          if ( ch != QEOF )
      Packit 1c1d7e
      	ts_ungetc( ch );
      Packit 1c1d7e
          return val;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      ulong QTextStream::input_dec()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          ulong val = 0;
      Packit 1c1d7e
          QChar ch = eat_ws();
      Packit 1c1d7e
          int dv = ch.digitValue();
      Packit 1c1d7e
          while ( ts_isdigit(ch) ) {
      Packit 1c1d7e
      	val = val * 10 + dv;
      Packit 1c1d7e
      	ch = ts_getc();
      Packit 1c1d7e
      	dv = ch.digitValue();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          if ( ch != QEOF )
      Packit 1c1d7e
      	ts_ungetc( ch );
      Packit 1c1d7e
          return val;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      ulong QTextStream::input_hex()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          ulong val = 0;
      Packit 1c1d7e
          QChar ch = eat_ws();
      Packit 1c1d7e
          char c = ch;
      Packit 1c1d7e
          while ( isxdigit(c) ) {
      Packit 1c1d7e
      	val <<= 4;
      Packit 1c1d7e
      	if ( ts_isdigit(c) )
      Packit 1c1d7e
      	    val += c - '0';
      Packit 1c1d7e
      	else
      Packit 1c1d7e
      	    val += 10 + tolower(c) - 'a';
      Packit 1c1d7e
      	c = ch = ts_getc();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          if ( ch != QEOF )
      Packit 1c1d7e
      	ts_ungetc( ch );
      Packit 1c1d7e
          return val;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      long QTextStream::input_int()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          long val;
      Packit 1c1d7e
          QChar ch;
      Packit 1c1d7e
          char c;
      Packit 1c1d7e
          switch ( flags() & basefield ) {
      Packit 1c1d7e
          case bin:
      Packit 1c1d7e
      	val = (long)input_bin();
      Packit 1c1d7e
      	break;
      Packit 1c1d7e
          case oct:
      Packit 1c1d7e
      	val = (long)input_oct();
      Packit 1c1d7e
      	break;
      Packit 1c1d7e
          case dec:
      Packit 1c1d7e
      	c = ch = eat_ws();
      Packit 1c1d7e
      	if ( ch == QEOF ) {
      Packit 1c1d7e
      	    val = 0;
      Packit 1c1d7e
      	} else {
      Packit 1c1d7e
      	    if ( !(c == '-' || c == '+') )
      Packit 1c1d7e
      		ts_ungetc( ch );
      Packit 1c1d7e
      	    if ( c == '-' ) {
      Packit 1c1d7e
      		ulong v = input_dec();
      Packit 1c1d7e
      		if ( v ) {		// ensure that LONG_MIN can be read
      Packit 1c1d7e
      		    v--;
      Packit 1c1d7e
      		    val = -((long)v) - 1;
      Packit 1c1d7e
      		} else {
      Packit 1c1d7e
      		    val = 0;
      Packit 1c1d7e
      		}
      Packit 1c1d7e
      	    } else {
      Packit 1c1d7e
      		val = (long)input_dec();
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	break;
      Packit 1c1d7e
          case hex:
      Packit 1c1d7e
      	val = (long)input_hex();
      Packit 1c1d7e
      	break;
      Packit 1c1d7e
          default:
      Packit 1c1d7e
      	val = 0;
      Packit 1c1d7e
      	c = ch = eat_ws();
      Packit 1c1d7e
      	if ( c == '0' ) {		// bin, oct or hex
      Packit 1c1d7e
      	    c = ch = ts_getc();
      Packit 1c1d7e
      	    if ( tolower(c) == 'x' )
      Packit 1c1d7e
      		val = (long)input_hex();
      Packit 1c1d7e
      	    else if ( tolower(c) == 'b' )
      Packit 1c1d7e
      		val = (long)input_bin();
      Packit 1c1d7e
      	    else {			// octal
      Packit 1c1d7e
      		ts_ungetc( ch );
      Packit 1c1d7e
      		if ( c >= '0' && c <= '7' ) {
      Packit 1c1d7e
      		    val = (long)input_oct();
      Packit 1c1d7e
      		} else {
      Packit 1c1d7e
      		    val = 0;
      Packit 1c1d7e
      		}
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	} else if ( ts_isdigit(ch) ) {
      Packit 1c1d7e
      	    ts_ungetc( ch );
      Packit 1c1d7e
      	    val = (long)input_dec();
      Packit 1c1d7e
      	} else if ( c == '-' || c == '+' ) {
      Packit 1c1d7e
      	    ulong v = input_dec();
      Packit 1c1d7e
      	    if ( c == '-' ) {
      Packit 1c1d7e
      		if ( v ) {		// ensure that LONG_MIN can be read
      Packit 1c1d7e
      		    v--;
      Packit 1c1d7e
      		    val = -((long)v) - 1;
      Packit 1c1d7e
      		} else {
      Packit 1c1d7e
      		    val = 0;
      Packit 1c1d7e
      		}
      Packit 1c1d7e
      	    } else {
      Packit 1c1d7e
      		val = (long)v;
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	}
      Packit 1c1d7e
          }
      Packit 1c1d7e
          return val;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      //
      Packit 1c1d7e
      // We use a table-driven FSM to parse floating point numbers
      Packit 1c1d7e
      // strtod() cannot be used directly since we're reading from a QIODevice
      Packit 1c1d7e
      //
      Packit 1c1d7e
      Packit 1c1d7e
      double QTextStream::input_double()
      Packit 1c1d7e
      {
      Packit 1c1d7e
          const int Init	 = 0;			// states
      Packit 1c1d7e
          const int Sign	 = 1;
      Packit 1c1d7e
          const int Mantissa	 = 2;
      Packit 1c1d7e
          const int Dot	 = 3;
      Packit 1c1d7e
          const int Abscissa	 = 4;
      Packit 1c1d7e
          const int ExpMark	 = 5;
      Packit 1c1d7e
          const int ExpSign	 = 6;
      Packit 1c1d7e
          const int Exponent	 = 7;
      Packit 1c1d7e
          const int Done	 = 8;
      Packit 1c1d7e
      Packit 1c1d7e
          const int InputSign	 = 1;			// input tokens
      Packit 1c1d7e
          const int InputDigit = 2;
      Packit 1c1d7e
          const int InputDot	 = 3;
      Packit 1c1d7e
          const int InputExp	 = 4;
      Packit 1c1d7e
      Packit 1c1d7e
          static uchar table[8][5] = {
      Packit 1c1d7e
           /* None	 InputSign   InputDigit InputDot InputExp */
      Packit 1c1d7e
      	{ 0,	    Sign,     Mantissa,	 Dot,	   0,	   }, // Init
      Packit 1c1d7e
      	{ 0,	    0,	      Mantissa,	 Dot,	   0,	   }, // Sign
      Packit 1c1d7e
      	{ Done,	    Done,     Mantissa,	 Dot,	   ExpMark,}, // Mantissa
      Packit 1c1d7e
      	{ 0,	    0,	      Abscissa,	 0,	   0,	   }, // Dot
      Packit 1c1d7e
      	{ Done,	    Done,     Abscissa,	 Done,	   ExpMark,}, // Abscissa
      Packit 1c1d7e
      	{ 0,	    ExpSign,  Exponent,	 0,	   0,	   }, // ExpMark
      Packit 1c1d7e
      	{ 0,	    0,	      Exponent,	 0,	   0,	   }, // ExpSign
      Packit 1c1d7e
      	{ Done,	    Done,     Exponent,	 Done,	   Done	   }  // Exponent
      Packit 1c1d7e
          };
      Packit 1c1d7e
      Packit 1c1d7e
          int state = Init;				// parse state
      Packit 1c1d7e
          int input;					// input token
      Packit 1c1d7e
      Packit 1c1d7e
          char buf[256];
      Packit 1c1d7e
          int i = 0;
      Packit 1c1d7e
          QChar c = eat_ws();
      Packit 1c1d7e
      Packit 1c1d7e
          while ( TRUE ) {
      Packit 1c1d7e
      Packit 1c1d7e
      	switch ( c ) {
      Packit 1c1d7e
      	    case '+':
      Packit 1c1d7e
      	    case '-':
      Packit 1c1d7e
      		input = InputSign;
      Packit 1c1d7e
      		break;
      Packit 1c1d7e
      	    case '0': case '1': case '2': case '3': case '4':
      Packit 1c1d7e
      	    case '5': case '6': case '7': case '8': case '9':
      Packit 1c1d7e
      		input = InputDigit;
      Packit 1c1d7e
      		break;
      Packit 1c1d7e
      	    case '.':
      Packit 1c1d7e
      		input = InputDot;
      Packit 1c1d7e
      		break;
      Packit 1c1d7e
      	    case 'e':
      Packit 1c1d7e
      	    case 'E':
      Packit 1c1d7e
      		input = InputExp;
      Packit 1c1d7e
      		break;
      Packit 1c1d7e
      	    default:
      Packit 1c1d7e
      		input = 0;
      Packit 1c1d7e
      		break;
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      Packit 1c1d7e
      	state = table[state][input];
      Packit 1c1d7e
      Packit 1c1d7e
      	if  ( state == 0 || state == Done || i > 250 ) {
      Packit 1c1d7e
      	    if ( i > 250 ) {			// ignore rest of digits
      Packit 1c1d7e
      		do { c = ts_getc(); } while ( c != QEOF && ts_isdigit(c) );
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    if ( c != QEOF )
      Packit 1c1d7e
      		ts_ungetc( c );
      Packit 1c1d7e
      	    buf[i] = '\0';
      Packit 1c1d7e
      	    char *end;
      Packit 1c1d7e
      	    return strtod( buf, &end );
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      Packit 1c1d7e
      	buf[i++] = c;
      Packit 1c1d7e
      	c = ts_getc();
      Packit 1c1d7e
          }
      Packit 1c1d7e
      Packit 1c1d7e
      #if !defined(_CC_EGG_)
      Packit 1c1d7e
          return 0.0;
      Packit 1c1d7e
      #endif
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a signed \c short integer from the stream and returns a reference to
      Packit 1c1d7e
        the stream. See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( signed short &i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          i = (signed short)input_int();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads an unsigned \c short integer from the stream and returns a reference to
      Packit 1c1d7e
        the stream. See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( unsigned short &i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          i = (unsigned short)input_int();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a signed \c int from the stream and returns a reference to the
      Packit 1c1d7e
        stream. See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( signed int &i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          i = (signed int)input_int();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads an unsigned \c int from the stream and returns a reference to the
      Packit 1c1d7e
        stream. See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( unsigned int &i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          i = (unsigned int)input_int();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a signed \c long int from the stream and returns a reference to the
      Packit 1c1d7e
        stream. See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( signed long &i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          i = (signed long)input_int();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads an unsigned \c long int from the stream and returns a reference to the
      Packit 1c1d7e
        stream. See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( unsigned long &i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          i = (unsigned long)input_int();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a \c float from the stream and returns a reference to the stream.
      Packit 1c1d7e
        See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( float &f )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          f = (float)input_double();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a \c double from the stream and returns a reference to the stream.
      Packit 1c1d7e
        See flags() for an explanation of expected input format.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( double &f )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          f = input_double();
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a word from the stream and returns a reference to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( char *s )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          int maxlen = width( 0 );
      Packit 1c1d7e
          QChar c = eat_ws();
      Packit 1c1d7e
          if ( !maxlen )
      Packit 1c1d7e
      	maxlen = -1;
      Packit 1c1d7e
          while ( c != QEOF ) {
      Packit 1c1d7e
      	if ( ts_isspace(c) || maxlen-- == 0 ) {
      Packit 1c1d7e
      	    ts_ungetc( c );
      Packit 1c1d7e
      	    break;
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	*s++ = c;
      Packit 1c1d7e
      	c = ts_getc();
      Packit 1c1d7e
          }
      Packit 1c1d7e
      Packit 1c1d7e
          *s = '\0';
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a word from the stream and returns a reference to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( QString &str )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          str=QString::fromLatin1("");
      Packit 1c1d7e
          QChar	c = eat_ws();
      Packit 1c1d7e
      Packit 1c1d7e
          while ( c != QEOF ) {
      Packit 1c1d7e
      	if ( ts_isspace(c) ) {
      Packit 1c1d7e
      	    ts_ungetc( c );
      Packit 1c1d7e
      	    break;
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	str += c;
      Packit 1c1d7e
      	c = ts_getc();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a word from the stream and returns a reference to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator>>( QCString &str )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          QCString  *dynbuf = 0;
      Packit 1c1d7e
          const int buflen = 256;
      Packit 1c1d7e
          char      buffer[buflen];
      Packit 1c1d7e
          char     *s = buffer;
      Packit 1c1d7e
          int	      i = 0;
      Packit 1c1d7e
          QChar	      c = eat_ws();
      Packit 1c1d7e
      Packit 1c1d7e
          while ( c != QEOF ) {
      Packit 1c1d7e
      	if ( ts_isspace(c) ) {
      Packit 1c1d7e
      	    ts_ungetc( c );
      Packit 1c1d7e
      	    break;
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	if ( i >= buflen-1 ) {
      Packit 1c1d7e
      	    if ( !dynbuf )  {			// create dynamic buffer
      Packit 1c1d7e
      		dynbuf = new QCString(buflen*2);
      Packit 1c1d7e
      		memcpy( dynbuf->rawData(), s, i );	// copy old data
      Packit 1c1d7e
      	    } else if ( i >= (int)dynbuf->size()-1 ) {
      Packit 1c1d7e
      		dynbuf->resize( dynbuf->size()*2 );
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    s = dynbuf->rawData();
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	s[i++] = c;
      Packit 1c1d7e
      	c = ts_getc();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          str.resize( i+1 );
      Packit 1c1d7e
          memcpy( str.rawData(), s, i );
      Packit 1c1d7e
          delete dynbuf;
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads a line from the stream and returns a string containing the text.
      Packit 1c1d7e
      Packit 1c1d7e
        The returned string does not contain any trailing newline or carriage
      Packit 1c1d7e
        return. Note that this is different from QIODevice::readLine(), which
      Packit 1c1d7e
        does not strip the newline at the end of the line.
      Packit 1c1d7e
      Packit 1c1d7e
        On EOF you will get a QString that is null. On reading an empty line the
      Packit 1c1d7e
        returned QString is empty but not null.
      Packit 1c1d7e
      Packit 1c1d7e
        \sa QIODevice::readLine()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QString QTextStream::readLine()
      Packit 1c1d7e
      {
      Packit 1c1d7e
      #if defined(CHECK_STATE)
      Packit 1c1d7e
          if ( !dev ) {
      Packit 1c1d7e
      	qWarning( "QTextStream::readLine: No device" );
      Packit 1c1d7e
      	return QString::null;
      Packit 1c1d7e
          }
      Packit 1c1d7e
      #endif
      Packit 1c1d7e
          QString result( "" );
      Packit 1c1d7e
          const int buf_size = 256;
      Packit 1c1d7e
          QChar c[buf_size];
      Packit 1c1d7e
          int pos = 0;
      Packit 1c1d7e
      Packit 1c1d7e
          c[pos] = ts_getc();
      Packit 1c1d7e
          if ( c[pos] == QEOF )
      Packit 1c1d7e
      	return QString::null;
      Packit 1c1d7e
      Packit 1c1d7e
          while ( c[pos] != QEOF && c[pos] != '\n' ) {
      Packit 1c1d7e
      	pos++;
      Packit 1c1d7e
      	if ( pos >= buf_size ) {
      Packit 1c1d7e
      	    result += QString( c, pos );
      Packit 1c1d7e
      	    pos = 0;
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	c[pos] = ts_getc();
      Packit 1c1d7e
          }
      Packit 1c1d7e
          result += QString( c, pos );
      Packit 1c1d7e
      Packit 1c1d7e
          int len = (int)result.length();
      Packit 1c1d7e
          if ( len && result[len-1] == '\r' )
      Packit 1c1d7e
      	result.truncate(len-1); // (if there are two \r, let one stay)
      Packit 1c1d7e
      Packit 1c1d7e
          return result;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Reads the entire stream and returns a string containing the text.
      Packit 1c1d7e
      Packit 1c1d7e
        \sa QIODevice::readLine()
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QString QTextStream::read()
      Packit 1c1d7e
      {
      Packit 1c1d7e
      #if defined(CHECK_STATE)
      Packit 1c1d7e
          if ( !dev ) {
      Packit 1c1d7e
      	qWarning( "QTextStream::read: No device" );
      Packit 1c1d7e
      	return QString::null;
      Packit 1c1d7e
          }
      Packit 1c1d7e
      #endif
      Packit 1c1d7e
          QString    result;
      Packit 1c1d7e
          const uint bufsize = 512;
      Packit 1c1d7e
          QChar      buf[bufsize];
      Packit 1c1d7e
          uint       i, num, start;
      Packit 1c1d7e
          bool       skipped_cr = FALSE;
      Packit 1c1d7e
      Packit 1c1d7e
          while ( 1 ) {
      Packit 1c1d7e
      	num = ts_getbuf(buf,bufsize);
      Packit 1c1d7e
      	// do a s/\r\n/\n
      Packit 1c1d7e
      	start = 0;
      Packit 1c1d7e
      	for ( i=0; i
      Packit 1c1d7e
      	    if ( buf[i] == '\r' ) {
      Packit 1c1d7e
      		// Only skip single cr's preceding lf's
      Packit 1c1d7e
      		if ( skipped_cr ) {
      Packit 1c1d7e
      		    result += buf[i];
      Packit 1c1d7e
      		    start++;
      Packit 1c1d7e
      		} else {
      Packit 1c1d7e
      		    result += QString( &buf[start], i-start );
      Packit 1c1d7e
      		    start = i+1;
      Packit 1c1d7e
      		    skipped_cr = TRUE;
      Packit 1c1d7e
      		}
      Packit 1c1d7e
      	    } else {
      Packit 1c1d7e
      		if ( skipped_cr ) {
      Packit 1c1d7e
      		    if ( buf[i] != '\n' ) {
      Packit 1c1d7e
      			// Should not have skipped it
      Packit 1c1d7e
      			result += '\r';
      Packit 1c1d7e
      		    }
      Packit 1c1d7e
      		    skipped_cr = FALSE;
      Packit 1c1d7e
      		}
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	if ( start < num )
      Packit 1c1d7e
      	    result += QString( &buf[start], i-start );
      Packit 1c1d7e
      	if ( num != bufsize ) // if ( EOF )
      Packit 1c1d7e
      	    break;
      Packit 1c1d7e
          }
      Packit 1c1d7e
          return result;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*****************************************************************************
      Packit 1c1d7e
        QTextStream write functions
      Packit 1c1d7e
       *****************************************************************************/
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a \c char to the stream and returns a reference to the stream.
      Packit 1c1d7e
      Packit 1c1d7e
        The character \a c is assumed to be Latin1 encoded independent of the Encoding set
      Packit 1c1d7e
        for the QTextStream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( QChar c )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          ts_putc( c );
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a \c char to the stream and returns a reference to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( char c )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          unsigned char uc = (unsigned char) c;
      Packit 1c1d7e
          ts_putc( uc );
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::output_int( int format, ulong n, bool neg )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          static char hexdigits_lower[] = "0123456789abcdef";
      Packit 1c1d7e
          static char hexdigits_upper[] = "0123456789ABCDEF";
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          char buf[76];
      Packit 1c1d7e
          register char *p;
      Packit 1c1d7e
          int	  len;
      Packit 1c1d7e
          char *hexdigits;
      Packit 1c1d7e
      Packit 1c1d7e
          switch ( flags() & I_BASE_MASK ) {
      Packit 1c1d7e
      Packit 1c1d7e
      	case I_BASE_2:				// output binary number
      Packit 1c1d7e
      	    switch ( format & I_TYPE_MASK ) {
      Packit 1c1d7e
      		case I_SHORT: len=16; break;
      Packit 1c1d7e
      		case I_INT:   len=sizeof(int)*8; break;
      Packit 1c1d7e
      		case I_LONG:  len=32; break;
      Packit 1c1d7e
      		default:      len = 0;
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    p = &buf[74];			// go reverse order
      Packit 1c1d7e
      	    *p = '\0';
      Packit 1c1d7e
      	    while ( len-- ) {
      Packit 1c1d7e
      		*--p = (char)(n&1) + '0';
      Packit 1c1d7e
      		n >>= 1;
      Packit 1c1d7e
      		if ( !n )
      Packit 1c1d7e
      		    break;
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    if ( flags() & showbase ) {		// show base
      Packit 1c1d7e
      		*--p = (flags() & uppercase) ? 'B' : 'b';
      Packit 1c1d7e
      		*--p = '0';
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    break;
      Packit 1c1d7e
      Packit 1c1d7e
      	case I_BASE_8:				// output octal number
      Packit 1c1d7e
      	    p = &buf[74];
      Packit 1c1d7e
      	    *p = '\0';
      Packit 1c1d7e
      	    do {
      Packit 1c1d7e
      		*--p = (char)(n&7) + '0';
      Packit 1c1d7e
      		n >>= 3;
      Packit 1c1d7e
      	    } while ( n );
      Packit 1c1d7e
      	    if ( flags() & showbase )
      Packit 1c1d7e
      		*--p = '0';
      Packit 1c1d7e
      	    break;
      Packit 1c1d7e
      Packit 1c1d7e
      	case I_BASE_16:				// output hexadecimal number
      Packit 1c1d7e
      	    p = &buf[74];
      Packit 1c1d7e
      	    *p = '\0';
      Packit 1c1d7e
      	    hexdigits = (flags() & uppercase) ?
      Packit 1c1d7e
      		hexdigits_upper : hexdigits_lower;
      Packit 1c1d7e
      	    do {
      Packit 1c1d7e
      		*--p = hexdigits[(int)n&0xf];
      Packit 1c1d7e
      		n >>= 4;
      Packit 1c1d7e
      	    } while ( n );
      Packit 1c1d7e
      	    if ( flags() & showbase ) {
      Packit 1c1d7e
      		*--p = (flags() & uppercase) ? 'X' : 'x';
      Packit 1c1d7e
      		*--p = '0';
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    break;
      Packit 1c1d7e
      Packit 1c1d7e
      	default:				// decimal base is default
      Packit 1c1d7e
      	    p = &buf[74];
      Packit 1c1d7e
      	    *p = '\0';
      Packit 1c1d7e
      	    if ( neg )
      Packit 1c1d7e
      		n = (ulong)(-(long)n);
      Packit 1c1d7e
      	    do {
      Packit 1c1d7e
      		*--p = ((int)(n%10)) + '0';
      Packit 1c1d7e
      		n /= 10;
      Packit 1c1d7e
      	    } while ( n );
      Packit 1c1d7e
      	    if ( neg )
      Packit 1c1d7e
      		*--p = '-';
      Packit 1c1d7e
      	    else if ( flags() & showpos )
      Packit 1c1d7e
      		*--p = '+';
      Packit 1c1d7e
      	    if ( (flags() & internal) && fwidth && !ts_isdigit(*p) ) {
      Packit 1c1d7e
      		ts_putc( *p );			// special case for internal
      Packit 1c1d7e
      		++p;				//   padding
      Packit 1c1d7e
      		fwidth--;
      Packit 1c1d7e
      		return *this << (const char*)p;
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
          }
      Packit 1c1d7e
          if ( fwidth ) {				// adjustment required
      Packit 1c1d7e
      	if ( !(flags() & left) ) {		// but NOT left adjustment
      Packit 1c1d7e
      	    len = qstrlen(p);
      Packit 1c1d7e
      	    int padlen = fwidth - len;
      Packit 1c1d7e
      	    if ( padlen <= 0 ) {		// no padding required
      Packit 1c1d7e
      		writeBlock( p, len );
      Packit 1c1d7e
      	    } else if ( padlen < (int)(p-buf) ) { // speeds up padding
      Packit 1c1d7e
      		memset( p-padlen, (char)fillchar, padlen );
      Packit 1c1d7e
      		writeBlock( p-padlen, padlen+len );
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    else				// standard padding
      Packit 1c1d7e
      		*this << (const char*)p;
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	else
      Packit 1c1d7e
      	    *this << (const char*)p;
      Packit 1c1d7e
      	fwidth = 0;				// reset field width
      Packit 1c1d7e
          }
      Packit 1c1d7e
          else
      Packit 1c1d7e
      	writeBlock( p, qstrlen(p) );
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a \c short integer to the stream and returns a reference to
      Packit 1c1d7e
        the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( signed short i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return output_int( I_SHORT | I_SIGNED, i, i < 0 );
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes an \c unsigned \c short integer to the stream and returns a reference
      Packit 1c1d7e
        to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( unsigned short i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return output_int( I_SHORT | I_UNSIGNED, i, FALSE );
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes an \c int to the stream and returns a reference to
      Packit 1c1d7e
        the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( signed int i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return output_int( I_INT | I_SIGNED, i, i < 0 );
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes an \c unsigned \c int to the stream and returns a reference to
      Packit 1c1d7e
        the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( unsigned int i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return output_int( I_INT | I_UNSIGNED, i, FALSE );
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a \c long \c int to the stream and returns a reference to
      Packit 1c1d7e
        the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( signed long i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return output_int( I_LONG | I_SIGNED, i, i < 0 );
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes an \c unsigned \c long \c int to the stream and returns a reference to
      Packit 1c1d7e
        the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( unsigned long i )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return output_int( I_LONG | I_UNSIGNED, i, FALSE );
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a \c float to the stream and returns a reference to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( float f )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return *this << (double)f;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a \c double to the stream and returns a reference to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( double f )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          char buf[64];
      Packit 1c1d7e
          char f_char;
      Packit 1c1d7e
          char format[16];
      Packit 1c1d7e
          if ( (flags()&floatfield) == fixed )
      Packit 1c1d7e
      	f_char = 'f';
      Packit 1c1d7e
          else if ( (flags()&floatfield) == scientific )
      Packit 1c1d7e
      	f_char = (flags() & uppercase) ? 'E' : 'e';
      Packit 1c1d7e
          else
      Packit 1c1d7e
      	f_char = (flags() & uppercase) ? 'G' : 'g';
      Packit 1c1d7e
          register char *fs = format;			// generate format string
      Packit 1c1d7e
          *fs++ = '%';				//   "%.<prec>l<f_char>"
      Packit 1c1d7e
          *fs++ = '.';
      Packit 1c1d7e
          int prec = precision();
      Packit 1c1d7e
          if ( prec > 99 )
      Packit 1c1d7e
      	prec = 99;
      Packit 1c1d7e
          if ( prec >= 10 ) {
      Packit 1c1d7e
      	*fs++ = prec / 10 + '0';
      Packit 1c1d7e
      	*fs++ = prec % 10 + '0';
      Packit 1c1d7e
          } else {
      Packit 1c1d7e
      	*fs++ = prec + '0';
      Packit 1c1d7e
          }
      Packit 1c1d7e
          *fs++ = 'l';
      Packit 1c1d7e
          *fs++ = f_char;
      Packit 1c1d7e
          *fs = '\0';
      Packit 1c1d7e
          sprintf( buf, format, f );			// convert to text
      Packit 1c1d7e
          if ( fwidth )				// padding
      Packit 1c1d7e
      	*this << (const char*)buf;
      Packit 1c1d7e
          else					// just write it
      Packit 1c1d7e
      	writeBlock( buf, qstrlen(buf) );
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a string to the stream and returns a reference to the stream.
      Packit 1c1d7e
      Packit 1c1d7e
        The string \a s is assumed to be Latin1 encoded independent of the Encoding set
      Packit 1c1d7e
        for the QTextStream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( const char* s )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          char padbuf[48];
      Packit 1c1d7e
          uint len = qstrlen( s );			// don't write null terminator
      Packit 1c1d7e
          if ( fwidth ) {				// field width set
      Packit 1c1d7e
      	int padlen = fwidth - len;
      Packit 1c1d7e
      	fwidth = 0;				// reset width
      Packit 1c1d7e
      	if ( padlen > 0 ) {
      Packit 1c1d7e
      	    char *ppad;
      Packit 1c1d7e
      	    if ( padlen > 46 ) {		// create extra big fill buffer
      Packit 1c1d7e
      		ppad = new char[padlen];
      Packit 1c1d7e
      		CHECK_PTR( ppad );
      Packit 1c1d7e
      	    } else {
      Packit 1c1d7e
      		ppad = padbuf;
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    memset( ppad, (char)fillchar, padlen );	// fill with fillchar
      Packit 1c1d7e
      	    if ( !(flags() & left) ) {
      Packit 1c1d7e
      		writeBlock( ppad, padlen );
      Packit 1c1d7e
      		padlen = 0;
      Packit 1c1d7e
      	    }
      Packit 1c1d7e
      	    writeBlock( s, len );
      Packit 1c1d7e
      	    if ( padlen )
      Packit 1c1d7e
      		writeBlock( ppad, padlen );
      Packit 1c1d7e
      	    if ( ppad != padbuf )		// delete extra big fill buf
      Packit 1c1d7e
      		delete[] ppad;
      Packit 1c1d7e
      	    return *this;
      Packit 1c1d7e
      	}
      Packit 1c1d7e
          }
      Packit 1c1d7e
          writeBlock( s, len );
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes \a s to the stream and returns a reference to the stream.
      Packit 1c1d7e
      Packit 1c1d7e
        The string \a s is assumed to be Latin1 encoded independent of the Encoding set
      Packit 1c1d7e
        for the QTextStream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( const QCString & s )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          return operator<<(s.data());
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes \a s to the stream and returns a reference to the stream.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( const QString& s )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          CHECK_STREAM_PRECOND
      Packit 1c1d7e
          uint len = s.length();
      Packit 1c1d7e
          QString s1 = s;
      Packit 1c1d7e
          if ( fwidth ) {				// field width set
      Packit 1c1d7e
      	if ( !(flags() & left) ) {
      Packit 1c1d7e
      	    s1 = s.rightJustify(fwidth, (char)fillchar);
      Packit 1c1d7e
      	} else {
      Packit 1c1d7e
      	    s1 = s.leftJustify(fwidth, (char)fillchar);
      Packit 1c1d7e
      	}
      Packit 1c1d7e
      	fwidth = 0;				// reset width
      Packit 1c1d7e
          }
      Packit 1c1d7e
          writeBlock( s1.unicode(), len );
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        Writes a pointer to the stream and returns a reference to the stream.
      Packit 1c1d7e
      Packit 1c1d7e
        The \e ptr is output as an unsigned long hexadecimal integer.
      Packit 1c1d7e
      */
      Packit 1c1d7e
      Packit 1c1d7e
      QTextStream &QTextStream::operator<<( void *ptr )
      Packit 1c1d7e
      {
      Packit 1c1d7e
          int f = flags();
      Packit 1c1d7e
          setf( hex, basefield );
      Packit 1c1d7e
          setf( showbase );
      Packit 1c1d7e
          unsetf( uppercase );
      Packit 1c1d7e
          output_int( I_LONG | I_UNSIGNED, (uintptr_t)ptr, FALSE );
      Packit 1c1d7e
          flags( f );
      Packit 1c1d7e
          return *this;
      Packit 1c1d7e
      }
      Packit 1c1d7e
      Packit 1c1d7e
      Packit 1c1d7e
      /*!
      Packit 1c1d7e
        \fn int QTextStream::flags() const
      Packit 1c1d7e
        Returns the current stream flags. The default value is 0.
      Packit 1c1d7e
      Packit 1c1d7e
        The meaning of the flags are:
      Packit 1c1d7e
        
        Packit 1c1d7e
            
      • \e skipws - Not currently used - whitespace always skipped
      • Packit 1c1d7e
            
      • \e left - Numeric fields are left-aligned
      • Packit 1c1d7e
            
      • \e right - Not currently used (by default numerics are right aligned)
      • Packit 1c1d7e
            
      • \e internal - Put any padding spaces between +/- and value
      • Packit 1c1d7e
            
      • \e bin - Output \e and input only in binary
      • Packit 1c1d7e
            
      • \e oct - Output \e and input only in octal
      • Packit 1c1d7e
            
      • \e dec - Output \e and input only in decimal
      • Packit 1c1d7e
            
      • \e hex - Output \e and input only in hexadecimal
      • Packit 1c1d7e
            
      • \e showbase - Annotate numeric outputs with 0b, 0, or 0x if in
      • Packit 1c1d7e
        		\e bin, \e oct, or \e hex format
        Packit 1c1d7e
            
      • \e showpoint - Not currently used
      • Packit 1c1d7e
            
      • \e uppercase - Use 0B and 0X rather than 0b and 0x
      • Packit 1c1d7e
            
      • \e showpos - Show + for positive numeric values
      • Packit 1c1d7e
            
      • \e scientific - Use scientific notation for floating point values
      • Packit 1c1d7e
            
      • \e fixed - Use fixed-point notation for floating point values
      • Packit 1c1d7e
          
        Packit 1c1d7e
        Packit 1c1d7e
          Note that unless \e bin, \e oct, \e dec, or \e hex is set, the input base is
        Packit 1c1d7e
            octal if the value starts with 0, hexadecimal if it starts with 0x, binary
        Packit 1c1d7e
            if the value starts with 0b, and decimal otherwise.
        Packit 1c1d7e
        Packit 1c1d7e
          \sa setf(), unsetf()
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::flags( int f )
        Packit 1c1d7e
          Sets the stream flags to \e f.
        Packit 1c1d7e
          Returns the previous stream flags.
        Packit 1c1d7e
        Packit 1c1d7e
          \sa setf(), unsetf(), flags()
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::setf( int bits )
        Packit 1c1d7e
          Sets the stream flag bits \e bits.
        Packit 1c1d7e
          Returns the previous stream flags.
        Packit 1c1d7e
        Packit 1c1d7e
          Equivalent to flags( flags() | bits ).
        Packit 1c1d7e
        Packit 1c1d7e
          \sa setf(), unsetf()
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::setf( int bits, int mask )
        Packit 1c1d7e
          Sets the stream flag bits \e bits with a bit mask \e mask.
        Packit 1c1d7e
          Returns the previous stream flags.
        Packit 1c1d7e
        Packit 1c1d7e
          Equivalent to flags( (flags() & ~mask) | (bits & mask) ).
        Packit 1c1d7e
        Packit 1c1d7e
          \sa setf(), unsetf()
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::unsetf( int bits )
        Packit 1c1d7e
          Clears the stream flag bits \e bits.
        Packit 1c1d7e
          Returns the previous stream flags.
        Packit 1c1d7e
        Packit 1c1d7e
          Equivalent to flags( flags() & ~mask ).
        Packit 1c1d7e
        Packit 1c1d7e
          \sa setf()
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::width() const
        Packit 1c1d7e
          Returns the field width. The default value is 0.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::width( int w )
        Packit 1c1d7e
          Sets the field width to \e w. Returns the previous field width.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::fill() const
        Packit 1c1d7e
          Returns the fill character. The default value is ' ' (space).
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::fill( int f )
        Packit 1c1d7e
          Sets the fill character to \e f. Returns the previous fill character.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::precision() const
        Packit 1c1d7e
          Returns the precision. The default value is 6.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn int QTextStream::precision( int p )
        Packit 1c1d7e
          Sets the precision to \e p. Returns the previous precision setting.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        Packit 1c1d7e
         /*****************************************************************************
        Packit 1c1d7e
          QTextStream manipulators
        Packit 1c1d7e
         *****************************************************************************/
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &bin( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            s.setf(QTS::bin,QTS::basefield);
        Packit 1c1d7e
            return s;
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &oct( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            s.setf(QTS::oct,QTS::basefield);
        Packit 1c1d7e
            return s;
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &dec( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            s.setf(QTS::dec,QTS::basefield);
        Packit 1c1d7e
            return s;
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &hex( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            s.setf(QTS::hex,QTS::basefield);
        Packit 1c1d7e
            return s;
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &endl( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            return s << '\n';
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &flush( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            if ( s.device() )
        Packit 1c1d7e
        	s.device()->flush();
        Packit 1c1d7e
            return s;
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &ws( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            s.skipWhiteSpace();
        Packit 1c1d7e
            return s;
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        QTextStream &reset( QTextStream &s )
        Packit 1c1d7e
        {
        Packit 1c1d7e
            s.reset();
        Packit 1c1d7e
            return s;
        Packit 1c1d7e
        }
        Packit 1c1d7e
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \class QTextIStream qtextstream.h
        Packit 1c1d7e
          \brief A convenience class for input streams.
        Packit 1c1d7e
        Packit 1c1d7e
          For simple tasks, code should be simple.  Hence this
        Packit 1c1d7e
          class is a shorthand to avoid passing the \e mode argument
        Packit 1c1d7e
          to the normal QTextStream constructors.
        Packit 1c1d7e
        Packit 1c1d7e
          This makes it easy for example, to write things like this:
        Packit 1c1d7e
        \code
        Packit 1c1d7e
            QString data = "123 456";
        Packit 1c1d7e
            int a, b;
        Packit 1c1d7e
            QTextIStream(&data) >> a >> b;
        Packit 1c1d7e
        \endcode
        Packit 1c1d7e
        Packit 1c1d7e
          \sa QTextOStream
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn QTextIStream::QTextIStream( QString *s )
        Packit 1c1d7e
        Packit 1c1d7e
          Constructs a stream to read from string \a s.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn QTextIStream::QTextIStream( QByteArray ba )
        Packit 1c1d7e
        Packit 1c1d7e
          Constructs a stream to read from the array \a ba.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn QTextIStream::QTextIStream( FILE *f )
        Packit 1c1d7e
        Packit 1c1d7e
          Constructs a stream to read from the file \a f.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \class QTextOStream qtextstream.h
        Packit 1c1d7e
          \brief A convenience class for output streams.
        Packit 1c1d7e
        Packit 1c1d7e
          For simple tasks, code should be simple.  Hence this
        Packit 1c1d7e
          class is a shorthand to avoid passing the \e mode argument
        Packit 1c1d7e
          to the normal QTextStream constructors.
        Packit 1c1d7e
        Packit 1c1d7e
          This makes it easy for example, to write things like this:
        Packit 1c1d7e
        \code
        Packit 1c1d7e
            QString result;
        Packit 1c1d7e
            QTextOStream(&result) << "pi = " << 3.14;
        Packit 1c1d7e
        \endcode
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn QTextOStream::QTextOStream( QString *s )
        Packit 1c1d7e
        Packit 1c1d7e
          Constructs a stream to write to string \a s.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn QTextOStream::QTextOStream( QByteArray ba )
        Packit 1c1d7e
        Packit 1c1d7e
          Constructs a stream to write to the array \a ba.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          \fn QTextOStream::QTextOStream( FILE *f )
        Packit 1c1d7e
        Packit 1c1d7e
          Constructs a stream to write to the file \a f.
        Packit 1c1d7e
        */
        Packit 1c1d7e
        Packit 1c1d7e
        Packit 1c1d7e
        Packit 1c1d7e
        /*!
        Packit 1c1d7e
          Sets the encoding of this stream to \a e, where \a e is one of:
        Packit 1c1d7e
          
          Packit 1c1d7e
            
        • \c Locale Using local file format (Latin1 if locale is not
        • Packit 1c1d7e
            set), but autodetecting Unicode(utf16) on input.
          Packit 1c1d7e
            
        • \c Unicode Using Unicode(utf16) for input and output. Output
        • Packit 1c1d7e
            will be written in the order most efficient for the current platform
          Packit 1c1d7e
            (i.e. the order used internally in QString).
          Packit 1c1d7e
            
        • \c UnicodeUTF8 Using Unicode(utf8) for input and output. If you use it
        • Packit 1c1d7e
            for input it will autodetect utf16 and use it instead of utf8.
          Packit 1c1d7e
            
        • \c Latin1 ISO-8859-1. Will not autodetect utf16.
        • Packit 1c1d7e
            
        • \c UnicodeNetworkOrder Using network order Unicode(utf16) for
        • Packit 1c1d7e
            input and output. Useful when reading Unicode data that does not
          Packit 1c1d7e
            start with the byte order marker.
          Packit 1c1d7e
            
        • \c UnicodeReverse Using reverse network order Unicode(utf16)
        • Packit 1c1d7e
            for input and output. Useful when reading Unicode data that does not
          Packit 1c1d7e
            start with the byte order marker, or writing data that should be
          Packit 1c1d7e
            read by buggy Windows applications.
          Packit 1c1d7e
            
        • \c RawUnicode Like Unicode, but does not write the byte order
        • Packit 1c1d7e
            marker, nor does it autodetect the byte order. Only useful when
          Packit 1c1d7e
            writing to non-persistent storage used by a single process.
          Packit 1c1d7e
            
          Packit 1c1d7e
          Packit 1c1d7e
            \c Locale and all Unicode encodings, except \c RawUnicode, will look at
          Packit 1c1d7e
            the first two bytes in a input stream to determine the byte order. The
          Packit 1c1d7e
            initial byte order marker will be stripped off before data is read.
          Packit 1c1d7e
          Packit 1c1d7e
            Note that this function should be called before any data is read
          Packit 1c1d7e
            to/written from the stream.
          Packit 1c1d7e
            \sa setCodec()
          Packit 1c1d7e
          */
          Packit 1c1d7e
          Packit 1c1d7e
          void QTextStream::setEncoding( Encoding e )
          Packit 1c1d7e
          {
          Packit 1c1d7e
              if ( d->sourceType == QTextStreamPrivate::String )
          Packit 1c1d7e
          	return; // QString does not need any encoding
          Packit 1c1d7e
              switch ( e ) {
          Packit 1c1d7e
              case Unicode:
          Packit 1c1d7e
          	mapper = 0;
          Packit 1c1d7e
          	latin1 = FALSE;
          Packit 1c1d7e
          	doUnicodeHeader = TRUE;
          Packit 1c1d7e
          	internalOrder = TRUE;
          Packit 1c1d7e
          	break;
          Packit 1c1d7e
              case UnicodeUTF8:
          Packit 1c1d7e
          #ifndef QT_NO_CODECS
          Packit 1c1d7e
          	mapper = QTextCodec::codecForMib( 106 );
          Packit 1c1d7e
          	latin1 = FALSE;
          Packit 1c1d7e
          	doUnicodeHeader = TRUE;
          Packit 1c1d7e
          	internalOrder = TRUE;
          Packit 1c1d7e
          #else
          Packit 1c1d7e
          	mapper = 0;
          Packit 1c1d7e
          	latin1 = TRUE;
          Packit 1c1d7e
          	doUnicodeHeader = TRUE;
          Packit 1c1d7e
          #endif
          Packit 1c1d7e
          	break;
          Packit 1c1d7e
              case UnicodeNetworkOrder:
          Packit 1c1d7e
          	mapper = 0;
          Packit 1c1d7e
          	latin1 = FALSE;
          Packit 1c1d7e
          	doUnicodeHeader = TRUE;
          Packit 1c1d7e
          	internalOrder = QChar::networkOrdered();
          Packit 1c1d7e
          	break;
          Packit 1c1d7e
              case UnicodeReverse:
          Packit 1c1d7e
          	mapper = 0;
          Packit 1c1d7e
          	latin1 = FALSE;
          Packit 1c1d7e
          	doUnicodeHeader = TRUE;
          Packit 1c1d7e
          	internalOrder = !QChar::networkOrdered();   //reverse network ordered
          Packit 1c1d7e
          	break;
          Packit 1c1d7e
              case RawUnicode:
          Packit 1c1d7e
          	mapper = 0;
          Packit 1c1d7e
          	latin1 = FALSE;
          Packit 1c1d7e
          	doUnicodeHeader = FALSE;
          Packit 1c1d7e
          	internalOrder = TRUE;
          Packit 1c1d7e
          	break;
          Packit 1c1d7e
              case Locale:
          Packit 1c1d7e
          	latin1 = TRUE; 				// fallback to Latin 1
          Packit 1c1d7e
          #ifndef QT_NO_TEXTCODEC
          Packit 1c1d7e
          	mapper = QTextCodec::codecForLocale();
          Packit 1c1d7e
          #if defined(_OS_WIN32_)
          Packit 1c1d7e
          	if ( GetACP() == 1252 )
          Packit 1c1d7e
          	    mapper = 0;				// Optimized latin1 processing
          Packit 1c1d7e
          #endif
          Packit 1c1d7e
          	if ( mapper && mapper->mibEnum() == 4 )
          Packit 1c1d7e
          #endif
          Packit 1c1d7e
          	    mapper = 0;				// Optimized latin1 processing
          Packit 1c1d7e
          	doUnicodeHeader = TRUE; // If it reads as Unicode, accept it
          Packit 1c1d7e
          	break;
          Packit 1c1d7e
              case Latin1:
          Packit 1c1d7e
          	mapper = 0;
          Packit 1c1d7e
          	doUnicodeHeader = FALSE;
          Packit 1c1d7e
          	latin1 = TRUE;
          Packit 1c1d7e
          	break;
          Packit 1c1d7e
              }
          Packit 1c1d7e
          }
          Packit 1c1d7e
          Packit 1c1d7e
          Packit 1c1d7e
          #ifndef QT_NO_TEXTCODEC
          Packit 1c1d7e
          /*!  Sets the codec for this stream to \a codec. Will not try to
          Packit 1c1d7e
            autodetect Unicode.
          Packit 1c1d7e
          Packit 1c1d7e
            Note that this function should be called before any data is read
          Packit 1c1d7e
            to/written from the stream.
          Packit 1c1d7e
          Packit 1c1d7e
            \sa setEncoding()
          Packit 1c1d7e
          */
          Packit 1c1d7e
          Packit 1c1d7e
          void QTextStream::setCodec( QTextCodec *codec )
          Packit 1c1d7e
          {
          Packit 1c1d7e
              if ( d->sourceType == QTextStreamPrivate::String )
          Packit 1c1d7e
          	return; // QString does not need any codec
          Packit 1c1d7e
              mapper = codec;
          Packit 1c1d7e
              doUnicodeHeader = FALSE;
          Packit 1c1d7e
          }
          Packit 1c1d7e
          #endif
          Packit 1c1d7e
          Packit 1c1d7e
          #endif // QT_NO_TEXTSTREAM