Fix for UBSan build
[platform/upstream/doxygen.git] / src / ftextstream.h
1 #ifndef FTEXTSTREAM_H
2 #define FTEXTSTREAM_H
3
4 #include "qtbc.h"
5 #include "qiodevice.h"
6 #include "qstring.h"
7 #include "qgstring.h"
8 #include <stdio.h>
9
10 /** @brief Simplified and optimized version of QTextStream */
11 class FTextStream
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
49 inline FTextStream &FTextStream::operator<<( char c)
50 {
51   m_dev->putch(c);
52   return *this;
53 }
54
55 inline FTextStream &FTextStream::operator<<( const char* s)
56 {
57   uint len = qstrlen( s );
58   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
74 inline FTextStream &operator<<( FTextStream &s, FTSFUNC f )
75 { return (*f)( s ); }
76
77 inline FTextStream &endl( FTextStream & s)
78 {
79   return s << '\n';
80 }
81
82 #endif // FTEXTSTREAM_H