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;
size_t used() const
Returns the number of elements in the buffer currently available for reading.
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
int getch()
Returns a single character from the buffer as an int.
void putch(int ch)
Puts a single character into the buffer as an int.
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().
#define deletev
Remplacement for delete[].