SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL::Process Struct Reference

An opaque handle representing a system process. More...

Inheritance diagram for SDL::Process:
[legend]

Public Member Functions

constexpr Process (ProcessRaw resource) noexcept
 Constructs from raw Process.
constexpr Process (const Process &other)=delete
 Copy constructor.
constexpr Process (Process &&other) noexcept
 Move constructor.
constexpr Process (const ProcessRef &other)=delete
constexpr Process (ProcessRef &&other)=delete
 Process (const char *const *args, bool pipe_stdio)
 Create a new process.
 Process (PropertiesRef props)
 Create a new process with the specified properties.
 ~Process ()
 Destructor.
constexpr Processoperator= (Process &&other) noexcept
 Assignment operator.
Processoperator= (const Process &other)=delete
 Assignment operator.
void Destroy ()
 Destroy a previously created process object.
PropertiesRef GetProperties () const
 Get the properties associated with a process.
StringResult Read (int *exitcode=nullptr)
 Read all the output from a process.
template<class T>
OwnArray< T > ReadAs (int *exitcode=nullptr)
 Read all the output from a process.
IOStreamRef GetInput ()
 Get the IOStream associated with process standard input.
IOStreamRef GetOutput ()
 Get the IOStream associated with process standard output.
void Kill (bool force)
 Stop a process.
bool Wait (bool block, int *exitcode)
 Wait for a process to finish.
constexpr ResourceBase (RawPointer resource)
 Constructs from resource pointer.
constexpr ResourceBase (std::nullptr_t=nullptr)
 Constructs null/invalid.
Public Member Functions inherited from SDL::ResourceBase< ProcessRaw >
constexpr ResourceBase (RawPointer resource)
 Constructs from resource pointer.
constexpr operator bool () const
 Converts to bool.
constexpr auto operator<=> (const ResourceBase &other) const=default
 Comparison.
constexpr RawConstPointer operator-> () const noexcept
 member access to underlying resource pointer.
constexpr RawPointer get () const noexcept
 Retrieves underlying resource pointer.
constexpr RawPointer release () noexcept
 Retrieves underlying resource pointer and clear this.

Additional Inherited Members

Public Types inherited from SDL::ResourceBase< ProcessRaw >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.

Detailed Description

An opaque handle representing a system process.

Since
This datatype is available since SDL 3.2.0.
See also
CreateProcess
Category:
Resource

Constructor & Destructor Documentation

◆ Process()

SDL::Process::Process ( ProcessRaw resource)
inlineexplicitconstexprnoexcept

Constructs from raw Process.

Parameters
resourcea ProcessRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

Member Function Documentation

◆ ReadAs()

template<class T>
OwnArray< T > SDL::Process::ReadAs ( int * exitcode = nullptr)
inline

Read all the output from a process.

If a process was created with I/O enabled, you can use this function to read the output. This function blocks until the process is complete, capturing all output, and providing the process exit code.

The data is allocated with a zero byte at the end (null terminated) for convenience. This extra byte is not included in the value reported via datasize.

The data should be freed with free().

Parameters
exitcodea pointer filled in with the process exit code if the process has exited, may be nullptr.
Returns
the data or nullptr on failure; call GetError() for more information.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
ProcessRef.Create

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