subprocess namespace

Namespaces

namespace exceptions
namespace literals
namespace posix_util

Classes

class command
Main interface class for subprocess library.
class descriptor
Abstracts file descriptors.
struct err_t
A tag representing stderr of a process.
class file_descriptor
Wraps a descriptor mapping to a file on the disc.
class idescriptor
Adds read ability to descriptor.
class ifile_descriptor
Always opens the file in read-mode.
struct in_t
A tag representing stdin of a process.
class ipipe_descriptor
A descriptor wrapping the input end of a posix OS pipe.
class ivariable_descriptor
class odescriptor
Adds write ability to descriptor.
class ofile_descriptor
Always opens the file in write-mode.
class opipe_descriptor
A descriptor wrapping the output end of a posix OS pipe.
struct out_t
A tag representing stdout of a process.
class ovariable_descriptor
class posix_process
Abstraction of a POSIX process with stdin, stdout, and stderr.

Typedefs

template<typename T>
using descriptor_ptr_t = std::enable_if_t<std::is_base_of_v<descriptor, T>, std::shared_ptr<T>>
A shorthand for describing a descriptor ptr.
using descriptor_ptr = descriptor_ptr_t<descriptor>
A shorthand for denoting an owning-pointer for the descriptor base class.
using process_t = posix_process

Functions

template<typename T, typename... Args>
auto make_descriptor(Args && ... args) -> descriptor_ptr_t<T>
Wraps std::make_unique. Used only for self-documentation purposes.
auto create_pipe() -> std::pair<descriptor_ptr_t<ipipe_descriptor>, descriptor_ptr_t<opipe_descriptor>>
Create opipe_descriptor and ipipe_descriptor objects and links them.
auto std_in() -> descriptor_ptr
Returns an abstraction of stdout file descriptor.
auto std_out() -> descriptor_ptr
Returns an abstraction of stdin file descriptor.
auto std_err() -> descriptor_ptr
Returns an abstraction of stderr file descriptor.
void link(ipipe_descriptor& fd1, opipe_descriptor& fd2)
Links two file descriptors.
auto operator<(command& cmd, descriptor_ptr fd) -> command&
auto operator>(command& cmd, err_t err_tag) -> command&
auto operator>(command& cmd, descriptor_ptr fd) -> command&
auto operator>=(command& cmd, out_t out_tag) -> command&
auto operator>=(command& cmd, descriptor_ptr fd) -> command&
auto operator>>(command& cmd, descriptor_ptr fd) -> command&
auto operator>>=(command& cmd, descriptor_ptr fd) -> command&
auto operator>=(command& cmd, std::string& output) -> command&
auto operator>(command& cmd, std::string& output) -> command&
auto operator<(command& cmd, std::string& input) -> command&
auto operator>(command& cmd, std::filesystem::path file_name) -> command&
auto operator>=(command& cmd, std::filesystem::path file_name) -> command&
auto operator>>(command& cmd, std::filesystem::path file_name) -> command&
auto operator>>=(command& cmd, std::filesystem::path file_name) -> command&
auto operator<(command& cmd, std::filesystem::path file_name) -> command&
auto operator>(command&& cmd, descriptor_ptr fd) -> command&&
auto operator>=(command&& cmd, descriptor_ptr fd) -> command&&
auto operator>>(command&& cmd, descriptor_ptr fd) -> command&&
auto operator>>=(command&& cmd, descriptor_ptr fd) -> command&&
auto operator<(command&& cmd, descriptor_ptr fd) -> command&&
auto operator>=(command&& cmd, out_t out_tag) -> command&&
auto operator>=(command&& cmd, std::string& output) -> command&&
auto operator>(command&& cmd, err_t err_tag) -> command&&
auto operator>(command&& cmd, std::string& output) -> command&&
auto operator<(command&& cmd, std::string& input) -> command&&
auto operator>(command&& cmd, std::filesystem::path file_name) -> command&&
auto operator>=(command&& cmd, std::filesystem::path file_name) -> command&&
auto operator>>(command&& cmd, std::filesystem::path file_name) -> command&&
auto operator>>=(command&& cmd, std::filesystem::path file_name) -> command&&
auto operator<(command&& cmd, std::filesystem::path file_name) -> command&&

