ftextstream.h
Go to the documentation of this file.
1 #ifndef FTEXTSTREAM_H
2 #define FTEXTSTREAM_H
3 
4 #include <stdio.h>
5 
6 #include <qiodevice.h>
7 #include <qstring.h>
8 #include <qgstring.h>
9 
10 /** @brief Simplified and optimized version of QTextStream */
12 {
13  public:
14  FTextStream();
16  FTextStream( QGString * );
17  FTextStream( FILE * );
18  virtual ~FTextStream();
19 
20  QIODevice *device() const;
21  void setDevice( QIODevice * );
22  void unsetDevice();
23 
24  FTextStream &operator<<( char );
25  FTextStream &operator<<( const char *);
26  FTextStream &operator<<( const QString & );
27  FTextStream &operator<<( const QCString & );
28  FTextStream &operator<<( signed short );
29  FTextStream &operator<<( unsigned short );
30  FTextStream &operator<<( signed int );
31  FTextStream &operator<<( unsigned int );
32  FTextStream &operator<<( signed long );
33  FTextStream &operator<<( unsigned long );
34  FTextStream &operator<<( float );
35  FTextStream &operator<<( double );
36 
37  private:
39  bool m_owndev;
40  FTextStream &output_int( ulong n, bool neg );
41 
42  private: // Disabled copy constructor and operator=
43 #if defined(Q_DISABLE_COPY)
44  FTextStream( const FTextStream & );
45  FTextStream &operator=( const FTextStream & );
46 #endif
47 };
48 
50 {
51  if (m_dev) m_dev->putch(c);
52  return *this;
53 }
54 
55 inline FTextStream &FTextStream::operator<<( const char* s)
56 {
57  uint len = qstrlen( s );
58  if (m_dev) m_dev->writeBlock( s, len );
59  return *this;
60 }
61 
63 {
64  return operator<<(s.data());
65 }
66 
68 {
69  return operator<<(s.data());
70 }
71 
72 typedef FTextStream & (*FTSFUNC)(FTextStream &);// manipulator function
73 
75 { return (*f)( s ); }
76 
78 {
79  return s << '\n';
80 }
81 
82 #endif // FTEXTSTREAM_H
bool m_owndev
Definition: ftextstream.h:39
QIODevice * m_dev
Definition: ftextstream.h:38
void setDevice(QIODevice *)
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
void unsetDevice()
FTextStream &(* FTSFUNC)(FTextStream &)
Definition: ftextstream.h:72
virtual int writeBlock(const char *data, uint len)=0
const char * data() const
Definition: qstring.h:542
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
FTextStream & operator<<(char)
Definition: ftextstream.h:49
std::void_t< T > n
unsigned long ulong
Definition: qglobal.h:352
const char * data() const
Definition: qcstring.h:207
QIODevice * device() const
FTextStream & output_int(ulong n, bool neg)
FTextStream & endl(FTextStream &s)
Definition: ftextstream.h:77
virtual ~FTextStream()
The QIODevice class is the base class of I/O devices.
Definition: qiodevice.h:88
virtual int putch(int)=0
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042