WvStreams
|
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 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