Variables

static in_t in
static out_t out
static err_t err

Typedef documentation

template<typename T>
using subprocess::descriptor_ptr_t = std::enable_if_t<std::is_base_of_v<descriptor, T>, std::shared_ptr<T>>

A shorthand for describing a descriptor ptr.

Template parameters
T descriptor or one of its derived classes

using subprocess::descriptor_ptr = descriptor_ptr_t<descriptor>

A shorthand for denoting an owning-pointer for the descriptor base class.

using subprocess::process_t = posix_process

Function documentation

template<typename T, typename... Args>
descriptor_ptr_t<T> subprocess::make_descriptor(Args && ... args)

Wraps std::make_unique. Used only for self-documentation purposes.

Template parameters
T The type of descriptor to create.
Args
Parameters
args Constructor args that should be passed to the descriptor's constructor
Returns descriptor_ptr_t<T> Returns a descriptor_ptr

std::pair<descriptor_ptr_t<ipipe_descriptor>, descriptor_ptr_t<opipe_descriptor>> subprocess::create_pipe()

Create opipe_descriptor and ipipe_descriptor objects and links them.

Returns std::pair<descriptor_ptr_t<ipipe_descriptor>, descriptor_ptr_t<opipe_descriptor>> A pair of linked file_descriptos [read_fd, write_fd]

Calling this method does not automatically create a pipe. You need to call open() on any one of the resulting objects to initialize the pipe.

descriptor_ptr subprocess::std_in()

Returns an abstraction of stdout file descriptor.

Returns descriptor stdout

descriptor_ptr subprocess::std_out()

Returns an abstraction of stdin file descriptor.

Returns descriptor stdin

descriptor_ptr subprocess::std_err()

Returns an abstraction of stderr file descriptor.

Returns descriptor stderr

void subprocess::link(ipipe_descriptor& fd1, opipe_descriptor& fd2)

Links two file descriptors.

Parameters
fd1
fd2

This function is used to link a read and write file descriptor

command& subprocess::operator>(command& cmd, err_t err_tag)

command& subprocess::operator>=(command& cmd, out_t out_tag)

command& subprocess::operator>=(command& cmd, std::string& output)

command& subprocess::operator>(command& cmd, std::string& output)

command& subprocess::operator<(command& cmd, std::string& input)

command& subprocess::operator>(command& cmd, std::filesystem::path file_name)

command& subprocess::operator>=(command& cmd, std::filesystem::path file_name)

command& subprocess::operator>>(command& cmd, std::filesystem::path file_name)

command& subprocess::operator>>=(command& cmd, std::filesystem::path file_name)

command& subprocess::operator<(command& cmd, std::filesystem::path file_name)

command&& subprocess::operator>=(command&& cmd, out_t out_tag)

command&& subprocess::operator>=(command&& cmd, std::string& output)

command&& subprocess::operator>(command&& cmd, err_t err_tag)

command&& subprocess::operator>(command&& cmd, std::string& output)

command&& subprocess::operator<(command&& cmd, std::string& input)

command&& subprocess::operator>(command&& cmd, std::filesystem::path file_name)

command&& subprocess::operator>=(command&& cmd, std::filesystem::path file_name)

command&& subprocess::operator>>(command&& cmd, std::filesystem::path file_name)

command&& subprocess::operator>>=(command&& cmd, std::filesystem::path file_name)

command&& subprocess::operator<(command&& cmd, std::filesystem::path file_name)

Variable documentation

static in_t subprocess::in

static out_t subprocess::out

static err_t subprocess::err