GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-prcstrm.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <cstdio>
31 
32 #include "oct-prcstrm.h"
33 #include "sysdep.h"
34 
36 octave_iprocstream::create (const std::string& n, std::ios::openmode arg_md,
38  const std::string& encoding)
39 {
40  return octave::stream (new octave_iprocstream (n, arg_md, ff, encoding));
41 }
42 
44  std::ios::openmode arg_md,
46  const std::string& encoding)
47  : octave_stdiostream (n, octave::popen (n.c_str (), "r"),
48  arg_md, ff, encoding, octave::pclose)
49 { }
50 
52 {
53  do_close ();
54 }
55 
57 octave_oprocstream::create (const std::string& n, std::ios::openmode arg_md,
59  const std::string& encoding)
60 {
61  return octave::stream (new octave_oprocstream (n, arg_md, ff, encoding));
62 }
63 
65  std::ios::openmode arg_md,
67  const std::string& encoding)
68  : octave_stdiostream (n, octave::popen (n.c_str (), "w"),
69  arg_md, ff, encoding, octave::pclose)
70 { }
71 
73 {
74  do_close ();
75 }
std::string encoding(void) const
Definition: oct-stream.h:159
octave_iprocstream(const std::string &n, std::ios::openmode arg_md=std::ios::in, octave::mach_info::float_format flt_fmt=octave::mach_info::native_float_format(), const std::string &encoding="utf-8")
Definition: oct-prcstrm.cc:43
static octave::stream create(const std::string &n, std::ios::openmode arg_md=std::ios::in, octave::mach_info::float_format flt_fmt=octave::mach_info::native_float_format(), const std::string &encoding="utf-8")
Definition: oct-prcstrm.cc:36
octave_oprocstream(const std::string &n, std::ios::openmode arg_md=std::ios::out, octave::mach_info::float_format flt_fmt=octave::mach_info::native_float_format(), const std::string &encoding="utf-8")
Definition: oct-prcstrm.cc:64
static octave::stream create(const std::string &n, std::ios::openmode arg_md=std::ios::out, octave::mach_info::float_format flt_fmt=octave::mach_info::native_float_format(), const std::string &encoding="utf-8")
Definition: oct-prcstrm.cc:57
octave_idx_type n
Definition: mx-inlines.cc:753
FILE * popen(const char *command, const char *mode)
Definition: sysdep.cc:619
int pclose(FILE *f)
Definition: sysdep.cc:643