My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
12 {
13  public:
14  FTextStream();
15  FTextStream( QIODevice * );
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:
38  QIODevice *m_dev;
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 
62 inline FTextStream &FTextStream::operator<<( const QString & s)
63 {
64  return operator<<(s.data());
65 }
66 
67 inline FTextStream &FTextStream::operator<<( const QCString &s)
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