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