2081
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2081
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include <cstdio> |
|
28 |
|
29 #include "oct-prcstrm.h" |
|
30 |
3340
|
31 octave_stream |
3544
|
32 octave_iprocstream::create (const std::string& n, std::ios::openmode arg_md, |
3340
|
33 oct_mach_info::float_format flt_fmt) |
|
34 { |
|
35 return octave_stream (new octave_iprocstream (n, arg_md, flt_fmt)); |
|
36 } |
|
37 |
3523
|
38 octave_iprocstream::octave_iprocstream (const std::string& n, |
3544
|
39 std::ios::openmode arg_md, |
2317
|
40 oct_mach_info::float_format flt_fmt) |
|
41 : octave_istdiostream (n, 0, arg_md, flt_fmt) |
2081
|
42 { |
|
43 fp = popen (n.c_str (), "r"); |
|
44 |
|
45 if (fp) |
|
46 { |
|
47 delete is; |
3523
|
48 is = new std::istdiostream (fp); |
2081
|
49 } |
|
50 } |
|
51 |
|
52 octave_iprocstream::~octave_iprocstream (void) |
|
53 { |
|
54 if (fp) |
|
55 { |
|
56 pclose (fp); |
|
57 fp = 0; |
|
58 } |
|
59 } |
|
60 |
3340
|
61 octave_stream |
3544
|
62 octave_oprocstream::create (const std::string& n, std::ios::openmode arg_md, |
3340
|
63 oct_mach_info::float_format flt_fmt) |
|
64 { |
|
65 return octave_stream (new octave_oprocstream (n, arg_md, flt_fmt)); |
|
66 } |
|
67 |
3523
|
68 octave_oprocstream::octave_oprocstream (const std::string& n, |
3544
|
69 std::ios::openmode arg_md, |
2317
|
70 oct_mach_info::float_format flt_fmt) |
|
71 : octave_ostdiostream (n, 0, arg_md, flt_fmt) |
2081
|
72 { |
|
73 fp = popen (n.c_str (), "w"); |
|
74 |
|
75 if (fp) |
|
76 { |
|
77 delete os; |
3523
|
78 os = new std::ostdiostream (fp); |
2081
|
79 } |
|
80 } |
|
81 |
|
82 octave_oprocstream::~octave_oprocstream (void) |
|
83 { |
|
84 if (fp) |
|
85 { |
|
86 pclose (fp); |
|
87 fp = 0; |
|
88 } |
|
89 } |
|
90 |
|
91 /* |
|
92 ;;; Local Variables: *** |
|
93 ;;; mode: C++ *** |
|
94 ;;; End: *** |
|
95 */ |