annotate libinterp/corefcn/oct-process.h @ 33645:42355b7ec5d7 bytecode-interpreter tip

maint: Merge default to bytecode-interpreter.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Tue, 04 Jun 2024 11:00:11 -0400
parents 4b601ca024d5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31855
diff changeset
3 // Copyright (C) 2019-2024 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
25
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
26 #if ! defined (oct_process_h)
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
27 #define oct_process_h 1
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
28
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
29 #include "octave-config.h"
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
30
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
31 #include <string>
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
32
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
33 OCTAVE_BEGIN_NAMESPACE(octave)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
34
32628
ae4e19c0a2b1 maint: Place class name and class keyword on one line.
Rik <rik@octave.org>
parents: 31855
diff changeset
35 class process_execution_result
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
36 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
37 public:
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
38
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
39 process_execution_result ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
40 : m_status (-1), m_err_msg (), m_exit_status (-1), m_stdout_output ()
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
41 { }
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
42
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
43 process_execution_result (int status, int exit_status,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
44 const std::string& stdout_output,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
45 const std::string& err_msg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
46 : m_status (status), m_err_msg (err_msg), m_exit_status (exit_status),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
47 m_stdout_output (stdout_output)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
48 { }
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
49
31855
1daf8bfceac3 default or disable more ctors, dtors, and assignment ops
John W. Eaton <jwe@octave.org>
parents: 31771
diff changeset
50 OCTAVE_DEFAULT_COPY_MOVE_DELETE (process_execution_result)
1daf8bfceac3 default or disable more ctors, dtors, and assignment ops
John W. Eaton <jwe@octave.org>
parents: 31771
diff changeset
51
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
52 static OCTINTERP_API process_execution_result
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
53 of_success (int exit_status, const std::string& stdout_output);
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
54
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
55 static OCTINTERP_API process_execution_result
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
56 of_error (int status, const std::string& err_msg);
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
57
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
58 int status () const { return m_status; }
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
59
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
60 int exit_status () const { return m_exit_status; }
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
61
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
62 std::string err_msg () const { return m_err_msg; }
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
63
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31706
diff changeset
64 std::string stdout_output () const { return m_stdout_output; }
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
65
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
66 private:
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
67
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
68 // Launch status of the process, 0 for success, nonzero for error.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
69 int m_status;
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
70
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
71 // Error message if executing command failed.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
72 std::string m_err_msg;
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
73
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
74 // Exit status of the process.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
75 int m_exit_status;
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
76
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
77 // Collected stdout output of the process.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
78 std::string m_stdout_output;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
79 };
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
80
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
81 extern OCTINTERP_API process_execution_result
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
82 run_command_and_return_output (const std::string& cmd_str);
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
83
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
84 OCTAVE_END_NAMESPACE(octave)
27002
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
85
c04329ead503 new class for executing commands and getting result
Andrew Janke <andrew@apjanke.net>
parents:
diff changeset
86 #endif