Mercurial > hg > octave-lyh
annotate src/procstream.h @ 11446:67e3edbf8ff7
Update list of keywords in Grammar chapter of documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 05 Jan 2011 20:22:12 -0800 |
parents | 0522a65bcd56 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, |
9245 | 4 2004, 2005, 2006, 2007, 2009 John W. Eaton |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
383 | 24 #if !defined (octave_procstream_h) |
25 #define octave_procstream_h 1 | |
1 | 26 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
27 #include <iosfwd> |
4051 | 28 #include <string> |
2095 | 29 |
30 #include <sys/types.h> | |
31 | |
32 #include "oct-procbuf.h" | |
1 | 33 |
34 class | |
6109 | 35 OCTINTERP_API |
3544 | 36 procstreambase : virtual public std::ios |
1 | 37 { |
1380 | 38 public: |
1965 | 39 |
40 procstreambase (void) { pb_init (); } | |
41 | |
4051 | 42 procstreambase (const std::string& name, int mode); |
43 | |
1965 | 44 procstreambase (const char *name, int mode); |
1380 | 45 |
1965 | 46 ~procstreambase (void) { close (); } |
1 | 47 |
4051 | 48 void open (const std::string& name, int mode) |
49 { open (name.c_str (), mode); } | |
50 | |
1965 | 51 void open (const char *name, int mode); |
1380 | 52 |
1965 | 53 int is_open (void) const { return pb.is_open (); } |
1 | 54 |
483 | 55 int close (void); |
1380 | 56 |
6316 | 57 pid_t pid (void) const { return pb.pid (); } |
58 | |
59 int file_number (void) const { return pb.file_number (); } | |
2095 | 60 |
1380 | 61 private: |
1965 | 62 |
2095 | 63 octave_procbuf pb; |
1965 | 64 |
65 void pb_init (void) { init (&pb); } | |
66 | |
67 procstreambase (const procstreambase&); | |
68 | |
69 procstreambase& operator = (const procstreambase&); | |
1 | 70 }; |
71 | |
1965 | 72 class |
6109 | 73 OCTINTERP_API |
3775 | 74 iprocstream : public std::istream, public procstreambase |
75 // iprocstream : public procstreambase, public std::istream | |
1965 | 76 { |
77 public: | |
78 | |
3775 | 79 iprocstream (void) : std::istream (0), procstreambase () { } |
1965 | 80 |
4051 | 81 iprocstream (const std::string& name, int mode = std::ios::in) |
82 : std::istream (0), procstreambase (name, mode) { } | |
83 | |
3544 | 84 iprocstream (const char *name, int mode = std::ios::in) |
3775 | 85 : std::istream (0), procstreambase (name, mode) { } |
1965 | 86 |
87 ~iprocstream (void) { } | |
88 | |
4051 | 89 void open (const std::string& name, int mode = std::ios::in) |
90 { procstreambase::open (name, mode); } | |
91 | |
3544 | 92 void open (const char *name, int mode = std::ios::in) |
3189 | 93 { procstreambase::open (name, mode); } |
1965 | 94 |
95 private: | |
96 | |
97 iprocstream (const iprocstream&); | |
98 | |
99 iprocstream& operator = (const iprocstream&); | |
100 }; | |
1448 | 101 |
1 | 102 class |
6109 | 103 OCTINTERP_API |
3775 | 104 oprocstream : public std::ostream, public procstreambase |
105 // oprocstream : public procstreambase, public std::ostream | |
1 | 106 { |
1380 | 107 public: |
1965 | 108 |
3775 | 109 oprocstream (void) : std::ostream (0), procstreambase () { } |
1 | 110 |
4051 | 111 oprocstream (const std::string& name, int mode = std::ios::out) |
112 : std::ostream (0), procstreambase(name, mode) { } | |
113 | |
3544 | 114 oprocstream (const char *name, int mode = std::ios::out) |
3775 | 115 : std::ostream (0), procstreambase(name, mode) { } |
1 | 116 |
1965 | 117 ~oprocstream (void) { } |
1380 | 118 |
4051 | 119 void open (const std::string& name, int mode = std::ios::out) |
120 { procstreambase::open (name, mode); } | |
121 | |
3544 | 122 void open (const char *name, int mode = std::ios::out) |
3652 | 123 { procstreambase::open (name, mode); } |
1380 | 124 |
125 private: | |
1965 | 126 |
127 oprocstream (const oprocstream&); | |
128 | |
129 oprocstream& operator = (const oprocstream&); | |
1 | 130 }; |
131 | |
1965 | 132 class |
6109 | 133 OCTINTERP_API |
3775 | 134 procstream : public std::iostream, public procstreambase |
135 // procstream : public procstreambase, public std::iostream | |
1965 | 136 { |
137 public: | |
138 | |
3775 | 139 procstream (void) : std::iostream (0), procstreambase () { } |
1965 | 140 |
4051 | 141 procstream (const std::string& name, int mode) |
142 : std::iostream (0), procstreambase (name, mode) { } | |
143 | |
1965 | 144 procstream (const char *name, int mode) |
3775 | 145 : std::iostream (0), procstreambase (name, mode) { } |
1965 | 146 |
147 ~procstream (void) { } | |
148 | |
4051 | 149 void open (const std::string& name, int mode) |
150 { procstreambase::open (name, mode); } | |
151 | |
1965 | 152 void open (const char *name, int mode) |
3652 | 153 { procstreambase::open (name, mode); } |
1965 | 154 |
155 private: | |
156 | |
157 procstream (const procstream&); | |
158 | |
159 procstream& operator = (const procstream&); | |
160 }; | |
1448 | 161 |
1 | 162 #endif |