Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
subprocess::Popen Class Reference

#include <subprocess.h>

Collaboration diagram for subprocess::Popen:
[legend]

Public Member Functions

template<typename... Args>
 Popen (const std::string &cmd_args, Args &&...args)
 
template<typename... Args>
 Popen (std::initializer_list< const char * > cmd_args, Args &&...args)
 
template<typename... Args>
 Popen (std::vector< std::string > vargs_, Args &&... args)
 
int retcode () const noexcept
 
int wait () noexcept(false)
 
void set_out_buf_cap (size_t cap)
 
void set_err_buf_cap (size_t cap)
 
int send (const char *msg, size_t length)
 
int send (const std::string &msg)
 
int send (const std::vector< char > &msg)
 
std::pair< OutBuffer, ErrBuffercommunicate (const char *msg, size_t length)
 
std::pair< OutBuffer, ErrBuffercommunicate (const std::string &msg)
 
std::pair< OutBuffer, ErrBuffercommunicate (const std::vector< char > &msg)
 
std::pair< OutBuffer, ErrBuffercommunicate ()
 

Private Member Functions

template<typename F , typename... Args>
void init_args (F &&farg, Args &&... args)
 
void init_args ()
 
void populate_c_argv ()
 
void execute_process () noexcept(false)
 

Private Attributes

detail::Streams stream_
 
std::string exe_name_
 
std::string args_
 
std::vector< std::string > vargs_
 
std::vector< char * > cargv_
 
int child_pid_ = -1
 
int retcode_ = -1
 

Friends

struct detail::ArgumentDeducer
 
class detail::Child
 

Detailed Description

class: Popen This is the single most important class in the whole library and glues together all the helper classes to provide a common interface to the client.

API's provided by the class: Popen({"cmd"}, output{..}, error{..}, ....) Command provided as a sequence. Popen("cmd arg1", output{..}, error{..}, ....) Command provided in a single string. wait() - Wait for the child to exit. retcode() - The return code of the exited child. send(...) - Send input to the input channel of the child. communicate(...) - Get the output/error from the child and close the channels from the parent side.

Definition at line 909 of file subprocess.h.

Constructor & Destructor Documentation

◆ Popen() [1/3]

template<typename... Args>
subprocess::Popen::Popen ( const std::string &  cmd_args,
Args &&...  args 
)
inline

Definition at line 916 of file subprocess.h.

Here is the call graph for this function:

◆ Popen() [2/3]

template<typename... Args>
subprocess::Popen::Popen ( std::initializer_list< const char * >  cmd_args,
Args &&...  args 
)
inline

Definition at line 929 of file subprocess.h.

Here is the call graph for this function:

◆ Popen() [3/3]

template<typename... Args>
subprocess::Popen::Popen ( std::vector< std::string >  vargs_,
Args &&...  args 
)
inline

Definition at line 941 of file subprocess.h.

Here is the call graph for this function:

Member Function Documentation

◆ communicate() [1/4]

std::pair< OutBuffer, ErrBuffer > subprocess::Popen::communicate ( )
inline

Definition at line 987 of file subprocess.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ communicate() [2/4]

std::pair< OutBuffer, ErrBuffer > subprocess::Popen::communicate ( const char *  msg,
size_t  length 
)
inline

Definition at line 968 of file subprocess.h.

Here is the call graph for this function:

◆ communicate() [3/4]

std::pair< OutBuffer, ErrBuffer > subprocess::Popen::communicate ( const std::string &  msg)
inline

Definition at line 975 of file subprocess.h.

Here is the call graph for this function:

◆ communicate() [4/4]

std::pair< OutBuffer, ErrBuffer > subprocess::Popen::communicate ( const std::vector< char > &  msg)
inline

Definition at line 980 of file subprocess.h.

Here is the call graph for this function:

◆ execute_process()

void subprocess::Popen::execute_process ( )
inlineprivatenoexcept

Definition at line 1062 of file subprocess.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_args() [1/2]

void subprocess::Popen::init_args ( )
inlineprivate

Definition at line 1021 of file subprocess.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_args() [2/2]

template<typename F , typename... Args>
void subprocess::Popen::init_args ( F &&  farg,
Args &&...  args 
)
inlineprivate

Definition at line 1026 of file subprocess.h.

Here is the call graph for this function:

◆ populate_c_argv()

void subprocess::Popen::populate_c_argv ( )
inlineprivate

Definition at line 1033 of file subprocess.h.

Here is the caller graph for this function:

◆ retcode()

int subprocess::Popen::retcode ( ) const
inlinenoexcept

Definition at line 951 of file subprocess.h.

Here is the caller graph for this function:

◆ send() [1/3]

int subprocess::Popen::send ( const char *  msg,
size_t  length 
)
inline

Definition at line 959 of file subprocess.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send() [2/3]

int subprocess::Popen::send ( const std::string &  msg)
inline

Definition at line 962 of file subprocess.h.

Here is the call graph for this function:

◆ send() [3/3]

int subprocess::Popen::send ( const std::vector< char > &  msg)
inline

Definition at line 965 of file subprocess.h.

Here is the call graph for this function:

◆ set_err_buf_cap()

void subprocess::Popen::set_err_buf_cap ( size_t  cap)
inline

Definition at line 957 of file subprocess.h.

Here is the call graph for this function:

◆ set_out_buf_cap()

void subprocess::Popen::set_out_buf_cap ( size_t  cap)
inline

Definition at line 955 of file subprocess.h.

Here is the call graph for this function:

◆ wait()

int subprocess::Popen::wait ( )
inlinenoexcept

Definition at line 1041 of file subprocess.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ detail::ArgumentDeducer

friend struct detail::ArgumentDeducer
friend

Definition at line 912 of file subprocess.h.

◆ detail::Child

friend class detail::Child
friend

Definition at line 913 of file subprocess.h.

Member Data Documentation

◆ args_

std::string subprocess::Popen::args_
private

Definition at line 1010 of file subprocess.h.

◆ cargv_

std::vector<char*> subprocess::Popen::cargv_
private

Definition at line 1013 of file subprocess.h.

◆ child_pid_

int subprocess::Popen::child_pid_ = -1
private

Definition at line 1016 of file subprocess.h.

◆ exe_name_

std::string subprocess::Popen::exe_name_
private

Definition at line 1007 of file subprocess.h.

◆ retcode_

int subprocess::Popen::retcode_ = -1
private

Definition at line 1018 of file subprocess.h.

◆ stream_

detail::Streams subprocess::Popen::stream_
private

Definition at line 1000 of file subprocess.h.

◆ vargs_

std::vector<std::string> subprocess::Popen::vargs_
private

Definition at line 1012 of file subprocess.h.


The documentation for this class was generated from the following file: