Panda3D
|
00001 // Filename: lineStreamBuf.h 00002 // Created by: drose (26Feb00) 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 LINESTREAMBUF_H 00016 #define LINESTREAMBUF_H 00017 00018 #include "pandabase.h" 00019 00020 #include <string> 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : LineStreamBuf 00024 // Description : Used by LineStream to implement an ostream that 00025 // writes to a memory buffer, whose contents can be 00026 // continuously extracted as a sequence of lines of 00027 // text. 00028 //////////////////////////////////////////////////////////////////// 00029 class EXPCL_PANDA_PUTIL LineStreamBuf : public streambuf { 00030 public: 00031 LineStreamBuf(); 00032 virtual ~LineStreamBuf(); 00033 00034 INLINE bool is_text_available() const; 00035 string get_line(); 00036 INLINE bool has_newline() const; 00037 00038 protected: 00039 virtual int overflow(int c); 00040 virtual int sync(); 00041 00042 private: 00043 INLINE void write_chars(const char *start, int length); 00044 00045 string _data; 00046 bool _has_newline; 00047 }; 00048 00049 #include "lineStreamBuf.I" 00050 00051 #endif