System environment variables features.
More...
|
constexpr const UChar * | ts::PATH_ENVIRONMENT_VARIABLE = platform - specific("PATH", "Path") |
| Environment variable containing the command search path.
|
|
constexpr const UChar * | ts::PLUGINS_PATH_ENVIRONMENT_VARIABLE = u"TSPLUGINS_PATH" |
| Name of the environment variable which contains a list of paths for plugins.
|
|
constexpr UChar | ts::SEARCH_PATH_SEPARATOR = platform-specific (':', ';') |
| Separator character in search paths.
|
|
System environment variables features.
◆ Environment
Define a container type holding all environment variables.
For each element in the container, the key is the name of an environment variable and the value is the corresponding value of this environment variable.
◆ EnvironmentExists()
bool ts::EnvironmentExists |
( |
const UString & |
varname | ) |
|
Check if an environment variable exists.
- Parameters
-
[in] | varname | Environment variable name. |
- Returns
- True if the specified environment variable exists, false otherwise.
◆ GetEnvironment() [1/2]
Get the value of an environment variable.
- Parameters
-
[in] | varname | Environment variable name. |
[in] | defvalue | Default value if the specified environment variable does not exist. |
- Returns
- The value of the specified environment variable it it exists, defvalue otherwise.
◆ GetEnvironmentPath()
template<class CONTAINER >
void ts::GetEnvironmentPath |
( |
CONTAINER & |
container, |
|
|
const UString & |
name, |
|
|
const UString & |
def = UString() |
|
) |
| |
|
inline |
Get the value of an environment variable containing a search path.
The search path is analyzed and split into individual directory names.
- Template Parameters
-
CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
- Parameters
-
[out] | container | A container of UString receiving the directory names. |
[in] | name | Environment variable name. |
[in] | def | Default value if the specified environment variable does not exist. |
◆ GetEnvironmentPathAppend()
template<class CONTAINER >
void ts::GetEnvironmentPathAppend |
( |
CONTAINER & |
container, |
|
|
const UString & |
name, |
|
|
const UString & |
def = UString() |
|
) |
| |
|
inline |
Get the value of an environment variable containing a search path.
The search path is analyzed and split into individual directory names.
- Template Parameters
-
CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
- Parameters
-
[in,out] | container | A container of UString receiving the directory names. The directory names are appended to the container without erasing previous content. |
[in] | name | Environment variable name. |
[in] | def | Default value if the specified environment variable does not exist. |
◆ SetEnvironment()
bool ts::SetEnvironment |
( |
const UString & |
name, |
|
|
const UString & |
value |
|
) |
| |
Set the value of an environment variable.
If the variable previously existed, its value is overwritten. If it did not exist, it is created.
- Parameters
-
[in] | name | Environment variable name. |
[in] | value | Environment variable value. |
- Returns
- True on success, false on error.
◆ SetEnvironmentPath()
template<class CONTAINER >
void ts::SetEnvironmentPath |
( |
const UString & |
name, |
|
|
const CONTAINER & |
container |
|
) |
| |
|
inline |
Set the value of an environment variable containing a search path.
If the variable previously existed, its value is overwritten. If it did not exist, it is created.
- Template Parameters
-
CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
- Parameters
-
[in] | name | Environment variable name. |
[in] | container | A container of UString containing directory names. |
◆ DeleteEnvironment()
bool ts::DeleteEnvironment |
( |
const UString & |
name | ) |
|
Delete an environment variable.
If the variable did not exist, do nothing, do not generate an error.
- Parameters
-
[in] | name | Environment variable name. |
- Returns
- True on success, false on error.
◆ ExpandEnvironment()
Expand environment variables inside a file path (or any string).
Environment variable references '$name' or '${name}' are replaced by the corresponding values from the environment. In the first form, 'name' is the longest combination of letters, digits and underscore. A combination \$ is interpreted as a literal $, not an environment variable reference.
- Parameters
-
[in] | path | A path string containing references to environment variables. |
- Returns
- The expanded string.
◆ GetEnvironment() [2/2]
Get the content of the entire environment (all environment variables).
- Parameters
-
[out] | env | An associative container which receives the content of the environment. Each key is the name of an environment variable and the corresponding value is the value of this environment variable. |
◆ LoadEnvironment()
Load a text file containing environment variables.
Each line shall be in the form "name = value". Empty line and line starting with '#' are ignored. Spaces are trimmed.
- Parameters
-
[out] | env | An associative container which receives the content of the environment. Each key is the name of an environment variable and the corresponding value is the value of this environment variable. |
[in] | fileName | Name of the file to load. |
- Returns
- True on success, false on error.