summaryrefslogtreecommitdiff
path: root/src/ftextstream.h
blob: 63ef24429ee3823325e46ffe61ae93dc887d0e0d (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef FTEXTSTREAM_H
#define FTEXTSTREAM_H

#include "qtbc.h"
#include "qiodevice.h"
#include "qstring.h"
#include "qgstring.h"
#include <stdio.h>

/** @brief Simplified and optimized version of QTextStream */
class FTextStream
{
  public:
    FTextStream();
    FTextStream( QIODevice * );
    FTextStream( QGString * );
    FTextStream( FILE * );
    virtual ~FTextStream();

    QIODevice	*device() const;
    void	 setDevice( QIODevice * );
    void	 unsetDevice();

    FTextStream &operator<<( char );
    FTextStream &operator<<( const char *);
    FTextStream &operator<<( const QString & );
    FTextStream &operator<<( const QCString & );
    FTextStream &operator<<( signed short );
    FTextStream &operator<<( unsigned short );
    FTextStream &operator<<( signed int );
    FTextStream &operator<<( unsigned int );
    FTextStream &operator<<( signed long );
    FTextStream &operator<<( unsigned long );
    FTextStream &operator<<( float );
    FTextStream &operator<<( double );

  private:
    QIODevice *m_dev;
    bool m_owndev;
    FTextStream &output_int( ulong n, bool neg );

  private:	// Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
    FTextStream( const FTextStream & );
    FTextStream &operator=( const FTextStream & );
#endif
};

inline FTextStream &FTextStream::operator<<( char c)
{
  m_dev->putch(c);
  return *this;
}

inline FTextStream &FTextStream::operator<<( const char* s)
{
  uint len = qstrlen( s );
  m_dev->writeBlock( s, len );
  return *this;
}

inline FTextStream &FTextStream::operator<<( const QString & s)
{
  return operator<<(s.data());
}

inline FTextStream &FTextStream::operator<<( const QCString &s)
{
  return operator<<(s.data());
}

typedef FTextStream & (*FTSFUNC)(FTextStream &);// manipulator function

inline FTextStream &operator<<( FTextStream &s, FTSFUNC f )
{ return (*f)( s ); }

inline FTextStream &endl( FTextStream & s)
{
  return s << '\n';
}

#endif // FTEXTSTREAM_H