VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gexecutable.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
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 gexecutable.h
19 ///
20 
21 #ifndef G_EXE_H
22 #define G_EXE_H
23 
24 #include "gdef.h"
25 #include "gpath.h"
26 #include "gstrings.h"
27 #include <string>
28 
29 namespace G
30 {
31  class Executable ;
32 }
33 
34 /// \class G::Executable
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.
38 ///
39 /// \see G::Path, G::Args
40 ///
42 {
43 public:
44  explicit Executable( const std::string & command_line = std::string() ) ;
45  ///< Constructor taking a complete command-line. The command-line
46  ///< is split up on unescaped space characters.
47 
48  Executable( const G::Path & exe , const StringArray & args ) ;
49  ///< Constructor taking the executable and arguments explicitly.
50 
51  Path exe() const ;
52  ///< Returns the executable.
53 
54  StringArray args() const ;
55  ///< Returns the command-line arguments.
56 
57  void add( const std::string & arg ) ;
58  ///< Adds a command-line argument.
59 
60  std::string displayString() const ;
61  ///< Returns a printable representation for logging and diagnostics.
62 
63 private:
64  bool osNativelyRunnable() const ;
65  void osAddWrapper() ;
66 
67 private:
68  G::Path m_exe ;
69  G::StringArray m_args ;
70 } ;
71 
72 #endif
A structure representing an external program, holding a path and a set of arguments.
Definition: gexecutable.h:41
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstrings.h:33
StringArray args() const
Returns the command-line arguments.
Definition: gexecutable.cpp:75
Executable(const std::string &command_line=std::string())
Constructor taking a complete command-line.
Definition: gexecutable.cpp:26
std::string displayString() const
Returns a printable representation for logging and diagnostics.
Definition: gexecutable.cpp:80
void add(const std::string &arg)
Adds a command-line argument.
Definition: gexecutable.cpp:88
A Path object represents a file system path.
Definition: gpath.h:72
Path exe() const
Returns the executable.
Definition: gexecutable.cpp:70