00001 // Filename: lineStreamBuf.h 00002 // Created by: drose (26Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef LINESTREAMBUF_H 00020 #define LINESTREAMBUF_H 00021 00022 #include <pandabase.h> 00023 00024 #include <string> 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : LineStreamBuf 00028 // Description : Used by LineStream to implement an ostream that 00029 // writes to a memory buffer, whose contents can be 00030 // continuously extracted as a sequence of lines of 00031 // text. 00032 //////////////////////////////////////////////////////////////////// 00033 class EXPCL_PANDA LineStreamBuf : public streambuf { 00034 public: 00035 LineStreamBuf(); 00036 virtual ~LineStreamBuf(); 00037 00038 INLINE bool is_text_available() const; 00039 string get_line(); 00040 INLINE bool has_newline() const; 00041 00042 protected: 00043 virtual int overflow(int c); 00044 virtual int sync(); 00045 00046 private: 00047 INLINE void write_chars(const char *start, int length); 00048 00049 string _data; 00050 bool _has_newline; 00051 }; 00052 00053 #include "lineStreamBuf.I" 00054 00055 #endif