E-MailRelay
gexecutablecommand.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gexecutablecommand.h
19///
20
21#ifndef G_EXECUTABLE_COMMAND_H
22#define G_EXECUTABLE_COMMAND_H
23
24#include "gdef.h"
25#include "gpath.h"
26#include "gstrings.h"
27#include <string>
28
29namespace G
30{
31 class ExecutableCommand ;
32}
33
34//| \class G::ExecutableCommand
35/// A structure representing an external program, holding a path and a set of
36/// arguments. The constructor takes a complete command-line and splits it up
37/// into the executable part and a list of command-line parameters. If the
38/// command-line starts with a script then the contructed command-line may
39/// be for the appropriate interpreter (depending on the o/s).
40///
41/// \see G::Path, G::Args
42///
44{
45public:
46 explicit ExecutableCommand( const std::string & command_line = std::string() ) ;
47 ///< Constructor taking a complete command-line. The command-line
48 ///< is split up on unescaped-and-unquoted space characters.
49
50 ExecutableCommand( const G::Path & exe , const StringArray & args , bool os_add_wrapper = true ) ;
51 ///< Constructor taking the executable and arguments explicitly.
52
53 Path exe() const ;
54 ///< Returns the executable.
55
56 StringArray args() const ;
57 ///< Returns the command-line arguments.
58
59 void add( const std::string & arg ) ;
60 ///< Adds a command-line argument.
61
62 std::string displayString() const ;
63 ///< Returns a printable representation for logging and diagnostics.
64
65private:
66 bool osNativelyRunnable() const ;
67 void osAddWrapper() ;
68
69private:
70 G::Path m_exe ;
71 G::StringArray m_args ;
72} ;
73
74#endif
A structure representing an external program, holding a path and a set of arguments.
ExecutableCommand(const std::string &command_line=std::string())
Constructor taking a complete command-line.
void add(const std::string &arg)
Adds a command-line argument.
StringArray args() const
Returns the command-line arguments.
std::string displayString() const
Returns a printable representation for logging and diagnostics.
Path exe() const
Returns the executable.
A Path object represents a file system path.
Definition: gpath.h:72
Low-level classes.
Definition: galign.h:28
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstrings.h:31