|
iash
v0.5
Library to provide a bash-like shell in an application
|
Environment variable manager for iash. More...
#include <Environment.h>
Public Member Functions | |
| Environment (const std::string appName="iash") | |
| Creates an Environment instance with the given application name. More... | |
| void | set (const std::string &key, const std::string &value) |
Sets the environment variable key to value. More... | |
| void | set (const std::string &key, const bool value) |
Sets the environment variable key to the boolean value value. More... | |
| void | set (const std::string &key, const int value) |
Sets the environment variable key to the integer value value. More... | |
| void | set (const std::string &key, const double value) |
Sets the environment variable key to the floating-point value value. More... | |
| const std::string & | getString (const std::string &key) const |
Gets the environment variable key as a string. More... | |
| bool | getBool (const std::string &key) const |
Gets the environment variable key as a boolean value. More... | |
| int | getInt (const std::string &key) const |
Gets the environment variable key as an integer. More... | |
| double | getDouble (const std::string &key) const |
Gets the environment variable key as a floating-point value. More... | |
| void | rm (const std::string &key) |
Removes the environment variable key. More... | |
Friends | |
| class | iash |
Environment variable manager for iash.
Using environment variables is one method that iash provides to allow different Command instances to communicate with each other. Internally, environment variables are stored as string instances, but Environment provides functions to convert numeric and boolean data types to and from the string format.
As of version 0.5, iash has the following protected environment variables, which can be read but not modified:
IASH_APP_NAME: (since v0.1) The name of the application CWD: (since v0.5) The absolute path to the iash current working directory | Environment::Environment | ( | const std::string | appName = "iash" | ) |
Creates an Environment instance with the given application name.
iash instantiates its own Environment instance, so there is no need to construct one manually.
| appName | the name of the application |
| bool Environment::getBool | ( | const std::string & | key | ) | const |
Gets the environment variable key as a boolean value.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| double Environment::getDouble | ( | const std::string & | key | ) | const |
Gets the environment variable key as a floating-point value.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| int Environment::getInt | ( | const std::string & | key | ) | const |
Gets the environment variable key as an integer.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| const string & Environment::getString | ( | const std::string & | key | ) | const |
Gets the environment variable key as a string.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| void Environment::rm | ( | const std::string & | key | ) |
Removes the environment variable key.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable to delete |
| void Environment::set | ( | const std::string & | key, |
| const std::string & | value | ||
| ) |
Sets the environment variable key to value.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| value | the new value of the environment variable |
| void Environment::set | ( | const std::string & | key, |
| const bool | value | ||
| ) |
Sets the environment variable key to the boolean value value.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| value | the new value of the environment variable |
| void Environment::set | ( | const std::string & | key, |
| const int | value | ||
| ) |
Sets the environment variable key to the integer value value.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| value | the new value of the environment variable |
| void Environment::set | ( | const std::string & | key, |
| const double | value | ||
| ) |
Sets the environment variable key to the floating-point value value.
key will automatically be converted to upper case, if it is not already.
| key | the name of the environment variable |
| value | the new value of the environment variable |