00001 // 00002 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2005 00003 // 00004 // Copyright: See COPYING file that comes with this distribution 00005 // 00006 // 00007 #ifndef LINEBUFFER_H 00008 #define LINEBUFFER_H 00009 00010 #include <string> 00011 #include <set> 00012 #include <boost/shared_ptr.hpp> 00013 00014 #include <sstream> 00015 00016 namespace srchilite { 00017 00021 class LineBuffer { 00022 public: 00024 typedef std::set<std::string> PostContents; 00025 00026 private: 00027 ostringstream buffer; 00028 PostContents post; 00029 00030 public: 00031 LineBuffer() { 00032 } 00033 ~LineBuffer() { 00034 } 00035 00039 void output(const std::string &s) { 00040 buffer << s; 00041 } 00042 00046 void output_post(const std::string &s) { 00047 post.insert(s); 00048 } 00049 00053 const std::string getContents() const { 00054 return buffer.str(); 00055 } 00056 00060 const PostContents &getPostContents() const { 00061 return post; 00062 } 00063 00067 bool empty() const { 00068 return (buffer.str().size() == 0 && post.size() == 0); 00069 } 00070 }; 00071 00073 typedef boost::shared_ptr<LineBuffer> LineBufferPtr; 00074 00075 } 00076 00077 #endif