Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 13503 → Rev 13504

/trunk/Scribus/scribus/sctextstream.h
0,0 → 1,51
//
// C++ Interface: sclocale
//
// Description:
//
//
// Author: Pierre Marchand <pierremarc@oep-h.com>, (C) 2009
//
// Copyright: See COPYING file that comes with this distribution
//
//
 
#ifndef SCTEXTSTREAM_H
#define SCTEXTSTREAM_H
 
#include <QString>
#include <QTextStream>
 
#include "scribusapi.h"
 
/**
This class fixes a bug in QTextStream up to version Qt 4.4: using locale-aware strtod() for parsing double/float arguments
*/
class SCRIBUS_API ScTextStream
{
private:
QTextStream qts;
 
public:
ScTextStream() : qts() {}
ScTextStream(QIODevice* device) : qts(device) {}
ScTextStream(QString * string, QIODevice::OpenMode openMode = QIODevice::ReadWrite) : qts(string, openMode) {}
ScTextStream(QByteArray * array, QIODevice::OpenMode openMode = QIODevice::ReadWrite ) : qts(array, openMode) {}
 
ScTextStream & operator<< ( const QString & val );
ScTextStream & operator<< ( double val );
 
ScTextStream & operator>> ( QString & val );
ScTextStream & operator>> ( double & val );
ScTextStream & operator>> ( float & val );
ScTextStream & operator>> ( int & val );
 
QString readAll ();
QString readLine ( qint64 maxlen = 0 );
 
bool atEnd () const;
};
 
#endif // SCTEXTSTREAM_H
 
 
/trunk/Scribus/scribus/sctextstream.cpp
0,0 → 1,69
//
// C++ Implementation: sclocale
//
// Description:
//
//
// Author: Pierre Marchand <pierremarc@oep-h.com>, (C) 2009
//
// Copyright: See COPYING file that comes with this distribution
//
//
 
#include "scclocale.h"
#include "sctextstream.h"
 
ScTextStream & ScTextStream::operator<< ( const QString & val )
{
qts << val;
return *this;
}
 
ScTextStream & ScTextStream::operator<< ( double val )
{
qts << ScCLocale::toQStringC(val);
return *this;
}
 
ScTextStream & ScTextStream::operator>> ( QString & val )
{
qts >> val;
return *this;
}
 
ScTextStream & ScTextStream::operator>> ( double & val )
{
QString s;
qts >> s;
val = ScCLocale::toDoubleC(s);
return *this;
}
 
ScTextStream & ScTextStream::operator>> ( float & val )
{
QString s;
qts >> s;
val = ScCLocale::toFloatC(s);
return *this;
}
 
ScTextStream & ScTextStream::operator>> ( int & val )
{
qts >> val;
return *this;
}
 
QString ScTextStream::readAll ()
{
return qts.readAll();
}
 
QString ScTextStream::readLine ( qint64 maxlen )
{
return qts.readLine(maxlen);
}
 
bool ScTextStream::atEnd () const
{
return qts.atEnd();
}