WvStreams
wvwordwrap.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * A very simple word wrapping encoder.
6  */
7 #ifndef __WVWORDWRAP_H
8 #define __WVWORDWRAP_H
9 
10 #include "wvencoder.h"
11 
21 {
22  const int maxwidth;
23  char *line;
24  int width; // current visual position
25  int curindex; // current index in line array
26  int wordindex; // index of beginning of word in line array
27  bool inword; // if true, we're in a word
28 
29 public:
30  WvWordWrapEncoder(int maxwidth);
31  virtual ~WvWordWrapEncoder();
32 
33 protected:
34  // on flush, outputs a partial line with remaining chars
35  virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush);
36  virtual bool _reset(); // supported
37 
38 private:
39  void flushline(WvBuf &outbuf);
40 };
41 
42 #endif // __WVWORDWRAP_H
WvEncoder
The base encoder class.
Definition: wvencoder.h:67
WvWordWrapEncoder::_reset
virtual bool _reset()
Template method implementation of reset().
Definition: wvwordwrap.cc:23
WvWordWrapEncoder::_encode
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush)
Template method implementation of encode().
Definition: wvwordwrap.cc:32
WvBufBase< unsigned char >
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
Definition: wvbuf.h:22
WvEncoder::flush
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Definition: wvencoder.h:163
WvWordWrapEncoder
Trivial word wrapper.
Definition: wvwordwrap.h:20