Coverage Report

Created: 2026-01-17 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aspell/common/ostream.hpp
Line
Count
Source
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
#define _INTL_NO_DEFINE_MACRO_PRINTF
11
12
#include <stdarg.h>
13
14
#include "parm_string.hpp"
15
16
namespace acommon {
17
18
  // FIXME: Add Print Method compatible with printf and friends.
19
  //   Than avoid code bloat by using it in many places instead of
20
  //   out << "Bla " << something << " djdkdk " << something else << "\n"
21
22
  class OStream {
23
  public:
24
    virtual void write (char c) = 0;
25
    virtual void write (ParmStr) = 0;
26
    virtual void write (const void *, unsigned int) = 0;
27
28
    virtual int vprintf(const char *format, va_list ap) = 0;
29
30
#ifdef __GNUC__
31
    __attribute__ ((format (printf,2,3)))
32
#endif
33
      int printf(const char * format, ...)
34
0
    {
35
0
      va_list ap;
36
0
      va_start(ap, format);
37
0
      int res = vprintf(format, ap);
38
0
      va_end(ap);
39
0
      return res;
40
0
    }
41
42
0
    void put (char c) {write(c);}
43
0
    void put (ParmStr str) {write(str);}
44
45
    virtual void printl(ParmStr l) 
46
0
    {
47
0
      write(l);
48
0
      write('\n');
49
0
    }
50
51
0
    void write16(unsigned short v) {write(&v, 2);}
52
0
    void write32(unsigned int v) {write(&v, 4);}
53
54
0
    OStream & operator << (char c) {
55
0
      write(c);
56
0
      return *this;
57
0
    }
58
59
0
    OStream & operator << (ParmStr in) {
60
0
      write(in);
61
0
      return *this;
62
0
    }
63
64
15.3M
    virtual ~OStream() {}
65
  };
66
  
67
}
68
69
#endif