////////////////////////////////////////////////////////////////////////////// // textboost.h #ifndef INCL_TextBoost #define INCL_TextBoost #include extern unsigned int strl(const char*); // custom strlen class TextBoost { public: TextBoost(unsigned int = 1024,const char * = 0); ~TextBoost() { delete mae; delete []tbuff; } TextBoost& reset() { return mae->seekp(0),*this; } std::strstream& operator()() { return *mae; } // enable you to reset TextBoost before use std::strstream& operator()(bool x) { if(x) reset(); return *mae; } private: char *buff,*tbuff; unsigned int len; std::strstream *mae; }; #endif ////////////////////////////////////////////////////////////////////////////// // textboost.cpp #include "textboost.h" using namespace std; TextBoost::TextBoost(unsigned int l,const char * p) { tbuff = new char[len = l]; *tbuff = 0; // Argument p is a pointer to a string that should be placed // on start of string all time. When you reseet TextBoost, its // cursor shall be placed just after that text. // // Main buffer is tbuff, buffer that you shall realy use most // of time is part of tbuff which start with buff. // // When you convert this object as char*, you'll get pointer // to tbuff. if(p) { buff = tbuff; while(*p) { *(buff++) = *(p++); } len -= strl(p); *buff = 0; } else buff = tbuff; buff[len-1]=0; mae = new strstream(buff, len-1); }