7 #include "wvwordwrap.h"
9 WvWordWrapEncoder::WvWordWrapEncoder(
int _maxwidth) :
12 line =
new char[maxwidth];
17 WvWordWrapEncoder::~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;
106 void WvWordWrapEncoder::flushline(
WvBuf &outbuf)
108 outbuf.put(line, curindex);
109 curindex = wordindex = 0;
virtual bool _reset()
Template method implementation of reset().
void putch(int ch)
Puts a single character into the buffer as an int.
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush)
Template method implementation of encode().
int getch()
Returns a single character from the buffer as an int.
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers...
size_t used() const
Returns the number of elements in the buffer currently available for reading.
#define deletev
Remplacement for delete[].