TSdlEnvironment
A thread-safe set of environment variables
Definition
Unit: Neslib.Sdl3.Additional
Properties
Name | Description |
---|---|
Process | The process environment. |
Constructors
Name | Description |
---|---|
Create | Create a set of environment variables |
Operators
Name | Description |
---|---|
Equal(TSdlEnvironment, TSdlEnvironment) | Used to compare against another TSdlEnvironment. |
Equal(TSdlEnvironment, Pointer) | Used to compare against nil . |
Implicit | Used to set the value to nil . |
NotEqual(TSdlEnvironment, TSdlEnvironment) | Used to compare against another TSdlEnvironment. |
NotEqual(TSdlEnvironment, Pointer) | Used to compare against nil . |
Methods
Name | Description |
---|---|
Free | Free the set of environment variables. |
GetUnsafe | Get the value of a variable in the environment. |
GetVariable | Get the value of a variable in the environment. |
GetVariables | Get all variables in the environment. |
SetUnsafe | Set the value of a variable in the environment. |
SetVariable | Set the value of a variable in the environment. |
UnsetUnsafe | Clear a variable from the environment. |
UnsetVariable | Clear a variable from the environment. |
Property Descriptions
Process
The process environment.
This is initialized at application start and is not affected by any changes to the environment variables after that point. Use SetVariable and UnsetVariable if you want to modify this environment, or SetUnsafe UnsetUnsafe if you want changes to persist to the runtime environment after SdlQuit.
class property Process: TSdlEnvironment read GetProcess
Type: TSdlEnvironment
Exceptions
ESdlError
: Raised on failure.
Remarks
It is safe to use this property from any thread
Constructor Descriptions
Create
Create a set of environment variables
constructor Create(const APopulated: Boolean)
Parameters
APopulated
: Boolean
: True to initialize it from the runtime environment, False to create an empty environment.
See Also
Remarks
If APopulated
is false, it is safe to call this constructor from any thread, otherwise it is safe if no other threads are changing the environment.
Operator Descriptions
Equal(TSdlEnvironment, TSdlEnvironment)
Used to compare against another TSdlEnvironment.
class operator Equal(const ALeft, ARight: TSdlEnvironment): Boolean; inline; static
Parameters
ALeft
: TSdlEnvironment
ARight
: TSdlEnvironment
Returns
Boolean
Equal(TSdlEnvironment, Pointer)
Used to compare against nil
.
class operator Equal(const ALeft: TSdlEnvironment; const ARight: Pointer): Boolean; inline; static
Parameters
ALeft
: TSdlEnvironment
ARight
: Pointer
Returns
Boolean
Implicit(Pointer)
Used to set the value to nil
.
class operator Implicit(const AValue: Pointer): TSdlEnvironment; inline; static
Parameters
AValue
: Pointer
Returns
NotEqual(TSdlEnvironment, TSdlEnvironment)
Used to compare against another TSdlEnvironment.
class operator NotEqual(const ALeft, ARight: TSdlEnvironment): Boolean; inline; static
Parameters
ALeft
: TSdlEnvironment
ARight
: TSdlEnvironment
Returns
Boolean
NotEqual(TSdlEnvironment, Pointer)
Used to compare against nil
.
class operator NotEqual(const ALeft: TSdlEnvironment; const ARight: Pointer): Boolean; inline; static
Parameters
ALeft
: TSdlEnvironment
ARight
: Pointer
Returns
Boolean
Method Descriptions
Free
Free the set of environment variables.
procedure Free; inline
See Also
Remarks
It is safe to call this method from any thread, as long as the environment is no longer in use.
GetUnsafe(String)
Get the value of a variable in the environment.
This method bypasses SDL's cached copy of the environment and is not thread-safe.
class function GetUnsafe(const AName: String): String; inline; static
Parameters
AName
: String
: The name of the variable to get.
Returns
String
: The value of the variable or an empty string if it can't be found.
See Also
Remarks
This function is not thread safe, consider using GetVariable instead.
GetVariable(String)
Get the value of a variable in the environment.
function GetVariable(const AName: String): String; inline
Parameters
AName
: String
: The name of the variable to get.
Returns
String
: The value of the variable or an empty string if it can't be found.
See Also
Remarks
It is safe to call this method from any thread
GetVariables
Get all variables in the environment.
function GetVariables: TArray<String>
Exceptions
ESdlError
: Raised on failure.
Returns
TArray<String>
: An array of pointers to environment variables in the form 'variable=value'.
See Also
Remarks
It is safe to call this method from any thread
SetUnsafe(String, String, Boolean)
Set the value of a variable in the environment.
class procedure SetUnsafe(const AName, AValue: String; const AOverwrite: Boolean); inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
AName
: String
: The name of the variable to set.
AValue
: String
: The value of the variable to set.
AOverwrite
: Boolean
: True to overwrite the variable if it exists, False to return success without setting the variable if it already exists.
See Also
Remarks
This function is not thread safe, consider using SetVariable instead.
SetVariable(String, String, Boolean)
Set the value of a variable in the environment.
procedure SetVariable(const AName, AValue: String; const AOverwrite: Boolean); inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AName
: String
: The name of the variable to set.
AValue
: String
: The value of the variable to set.
AOverwrite
: Boolean
: True to overwrite the variable if it exists, False to return success without setting the variable if it already exists.
See Also
Remarks
It is safe to call this method from any thread
UnsetUnsafe(String)
Clear a variable from the environment.
class procedure UnsetUnsafe(const AName: String); inline; static
Exceptions
ESdlError
: Raised on failure.
Parameters
AName
: String
: The name of the variable to unset.
See Also
Remarks
This function is not thread safe, consider using UnsetVariable instead.
UnsetVariable(String)
Clear a variable from the environment.
procedure UnsetVariable(const AName: String); inline
Exceptions
ESdlError
: Raised on failure.
Parameters
AName
: String
: The name of the variable to unset.
See Also
Remarks
It is safe to call this method from any thread