OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
WinEnvironment Class Reference

#include <WinEnvironment.h>

Inheritance diagram for WinEnvironment:
Environment

Public Member Functions

virtual std::string queryRegistry (const std::string &path) const override
 
virtual std::string path (EnvironmentPath path) const override
 
virtual std::string getenv (const std::string &key) const override
 
virtual void setenv (const std::string &key, const std::string &value) const override
 
- Public Member Functions inherited from Environment
virtual ~Environment ()=default
 
virtual std::string queryRegistry (const std::string &path) const =0
 
virtual std::string path (EnvironmentPath path) const =0
 
virtual std::string getenv (const std::string &key) const =0
 
virtual void setenv (const std::string &key, const std::string &value) const =0
 

Additional Inherited Members

- Static Public Member Functions inherited from Environment
static std::unique_ptr< EnvironmentcreateStandardEnvironment ()
 

Member Function Documentation

◆ getenv()

std::string WinEnvironment::getenv ( const std::string &  key) const
overridevirtual

Same as std::getenv, but takes & returns UTF8-encoded keys and values on all platforms.

Note that on Windows std::getenv doesn't switch to UTF8 even if UnicodeCrt is used (aka std::setlocale(LC_ALL, ".UTF-8")).

Returns an empty string for non-existent environment variables, and thus doesn't distinguish between empty and non-existent values (and you shouldn't, either).

Parameters
keyUTF8-encoded name of the environment variable to query.
Returns
UTF8-encoded value of the environment variable.

Implements Environment.

◆ path()

std::string WinEnvironment::path ( EnvironmentPath  path) const
overridevirtual

Accessor for various system paths.

Parameters
pathPath to get.
Returns
UTF8-encoded path, or an empty string in case of an error.

Implements Environment.

◆ queryRegistry()

std::string WinEnvironment::queryRegistry ( const std::string &  path) const
overridevirtual

Windows-only function for querying the registry. Always returns an empty string on non-Windows systems.

Parameters
pathUTF8-encoded registry path to query.
Returns
UTF8-encoded value at the given path, or an empty string in case of an error.

Implements Environment.

◆ setenv()

void WinEnvironment::setenv ( const std::string &  key,
const std::string &  value 
) const
overridevirtual

Same as POSIX setenv(key, value, 1). Takes UTF8-encoded keys and values on all platforms.

Parameters
keyUTF8-encoded name of the environment variable to set.
valueUTF8-encoded value of the environment variable.

Implements Environment.


The documentation for this class was generated from the following files: