Platform-independent environment variables manipulations.
Provide analog for POSIX functions:
- setenv
- unsetenv
- putenv
- getenv
You can generally use the functions as you would normally in POSIX-style. The differences below are just to make things more convenient through use of std::string (2,3), and to also allow the Win32-style of unsetting variables (4,5) if wanted.
- CEnvironment::setenv parameter 'overwrite' is optional, set by default to 1 (allow overwrite).
- CEnvironment::putenv uses copy of provided string (rather than string itself) to change environment, so you can free parameter variable right after call of function.
- CEnvironment::getenv returns a copy of environment variable value instead of pointer to value.
- CEnvironment::setenv can be used to unset variables. Just pass empty string for 'value' parameter.
- CEnvironment::putenv can be used to unset variables. Set parameter to 'var=' (Windows style) or just 'var' (POSIX style), and 'var' will be unset.
All 'std::string' types are supposed to be in UTF-8 encoding. All functions work on all platforms. Special care is taken on Windows platform where Environment is changed for process itself, for process runtime library and for all runtime libraries (MSVCRT) loaded by third-party modules. Functions internally make all necessary UTF-8 <-> wide conversions.*