Saner handling if config.mk doesn't exist: use a default config.defaults.mk.
[wvstreams.git] / include / wvwordwrap.h
blob64c37127dd275f61287bfc0f73fc44591ad1ff9f
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * A very simple word wrapping encoder.
6 */
7 #ifndef __WVWORDWRAP_H
8 #define __WVWORDWRAP_H
10 #include "wvencoder.h"
12 /**
13 * Trivial word wrapper.
14 * Recognizes newlines in input stream as end of line.
15 * Words are output until no more will fit, in which case a newline
16 * is output and the word is presented on the next line. Wrapped
17 * word delimiter characters are discarded such that a wrapped word
18 * will always be placed at the beginning of a line.
20 class WvWordWrapEncoder : public WvEncoder
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
29 public:
30 WvWordWrapEncoder(int maxwidth);
31 virtual ~WvWordWrapEncoder();
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
38 private:
39 void flushline(WvBuf &outbuf);
42 #endif // __WVWORDWRAP_H