Public Member Functions | Private Member Functions | Private Attributes | List of all members
FTextStream Class Reference

Simplified and optimized version of QTextStream. More...

#include <ftextstream.h>

Public Member Functions

 FTextStream ()
 
 FTextStream (QIODevice *)
 
 FTextStream (QGString *)
 
 FTextStream (FILE *)
 
virtual ~FTextStream ()
 
QIODevicedevice () const
 
void setDevice (QIODevice *)
 
void unsetDevice ()
 
FTextStreamoperator<< (char)
 
FTextStreamoperator<< (const char *)
 
FTextStreamoperator<< (const QString &)
 
FTextStreamoperator<< (const QCString &)
 
FTextStreamoperator<< (signed short)
 
FTextStreamoperator<< (unsigned short)
 
FTextStreamoperator<< (signed int)
 
FTextStreamoperator<< (unsigned int)
 
FTextStreamoperator<< (signed long)
 
FTextStreamoperator<< (unsigned long)
 
FTextStreamoperator<< (float)
 
FTextStreamoperator<< (double)
 

Private Member Functions

FTextStreamoutput_int (ulong n, bool neg)
 

Private Attributes

QIODevicem_dev
 
bool m_owndev
 

Detailed Description

Simplified and optimized version of QTextStream.

Definition at line 11 of file ftextstream.h.

Constructor & Destructor Documentation

FTextStream::FTextStream ( )

Definition at line 145 of file ftextstream.cpp.

146 {
147  m_dev = 0;
148  m_owndev = FALSE;
149 }
bool m_owndev
Definition: ftextstream.h:39
QIODevice * m_dev
Definition: ftextstream.h:38
const bool FALSE
Definition: qglobal.h:370
FTextStream::FTextStream ( QIODevice dev)

Definition at line 151 of file ftextstream.cpp.

152 {
153  m_dev = dev;
154  m_owndev = FALSE;
155 }
bool m_owndev
Definition: ftextstream.h:39
QIODevice * m_dev
Definition: ftextstream.h:38
const bool FALSE
Definition: qglobal.h:370
FTextStream::FTextStream ( QGString s)

Definition at line 157 of file ftextstream.cpp.

158 {
159  m_dev = new QGStringBuffer(s);
160  ((QGStringBuffer*)m_dev)->open( IO_WriteOnly );
161  m_owndev = TRUE;
162 }
#define IO_WriteOnly
Definition: qiodevice.h:62
bool m_owndev
Definition: ftextstream.h:39
QIODevice * m_dev
Definition: ftextstream.h:38
const bool TRUE
Definition: qglobal.h:371
FTextStream::FTextStream ( FILE *  fh)

Definition at line 164 of file ftextstream.cpp.

165 {
166  m_dev = new QFile;
167  ((QFile *)m_dev)->open( IO_WriteOnly, fh);
168  m_owndev = TRUE;
169 }
#define IO_WriteOnly
Definition: qiodevice.h:62
bool m_owndev
Definition: ftextstream.h:39
QIODevice * m_dev
Definition: ftextstream.h:38
bool open(int)
Definition: qfile_unix.cpp:134
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
const bool TRUE
Definition: qglobal.h:371
FTextStream::~FTextStream ( )
virtual

Definition at line 171 of file ftextstream.cpp.

172 {
173  if (m_owndev) delete m_dev;
174  m_dev = 0;
175 }
bool m_owndev
Definition: ftextstream.h:39
QIODevice * m_dev
Definition: ftextstream.h:38

Member Function Documentation

QIODevice * FTextStream::device ( ) const

Definition at line 177 of file ftextstream.cpp.

178 {
179  return m_dev;
180 }
QIODevice * m_dev
Definition: ftextstream.h:38
FTextStream & FTextStream::operator<< ( char  c)
inline

Definition at line 49 of file ftextstream.h.

50 {
51  if (m_dev) m_dev->putch(c);
52  return *this;
53 }
QIODevice * m_dev
Definition: ftextstream.h:38
virtual int putch(int)=0
FTextStream & FTextStream::operator<< ( const char *  s)
inline

Definition at line 55 of file ftextstream.h.

