9WvWordWrapEncoder::WvWordWrapEncoder(
int _maxwidth) :
12 line =
new char[maxwidth];
17WvWordWrapEncoder::~WvWordWrapEncoder()
26 curindex = wordindex = 0;
35 while (inbuf.used() != 0)
37 int ch = inbuf.getch();
52 if (width <= maxwidth)
53 line[curindex++] = ch;
59 width = (width + 8) & ~7;
60 if (width <= maxwidth)
61 line[curindex++] = ch;
65 if (width >= maxwidth)
70 curindex = wordindex = 0;
73 else if (wordindex == 0)
82 curindex -= wordindex;
83 memmove(line, line + wordindex, curindex);
95 line[curindex++] = ch;
106void WvWordWrapEncoder::flushline(WvBuf &outbuf)
108 outbuf.put(line, curindex);
109 curindex = wordindex = 0;
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
virtual bool _reset()
Template method implementation of reset().
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush)
Template method implementation of encode().