summaryrefslogtreecommitdiffstats
path: root/scribus/sctextstream.h
blob: b909f24ef44086f983d359225184d32841ee97bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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