System environment variables features.
More...
|
| bool | ts::DeleteEnvironment (const UString &name) |
| bool | ts::EnvironmentExists (const UString &varname) |
| UString | ts::ExpandEnvironment (const UString &path, ExpandOptions options=ExpandOptions::ALL) |
| UString | ts::GetEnvironment (const UString &varname, const UString &defvalue=UString()) |
| void | ts::GetEnvironment (Environment &env) |
| template<class CONTAINER> |
| void | ts::GetEnvironmentPath (CONTAINER &container, const UString &name, const UString &def=UString()) |
| template<class CONTAINER> |
| void | ts::GetEnvironmentPathAppend (CONTAINER &container, const UString &name, const UString &def=UString()) |
template<typename INT>
requires std::integral<INT> |
| INT | ts::GetIntEnvironment (const UString &varname, INT defvalue=static_cast< INT >(0)) |
| bool | ts::LoadEnvironment (Environment &env, const UString &fileName) |
| bool | ts::SetEnvironment (const UString &name, const UString &value) |
| template<class CONTAINER> |
| void | ts::SetEnvironmentPath (const UString &name, const CONTAINER &container) |
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
-
- 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.
◆ GetIntEnvironment()
template<typename
INT>
requires std::integral<
INT>
| INT ts::GetIntEnvironment |
( |
const UString & | varname, |
|
|
INT | defvalue = static_cast<INT>(0) ) |
Get the value of an environment variable as an integer value.
- Template Parameters
-
| INT | An integer type, any size, signed or unsigned. |
- Parameters
-
| [in] | varname | Environment variable name. |
| [in] | defvalue | Default value if the specified environment variable does not exist or is not an integer. |
- Returns
- The value of the specified environment variable, 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
-
- 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
-
- 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. |
| [in] | options | Which form of environment variables references to expand. |
- 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.
◆ PATH_ENVIRONMENT_VARIABLE
| const UChar* ts::PATH_ENVIRONMENT_VARIABLE = platform - specific("PATH", "Path") |
|
constexpr |
Environment variable containing the command search path.
◆ PLUGINS_PATH_ENVIRONMENT_VARIABLE
| const UChar* ts::PLUGINS_PATH_ENVIRONMENT_VARIABLE = u"TSPLUGINS_PATH" |
|
constexpr |
Name of the environment variable which contains a list of paths for plugins.
◆ SEARCH_PATH_SEPARATOR
| UChar ts::SEARCH_PATH_SEPARATOR = platform-specific (':', ';') |
|
constexpr |
Separator character in search paths.