![]() |
Octave-Forge - Extra packages for GNU Octave |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2002, 2005, 2006, 00004 2007, 2009 John W. Eaton 00005 00006 This file is part of Octave. 00007 00008 Octave is free software; you can redistribute it and/or modify it 00009 under the terms of the GNU General Public License as published by the 00010 Free Software Foundation; either version 3 of the License, or (at your 00011 option) any later version. 00012 00013 Octave is distributed in the hope that it will be useful, but WITHOUT 00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Octave; see the file COPYING. If not, see 00020 <http://www.gnu.org/licenses/>. 00021 00022 */ 00023 00024 #if !defined (octave_pager_h) 00025 #define octave_pager_h 1 00026 00027 #include <iosfwd> 00028 #include <sstream> 00029 #include <string> 00030 00031 #ifdef HAVE_SYS_TYPES_H 00032 #include <sys/types.h> 00033 #endif 00034 00035 class 00036 OCTINTERP_API 00037 octave_pager_buf : public std::stringbuf 00038 { 00039 public: 00040 00041 octave_pager_buf (void) : std::stringbuf (), diary_skip (0) { } 00042 00043 void flush_current_contents_to_diary (void); 00044 00045 void set_diary_skip (void); 00046 00047 protected: 00048 00049 int sync (void); 00050 00051 private: 00052 00053 size_t diary_skip; 00054 }; 00055 00056 class 00057 OCTINTERP_API 00058 octave_pager_stream : public std::ostream 00059 { 00060 protected: 00061 00062 octave_pager_stream (void); 00063 00064 public: 00065 00066 ~octave_pager_stream (void); 00067 00068 void flush_current_contents_to_diary (void); 00069 00070 void set_diary_skip (void); 00071 00072 static octave_pager_stream& stream (void); 00073 00074 private: 00075 00076 static octave_pager_stream *instance; 00077 00078 octave_pager_buf *pb; 00079 00080 // No copying! 00081 00082 octave_pager_stream (const octave_pager_stream&); 00083 00084 octave_pager_stream& operator = (const octave_pager_stream&); 00085 }; 00086 00087 class 00088 OCTINTERP_API 00089 octave_diary_buf : public std::stringbuf 00090 { 00091 public: 00092 00093 octave_diary_buf (void) : std::stringbuf () { } 00094 00095 protected: 00096 00097 int sync (void); 00098 }; 00099 00100 class 00101 OCTINTERP_API 00102 octave_diary_stream : public std::ostream 00103 { 00104 protected: 00105 00106 octave_diary_stream (void); 00107 00108 public: 00109 00110 ~octave_diary_stream (void); 00111 00112 static octave_diary_stream& stream (void); 00113 00114 private: 00115 00116 static octave_diary_stream *instance; 00117 00118 octave_diary_buf *db; 00119 00120 // No copying! 00121 00122 octave_diary_stream (const octave_diary_stream&); 00123 00124 octave_diary_stream& operator = (const octave_diary_stream&); 00125 }; 00126 00127 #define octave_stdout (octave_pager_stream::stream ()) 00128 00129 #define octave_diary (octave_diary_stream::stream ()) 00130 00131 extern OCTINTERP_API void flush_octave_stdout (void); 00132 00133 #endif 00134 00135 /* 00136 ;;; Local Variables: *** 00137 ;;; mode: C++ *** 00138 ;;; End: *** 00139 */