56 {
57  uint len = qstrlen( s );
58  if (m_dev) m_dev->writeBlock( s, len );
59  return *this;
60 }
QIODevice * m_dev
Definition: ftextstream.h:38
virtual int writeBlock(const char *data, uint len)=0
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042
FTextStream & FTextStream::operator<< ( const QString s)
inline

Definition at line 62 of file ftextstream.h.

63 {
64  return operator<<(s.data());
65 }
const char * data() const
Definition: qstring.h:542
FTextStream & operator<<(char)
Definition: ftextstream.h:49
FTextStream & FTextStream::operator<< ( const QCString s)
inline

Definition at line 67 of file ftextstream.h.

68 {
69  return operator<<(s.data());
70 }
FTextStream & operator<<(char)
Definition: ftextstream.h:49
const char * data() const
Definition: qcstring.h:207
FTextStream & FTextStream::operator<< ( signed short  i)

Definition at line 215 of file ftextstream.cpp.

216 {
217  return output_int( i, i < 0 );
218 }
FTextStream & output_int(ulong n, bool neg)
FTextStream & FTextStream::operator<< ( unsigned short  i)

Definition at line 220 of file ftextstream.cpp.

221 {
222  return output_int( i, FALSE );
223 }
const bool FALSE
Definition: qglobal.h:370
FTextStream & output_int(ulong n, bool neg)
FTextStream & FTextStream::operator<< ( signed int  i)

Definition at line 225 of file ftextstream.cpp.

226 {
227  return output_int( i, i < 0 );
228 }
FTextStream & output_int(ulong n, bool neg)
FTextStream & FTextStream::operator<< ( unsigned int  i)

Definition at line 230 of file ftextstream.cpp.

231 {
232  return output_int( i, FALSE );
233 }
const bool FALSE
Definition: qglobal.h:370
FTextStream & output_int(ulong n, bool neg)
FTextStream & FTextStream::operator<< ( signed long  i)

Definition at line 235 of file ftextstream.cpp.

236 {
237  return output_int( i, i < 0 );
238 }
FTextStream & output_int(ulong n, bool neg)
FTextStream & FTextStream::operator<< ( unsigned long  i)

Definition at line 240 of file ftextstream.cpp.

241 {
242  return output_int( i, FALSE );
243 }
const bool FALSE
Definition: qglobal.h:370
FTextStream & output_int(ulong n, bool neg)
FTextStream & FTextStream::operator<< ( float  f)

Definition at line 245 of file ftextstream.cpp.

246 {
247  return *this << (double)f;
248 }
FTextStream & FTextStream::operator<< ( double  d)

Definition at line 250 of file ftextstream.cpp.

251 {
252  char buf[64];
253  sprintf(buf,"%f",d);
254  return *this << buf;
255 }
FTextStream & FTextStream::output_int ( ulong  n,
bool  neg 
)
private

Definition at line 197 of file ftextstream.cpp.

198 {
199  char buf[20];
200  char *p = &buf[19];
201  *p = '\0';
202  if ( neg )
203  {
204  n = (ulong)(-(long)n);
205  }
206  do
207  {
208  *--p = ((int)(n%10)) + '0';
209  n /= 10;
210  } while ( n );
211  if ( neg ) *--p = '-';
212  return operator<<(p);
213 }
FTextStream & operator<<(char)
Definition: ftextstream.h:49
std::void_t< T > n
unsigned long ulong
Definition: qglobal.h:352
p
Definition: test.py:223
void FTextStream::setDevice ( QIODevice dev)

Definition at line 182 of file ftextstream.cpp.

183 {
184  if (m_owndev)
185  {
186  delete m_dev;
187  m_owndev = FALSE;
188  }
189  m_dev = dev;
190 }
bool m_owndev
Definition: ftextstream.h:39
QIODevice * m_dev
Definition: ftextstream.h:38
const bool FALSE
Definition: qglobal.h:370
void FTextStream::unsetDevice ( )

Definition at line 192 of file ftextstream.cpp.

193 {
194  setDevice(0);
195 }
void setDevice(QIODevice *)

Member Data Documentation

QIODevice* FTextStream::m_dev
private

Definition at line 38 of file ftextstream.h.

bool FTextStream::m_owndev
private

Definition at line 39 of file ftextstream.h.


The documentation for this class was generated from the following files: