Coverage Report

Created: 2023-12-08 06:59

/src/aspell/common/ostream.hpp
Line
Count
Source (jump to first uncovered line)
1
// This file is part of The New Aspell
2
// Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license
3
// version 2.0 or 2.1.  You should have received a copy of the LGPL
4
// license along with this library if you did not you can find
5
// it at http://www.gnu.org/.
6
7
#ifndef ASPELL_OSTREAM__HPP
8
#define ASPELL_OSTREAM__HPP
9
10
#include <stdarg.h>
11
12
#include "parm_string.hpp"
13
14
namespace acommon {
15
16
  // FIXME: Add Print Method compatible with printf and friends.
17
  //   Than avoid code bloat by using it in many places instead of
18
  //   out << "Bla " << something << " djdkdk " << something else << "\n"
19
20
  class OStream {
21
  public:
22
    virtual void write (char c) = 0;
23
    virtual void write (ParmStr) = 0;
24
    virtual void write (const void *, unsigned int) = 0;
25
26
    virtual int vprintf(const char *format, va_list ap) = 0;
27
28
#ifdef __GNUC__
29
    __attribute__ ((format (printf,2,3)))
30
#endif
31
      int printf(const char * format, ...)
32
0
    {
33
0
      va_list ap;
34
0
      va_start(ap, format);
35
0
      int res = vprintf(format, ap);
36
0
      va_end(ap);
37
0
      return res;
38
0
    }
39
40
0
    void put (char c) {write(c);}
41
0
    void put (ParmStr str) {write(str);}
42
43
    virtual void printl(ParmStr l) 
44
0
    {
45
0
      write(l);
46
0
      write('\n');
47
0
    }
48
49
0
    void write16(unsigned short v) {write(&v, 2);}
50
0
    void write32(unsigned int v) {write(&v, 4);}
51
52
0
    OStream & operator << (char c) {
53
0
      write(c);
54
0
      return *this;
55
0
    }
56
57
0
    OStream & operator << (ParmStr in) {
58
0
      write(in);
59
0
      return *this;
60
0
    }
61
62
15.3M
    virtual ~OStream() {}
63
  };
64
  
65
}
66
67
#endif