wex  v21.04.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
wex::process Class Reference

Offers a process, capturing execution output. More...

#include <wex/process.h>

Inheritance diagram for wex::process:
Inheritance graph
[legend]

Public Types

enum  exec_t { EXEC_NO_WAIT , EXEC_WAIT }
 process execute type More...
 

Public Member Functions

 process ()
 Other methods. More...
 
virtual ~process ()
 Destructor.
 
 process (const process &process)
 Copy constructor.
 
processoperator= (const process &p)
 Assignment operator.
 
bool execute (const std::string &command=std::string(), exec_t type=EXEC_NO_WAIT, const std::string &wd=std::string())
 Executes the process. More...
 
const auto & get_exec () const
 Returns command.
 
auto * get_frame ()
 Returns the frame.
 
const auto & get_stderr () const
 Returns the stderr.
 
const auto & get_stdout () const
 Returns the stdout.
 
bool is_debug () const
 Is this a debug process.
 
bool is_running () const
 Returns true if this process is running.
 
virtual void show_output (const std::string &caption=std::string()) const
 Shows stdout or stderr from execute on the shell component. More...
 
bool stop ()
 Stops this process. More...
 
bool write (const std::string &text)
 Writes text to stdin of process. More...
 

Static Public Member Functions

static int config_dialog (const data::window &data=data::window())
 Static interface. More...
 
static auto * get_shell ()
 Returns the shell component (might be nullptr if prepare_output is not yet invoked).
 
static shellprepare_output (wxWindow *parent)
 Construct the shell component, and returns it.
 

Detailed Description

Offers a process, capturing execution output.

Member Enumeration Documentation

◆ exec_t

process execute type

  • EXEC_NO_WAIT this call immediately returns. The stc component will be filled with output from the process.
  • EXEC_WAIT this call returns after execute ends, and the output is available using get_stdout.
Enumerator
EXEC_NO_WAIT 

do not wait

EXEC_WAIT 

wait for process finish

Constructor & Destructor Documentation

◆ process()

wex::process::process ( )

Other methods.

Default constructor.

Member Function Documentation

◆ config_dialog()

static int wex::process::config_dialog ( const data::window data = data::window())
static

Static interface.

Shows a config dialog, allowing you to set the command and folder. Returns dialog return code.

◆ execute()

bool wex::process::execute ( const std::string &  command = std::string(),
exec_t  type = EXEC_NO_WAIT,
const std::string &  wd = std::string() 
)

Executes the process.

Return value is false if process could not execute, or if config dialog was invoked and cancelled.

Parameters
commandcommand to be executed, if empty last given command is used
typeprocess execute type
wdworking dir, if empty last working dir is used

◆ show_output()

virtual void wex::process::show_output ( const std::string &  caption = std::string()) const
virtual

Shows stdout or stderr from execute on the shell component.

You can override this method to e.g. prepare a lexer on get_shell before calling this base method.

Reimplemented in wex::vcs_entry.

◆ stop()

bool wex::process::stop ( )

Stops this process.

Returns true if stop is ok.

◆ write()

bool wex::process::write ( const std::string &  text)

Writes text to stdin of process.

Default the response stdout is collected in the shell,