StormByte C++ Library: System module 0.0.9999
StormByte-System is a StormByte library module for encapsulating different process handling over different operating system's complexities
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
StormByte::System::Process Class Reference

Process class for running external programs They will run immediately after creation. More...

#include <process.hxx>

Public Types

enum class  Status : unsigned short { RUNNING , SUSPENDED , TERMINATED }
 Process status. More...
 

Public Member Functions

 Process (const std::filesystem::path &prog, const std::vector< std::string > &args=std::vector< std::string >())
 
 Process (std::filesystem::path &&prog, std::vector< std::string > &&args=std::vector< std::string >())
 
 Process (const Process &proc)=delete
 
 Process (Process &&proc) noexcept
 
Processoperator= (const Process &proc)=delete
 
Processoperator= (Process &&proc) noexcept
 
virtual ~Process () noexcept
 
DWORD Wait () noexcept
 
PROCESS_INFORMATION Pid ()
 
void Suspend ()
 
void Resume ()
 
Processoperator>> (Process &proc)
 
std::string & operator>> (std::string &str) const
 
Processoperator<< (const std::string &str)
 
void operator<< (const System::_EoF &eof)
 

Protected Attributes

Status m_status
 Process status.
 
STARTUPINFO m_siStartInfo
 Startup information.
 
PROCESS_INFORMATION m_piProcInfo
 Process information.
 
Pipe * m_pstdout
 Standard output pipe.
 
Pipe * m_pstdin
 Standard input pipe.
 
Pipe * m_pstderr
 Standard error pipe.
 
std::filesystem::path m_program
 Program path.
 
std::vector< std::string > m_arguments
 Program arguments.
 
std::unique_ptr< std::thread > m_forwarder
 Forwarder thread.
 

Friends

STORMBYTE_SYSTEM_PUBLIC std::ostream & operator<< (std::ostream &ostream, const Process &proc)
 

Detailed Description

Process class for running external programs They will run immediately after creation.

Member Enumeration Documentation

◆ Status

enum class StormByte::System::Process::Status : unsigned short
strong

Process status.

Process status

Enumerator
RUNNING 

Process is running.

SUSPENDED 

Process is suspended.

TERMINATED 

Process is terminated.

Constructor & Destructor Documentation

◆ Process() [1/4]

StormByte::System::Process::Process ( const std::filesystem::path &  prog,
const std::vector< std::string > &  args = std::vector< std::string >() 
)

Constructor

Parameters
progprogram
argsarguments

◆ Process() [2/4]

StormByte::System::Process::Process ( std::filesystem::path &&  prog,
std::vector< std::string > &&  args = std::vector< std::string >() 
)

Constructor

Parameters
progprogram
argsarguments

◆ Process() [3/4]

StormByte::System::Process::Process ( const Process proc)
delete

Copy constructor (deleted)

Parameters
procProcess

◆ Process() [4/4]

StormByte::System::Process::Process ( Process &&  proc)
noexcept

Move constructor

Parameters
procProcess

◆ ~Process()

virtual StormByte::System::Process::~Process ( )
virtualnoexcept

Destructor

Member Function Documentation

◆ operator<<() [1/2]

Process & StormByte::System::Process::operator<< ( const std::string &  str)

Writes to the process stdin

Parameters
strstring
Returns
Process reference

◆ operator<<() [2/2]

void StormByte::System::Process::operator<< ( const System::_EoF eof)

Writes EOF to the process stdin

Parameters
eofEoF

◆ operator=() [1/2]

Process & StormByte::System::Process::operator= ( const Process proc)
delete

Assignment operator (deleted)

Parameters
procProcess

◆ operator=() [2/2]

Process & StormByte::System::Process::operator= ( Process &&  proc)
noexcept

Move assignment operator

Parameters
procProcess

◆ operator>>() [1/2]

Process & StormByte::System::Process::operator>> ( Process proc)

Binds current process stdout to a process stdin

Parameters
proctarget Process
Returns
Process reference

◆ operator>>() [2/2]

std::string & StormByte::System::Process::operator>> ( std::string &  str) const

Outputs the process stdout to a string

Parameters
strstring
Returns
string reference

◆ Pid()

PROCESS_INFORMATION StormByte::System::Process::Pid ( )

Gets the process id

Returns
process id

◆ Resume()

void StormByte::System::Process::Resume ( )

Resumes the process

◆ Suspend()

void StormByte::System::Process::Suspend ( )

Suspends the process

◆ Wait()

DWORD StormByte::System::Process::Wait ( )
noexcept

Waits for the process to finish

Returns
exit code

Friends And Related Symbol Documentation

◆ operator<<

STORMBYTE_SYSTEM_PUBLIC std::ostream & operator<< ( std::ostream &  ostream,
const Process proc 
)
friend

Outputs the process stdout to an ostream

Parameters
ostreamostream
procProcess
Returns
ostream reference

Outputs the process to an ostream

Parameters
ostreamostream
procProcess
Returns
ostream reference

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