GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
procstream.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1993-2025 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 <iomanip>
31
32#include "procstream.h"
33
35
36procstreambase::procstreambase (const std::string& command, int mode)
37{
38 pb_init ();
39
40 if (! m_pb.open (command.c_str (), mode))
41 std::ios::setstate (std::ios::badbit);
42}
43
44procstreambase::procstreambase (const char *command, int mode)
45{
46 pb_init ();
47
48 if (! m_pb.open (command, mode))
49 std::ios::setstate (std::ios::badbit);
50}
51
52void
53procstreambase::open (const char *command, int mode)
54{
55 clear ();
56
57 if (! m_pb.open (command, mode))
58 std::ios::setstate (std::ios::badbit);
59}
60
61int
63{
64 int status = 0;
65
66 if (is_open ())
67 {
68 if (! m_pb.close ())
69 std::ios::setstate (std::ios::failbit);
70
71 status = m_pb.wait_status ();
72 }
73
74 return status;
75}
76
77OCTAVE_END_NAMESPACE(octave)
procbuf * close()
procbuf * open(const char *command, int mode)
int wait_status() const
Definition oct-procbuf.h:62
void open(const std::string &name, int mode)
Definition procstream.h:54
int is_open() const
Definition procstream.h:61
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn