![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qprocess.h>
Public Types | |
enum | Initialization { InheritFromParent } |
This enum contains a token that is used to disambiguate constructors. More... | |
Public Member Functions | |
QProcessEnvironment () | |
Creates a new QProcessEnvironment object. | |
QProcessEnvironment (Initialization) noexcept | |
Creates an object that when set on QProcess will cause it to be executed with environment variables inherited from its parent process. | |
QProcessEnvironment (const QProcessEnvironment &other) | |
Creates a QProcessEnvironment object that is a copy of other. | |
~QProcessEnvironment () | |
Frees the resources associated with this QProcessEnvironment object. | |
QProcessEnvironment & | operator= (const QProcessEnvironment &other) |
Copies the contents of the other QProcessEnvironment object into this one. | |
void | swap (QProcessEnvironment &other) noexcept |
bool | isEmpty () const |
Returns true if this QProcessEnvironment object is empty: that is there are no key=value pairs set. | |
bool | inheritsFromParent () const |
Returns true if this QProcessEnvironment was constructed using {QProcessEnvironment::InheritFromParent}. | |
void | clear () |
Removes all key=value pairs from this QProcessEnvironment object, making it empty. | |
bool | contains (const QString &name) const |
Returns true if the environment variable of name name is found in this QProcessEnvironment object. | |
void | insert (const QString &name, const QString &value) |
Inserts the environment variable of name name and contents value into this QProcessEnvironment object. | |
void | remove (const QString &name) |
Removes the environment variable identified by name from this QProcessEnvironment object. | |
QString | value (const QString &name, const QString &defaultValue=QString()) const |
Searches this QProcessEnvironment object for a variable identified by name and returns its value. | |
QStringList | toStringList () const |
Converts this QProcessEnvironment object into a list of strings, one for each environment variable that is set. | |
QStringList | keys () const |
void | insert (const QProcessEnvironment &e) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Static Public Member Functions | |
static QProcessEnvironment | systemEnvironment () |
Friends | |
class | QProcessPrivate |
class | QProcessEnvironmentPrivate |
Q_CORE_EXPORT bool | comparesEqual (const QProcessEnvironment &lhs, const QProcessEnvironment &rhs) |
\inmodule QtCore
The QProcessEnvironment class holds the environment variables that can be passed to a program.
\reentrant
\compares equality
A process's environment is composed of a set of key=value pairs known as environment variables. The QProcessEnvironment class wraps that concept and allows easy manipulation of those variables. It's meant to be used along with QProcess, to set the environment for child processes. It cannot be used to change the current process's environment.
The environment of the calling process can be obtained using QProcessEnvironment::systemEnvironment().
On Unix systems, the variable names are case-sensitive. Note that the Unix environment allows both variable names and contents to contain arbitrary binary data (except for the NUL character). QProcessEnvironment will preserve such variables, but does not support manipulating variables whose names or values cannot be encoded by the current locale settings (see QString::toLocal8Bit).
On Windows, the variable names are case-insensitive, but case-preserving. QProcessEnvironment behaves accordingly.
Definition at line 31 of file qprocess.h.
This enum contains a token that is used to disambiguate constructors.
\value InheritFromParent A QProcessEnvironment will be created that, when set on a QProcess, causes it to inherit variables from its parent.
Enumerator | |
---|---|
InheritFromParent |
Definition at line 34 of file qprocess.h.
QProcessEnvironment::QProcessEnvironment | ( | ) |
Creates a new QProcessEnvironment object.
This constructor creates an empty environment. If set on a QProcess, this will cause the current environment variables to be removed (except for PATH and SystemRoot on Windows).
Definition at line 132 of file qprocess.cpp.
|
noexcept |
Creates an object that when set on QProcess will cause it to be executed with environment variables inherited from its parent process.
If a modified version of the parent environment is wanted, start with the return value of systemEnvironment()
and modify that (but note that changes to the parent process's environment after that is created won't be reflected in the modified environment).
Definition at line 152 of file qprocess.cpp.
QProcessEnvironment::QProcessEnvironment | ( | const QProcessEnvironment & | other | ) |
Creates a QProcessEnvironment object that is a copy of other.
Definition at line 164 of file qprocess.cpp.
QProcessEnvironment::~QProcessEnvironment | ( | ) |
Frees the resources associated with this QProcessEnvironment object.
Definition at line 157 of file qprocess.cpp.
void QProcessEnvironment::clear | ( | ) |
Removes all key=value pairs from this QProcessEnvironment object, making it empty.
If the environment was constructed using {QProcessEnvironment::InheritFromParent} it remains unchanged.
Definition at line 248 of file qprocess.cpp.
bool QProcessEnvironment::contains | ( | const QString & | name | ) | const |
Returns true
if the environment variable of name name is found in this QProcessEnvironment object.
Definition at line 263 of file qprocess.cpp.
|
nodiscard |
Returns true
if this QProcessEnvironment was constructed using {QProcessEnvironment::InheritFromParent}.
Definition at line 234 of file qprocess.cpp.
void QProcessEnvironment::insert | ( | const QProcessEnvironment & | e | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Inserts the contents of e in this QProcessEnvironment object. Variables in this object that also exist in e will be overwritten.
Definition at line 367 of file qprocess.cpp.
Inserts the environment variable of name name and contents value into this QProcessEnvironment object.
If that variable already existed, it is replaced by the new value.
On most systems, inserting a variable with no contents will have the same effect for applications as if the variable had not been set at all. However, to guarantee that there are no incompatibilities, to remove a variable, please use the remove() function.
Definition at line 282 of file qprocess.cpp.
bool QProcessEnvironment::isEmpty | ( | ) | const |
Returns true
if this QProcessEnvironment object is empty: that is there are no key=value pairs set.
This method also returns true
for objects that were constructed using {QProcessEnvironment::InheritFromParent}.
Definition at line 221 of file qprocess.cpp.
QStringList QProcessEnvironment::keys | ( | ) | const |
Returns a list containing all the variable names in this QProcessEnvironment object.
The returned list is empty for objects constructed using {QProcessEnvironment::InheritFromParent}.
Definition at line 353 of file qprocess.cpp.
QProcessEnvironment & QProcessEnvironment::operator= | ( | const QProcessEnvironment & | other | ) |
Copies the contents of the other QProcessEnvironment object into this one.
Definition at line 173 of file qprocess.cpp.
Removes the environment variable identified by name from this QProcessEnvironment object.
If that variable did not exist before, nothing happens.
Definition at line 297 of file qprocess.cpp.
|
inlinenoexcept |
Definition at line 43 of file qprocess.h.
|
static |
Definition at line 10 of file qprocess_darwin.mm.
QStringList QProcessEnvironment::toStringList | ( | ) | const |
Converts this QProcessEnvironment object into a list of strings, one for each environment variable that is set.
The environment variable's name and its value are separated by an equal character ('=').
The QStringList contents returned by this function are suitable for presentation. Use with the QProcess::setEnvironment function is not recommended due to potential encoding problems under Unix, and worse performance.
Definition at line 337 of file qprocess.cpp.
QString QProcessEnvironment::value | ( | const QString & | name, |
const QString & | defaultValue = QString() ) const |
Searches this QProcessEnvironment object for a variable identified by name and returns its value.
If the variable is not found in this object, then defaultValue is returned instead.
Definition at line 312 of file qprocess.cpp.
|
friend |
Definition at line 204 of file qprocess.cpp.
|
friend |
Definition at line 73 of file qprocess.h.
|
friend |
Definition at line 72 of file qprocess.h.