Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::ProcessEnvironment Struct Reference

Reads current process environment variables. More...

#include <Process.h>

Public Member Functions

 ProcessEnvironment (const ProcessEnvironment &)=delete
 
 ProcessEnvironment (ProcessEnvironment &&)=delete
 
ProcessEnvironmentoperator= (const ProcessEnvironment &)=delete
 
ProcessEnvironmentoperator= (ProcessEnvironment &&)=delete
 
size_t size () const
 Returns the total number of environment variables for current process. More...
 
bool get (size_t index, StringView &name, StringView &value) const
 Get the environmnent variable at given index, returning its name and value. More...
 
bool contains (StringView variableName, size_t *index=nullptr)
 Checks if an environment variable exists in current process. More...
 

Detailed Description

Reads current process environment variables.

Example: Print all environment variables to stdout

for (size_t idx = 0; idx < environment.size(); ++idx)
{
StringView name, value;
(void)environment.get(idx, name, value);
if (value.isEmpty())
{
report.console.printLine(name);
}
else
{
report.console.print(name);
report.console.print("=");
report.console.printLine(value);
}
}
Reads current process environment variables.
Definition: Process.h:329
bool get(size_t index, StringView &name, StringView &value) const
Get the environmnent variable at given index, returning its name and value.
size_t size() const
Returns the total number of environment variables for current process.
Definition: Process.h:339

Member Function Documentation

◆ contains()

bool SC::ProcessEnvironment::contains ( StringView  variableName,
size_t index = nullptr 
)

Checks if an environment variable exists in current process.

Parameters
variableNameName of the variable to check
indexOptional pointer to a variable that will receive the index of the variable (only if found)
Returns
true if variableName has been found in list of the variable

◆ get()

bool SC::ProcessEnvironment::get ( size_t  index,
StringView name,
StringView value 
) const

Get the environmnent variable at given index, returning its name and value.

Parameters
indexThe index of the variable to retrieve (must be less than ProcessEnvironment::size())
nameThe parsed name of the environment variable at requested index
valueThe parsed value of the environment variable at requested index

◆ size()

size_t SC::ProcessEnvironment::size ( ) const
inline

Returns the total number of environment variables for current process.


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