OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Environment Class Referenceabstract

#include <Environment.h>

Inheritance diagram for Environment:
AndroidEnvironment PosixEnvironment WinEnvironment

Public Member Functions

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
 

Static Public Member Functions

static std::unique_ptr< EnvironmentcreateStandardEnvironment ()
 

Detailed Description

Base class akin to Platform that provides an abstraction for the process's environment.

All strings accepted by and returned from methods of this class are UTF8-encoded.

Why is this class not a part of Platform? Mainly for the following reasons:

Constructor & Destructor Documentation

◆ ~Environment()

virtual Environment::~Environment ( )
virtualdefault

Member Function Documentation

◆ createStandardEnvironment()

std::unique_ptr< Environment > Environment::createStandardEnvironment ( )
static
Returns
Newly created standard Environment instance.

◆ getenv()

virtual std::string Environment::getenv ( const std::string &  key) const
pure virtual

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.

Implemented in AndroidEnvironment, PosixEnvironment, and WinEnvironment.

◆ path()

virtual std::string Environment::path ( EnvironmentPath  path) const
pure virtual

Accessor for various system paths.

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

Implemented in AndroidEnvironment, PosixEnvironment, and WinEnvironment.

◆ queryRegistry()

virtual std::string Environment::queryRegistry ( const std::string &  path) const
pure virtual

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.

Implemented in AndroidEnvironment, PosixEnvironment, and WinEnvironment.

◆ setenv()

virtual void Environment::setenv ( const std::string &  key,
const std::string &  value 
) const
pure virtual

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.

Implemented in AndroidEnvironment, PosixEnvironment, and WinEnvironment.


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