Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvwordwrap.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * A very simple word wrapping encoder.
00006  */
00007 #ifndef __WVWORDWRAP_H
00008 #define __WVWORDWRAP_H
00009  
00010 #include "wvencoder.h"
00011  
00012 /**
00013  * Trivial word wrapper.
00014  * Recognizes newlines in input stream as end of line.
00015  * Words are output until no more will fit, in which case a newline
00016  * is output and the word is presented on the next line.  Wrapped
00017  * word delimiter characters are discarded such that a wrapped word
00018  * will always be placed at the beginning of a line.
00019  */
00020 class WvWordWrapEncoder : public WvEncoder
00021 {
00022     const int maxwidth;
00023     char *line;
00024     int width;     // current visual position
00025     int curindex;  // current index in line array
00026     int wordindex; // index of beginning of word in line array
00027     bool inword;   // if true, we're in a word
00028 
00029 public:
00030     WvWordWrapEncoder(int maxwidth);
00031     virtual ~WvWordWrapEncoder();
00032 
00033 protected:
00034     // on flush, outputs a partial line with remaining chars
00035     virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush);
00036     virtual bool _reset(); // supported
00037 
00038 private:
00039     void flushline(WvBuf &outbuf);
00040 };
00041 
00042 #endif // __WVWORDWRAP_H

Generated on Sat Mar 13 14:56:02 2004 for WvStreams by doxygen 1.3.6-20040222