Skip to content

Environment

Mario Bielert edited this page Mar 19, 2018 · 9 revisions

There are some functions, which allows the access to some runtime environment settings.

Plugin specific

These functions are used to determine the name and the prefix of the plugin.

std::string& plugin::name()

This function returns the name of the plugin.

Returns:

  • string - the name of the plugin

Attention:

You shall not modify the return value of this function.

std::string plugin::prefix()

This function returns the prefix used for environment variables. It uses the plugin name.

Returns:

  • string - the plugin prefix

Environment variables

There are two functions, which gives access to environment variables.

std::string environment_variable::get(std::string name, std::string default = "", bool global = false)

This function is a nice wrapper around the C library function getenv().

Arguments:

  • name - the name of the variable
  • default - the default value, if the variable wasn't set in the environment
  • global - if this is true, than the name will be used as given for the variable lookup, otherwise the name will be passed through environment_variable::name()

Returns:

  • string - the content of the environment variable or default

std::string environment_variable::name(const std::string& name)

The function returns the prefixed environment variable name of the given variable.

Arguments:

  • name - the name of the variable

Returns:

  • string - the prefixed variable name

See also

Clone this wiki locally