Panda3D
 All Classes Functions Variables Enumerations
wordWrapStreamBuf.h
00001 // Filename: wordWrapStreamBuf.h
00002 // Created by:  drose (28Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef WORDWRAPSTREAMBUF_H
00016 #define WORDWRAPSTREAMBUF_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include <string>
00021 
00022 class ProgramBase;
00023 class WordWrapStream;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : WordWrapStreamBuf
00027 // Description : Used by WordWrapStream to implement an ostream that
00028 //               flushes its output to ProgramBase::show_text().
00029 ////////////////////////////////////////////////////////////////////
00030 class WordWrapStreamBuf : public streambuf {
00031 public:
00032   WordWrapStreamBuf(WordWrapStream *owner, ProgramBase *program);
00033   virtual ~WordWrapStreamBuf();
00034 
00035 protected:
00036   virtual int overflow(int c);
00037   virtual int sync();
00038 
00039 private:
00040   void write_chars(const char *start, int length);
00041   INLINE void set_literal_mode(bool mode);
00042   void flush_data();
00043 
00044   string _data;
00045   WordWrapStream *_owner;
00046   ProgramBase *_program;
00047   bool _literal_mode;
00048 };
00049 
00050 #include "wordWrapStreamBuf.I"
00051 
00052 #endif
 All Classes Functions Variables Enumerations