|
λ61
|
A utility class for accessing environment variables by name. More...
#include <EnvironmentVariable.hpp>
Public Member Functions | |
| EnvironmentVariable (const std::string &name) | |
| Constructs an EnvironmentVariable object with the given name. | |
| std::string | getValue () const |
| Retrieves the value of the environment variable. | |
| std::string | get (const std::string &defaultValue="") const |
| Retrieves the value of the environment variable, or returns a default. | |
| bool | exists () const |
| Checks if the environment variable exists. | |
| const std::string & | getKey () const |
| Retrieves the name (key) of the environment variable. | |
| std::string | toString () const override |
| Returns a human-readable string representation of the object. | |
| std::size_t | hashCode () const override |
| Computes a hash code for this environment variable. | |
| nlohmann::json | toJsonValue () const override |
| Serializes the object into JSON form. | |
| bool | operator== (const EnvironmentVariable &other) const |
| Equality operator for EnvironmentVariable objects. | |
| EnvironmentVariable (const EnvironmentVariable &environment_variable) | |
| EnvironmentVariable (EnvironmentVariable &&environment_variable) noexcept | |
| ~EnvironmentVariable () override=default | |
| Public Member Functions inherited from l61::Object | |
| virtual | ~Object ()=default |
| std::string | typeName () const |
| Returns the demangled name of the type. | |
| const std::type_info & | typeInfo () const |
| Returns RTTI type information object. | |
| operator std::string () const | |
| Explicit conversion operator to std::string. | |
| operator nlohmann::json () const | |
| Explicit conversion operator to nlohmann::json. | |
Static Public Member Functions | |
| static EnvironmentVariable | of (const std::string &name) |
Private Attributes | |
| std::string | name_ |
A utility class for accessing environment variables by name.
This class provides a clean interface to query, check, and retrieve environment variables. It does not modify or set environment variables, only reads them.
|
explicit |
Constructs an EnvironmentVariable object with the given name.
| name | The name of the environment variable. |
| l61::RosettaSystem::EnvironmentVariable::EnvironmentVariable | ( | const EnvironmentVariable & | environment_variable | ) |
|
noexcept |
|
overridedefault |
| bool l61::RosettaSystem::EnvironmentVariable::exists | ( | ) | const |
Checks if the environment variable exists.
Example:
| std::string l61::RosettaSystem::EnvironmentVariable::get | ( | const std::string & | defaultValue = "" | ) | const |
Retrieves the value of the environment variable, or returns a default.
| defaultValue | The value to return if the environment variable does not exist. |
defaultValue.Example:
| const std::string & l61::RosettaSystem::EnvironmentVariable::getKey | ( | ) | const |
Retrieves the name (key) of the environment variable.
Example:
| std::string l61::RosettaSystem::EnvironmentVariable::getValue | ( | ) | const |
Retrieves the value of the environment variable.
| std::runtime_error | if the environment variable does not exist. |
Example:
|
overridevirtual |
Computes a hash code for this environment variable.
The hash is derived from the variable's name, making it suitable for use in hash-based containers (e.g., std::unordered_map).
Example:
Reimplemented from l61::Object.
|
inlinestatic |
| bool l61::RosettaSystem::EnvironmentVariable::operator== | ( | const EnvironmentVariable & | other | ) | const |
Equality operator for EnvironmentVariable objects.
Two EnvironmentVariable objects are considered equal if they reference the same variable name.
| other | Another EnvironmentVariable to compare with. |
Example:
|
overridevirtual |
Serializes the object into JSON form.
Intended for persistence, logging, or communication. Derived classes should override this to produce structured JSON output representing their state.
Reimplemented from l61::Object.
|
overridevirtual |
Returns a human-readable string representation of the object.
Derived classes should override this to provide a meaningful textual description of their internal state. Default implementation may just return the type name or placeholder text.
Reimplemented from l61::Object.
|
private |