E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gexecutablecommand.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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
29 namespace 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 ///
43 class G::ExecutableCommand
44 {
45 public:
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
65 private:
66 bool osNativelyRunnable() const ;
67 void osAddWrapper() ;
68 static G::StringArray osSplit( const std::string & ) ;
69
70 private:
71 G::Path m_exe ;
72 G::StringArray m_args ;
73 } ;
74
75 #endif
gstrings.h
G::ExecutableCommand::add
void add(const std::string &arg)
Adds a command-line argument.
Definition: gexecutablecommand.cpp:80
G::StringArray
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstrings.h:33
G::ExecutableCommand::args
StringArray args() const
Returns the command-line arguments.
Definition: gexecutablecommand.cpp:67
G::ExecutableCommand::ExecutableCommand
ExecutableCommand(const std::string &command_line=std::string())
Constructor taking a complete command-line.
Definition: gexecutablecommand.cpp:26
G
Low-level classes.
Definition: garg.h:29
G::ExecutableCommand::exe
Path exe() const
Returns the executable.
Definition: gexecutablecommand.cpp:62
G::ExecutableCommand
A structure representing an external program, holding a path and a set of arguments.
Definition: gexecutablecommand.h:43
G::ExecutableCommand::displayString
std::string displayString() const
Returns a printable representation for logging and diagnostics.
Definition: gexecutablecommand.cpp:72
gpath.h
G::Path
A Path object represents a file system path.
Definition: gpath.h:72