A utility class to load and access configuration values from .env files.
More...
#include <config_loader.h>
|
| ConfigLoader () |
| Construct a ConfigLoader with default .env file locations.
|
|
| ConfigLoader (const std::string &customPath) |
| Construct a ConfigLoader with a custom .env file path.
|
|
std::string | get (const std::string &key, const std::string &defaultValue="") const |
| Get a configuration value.
|
|
bool | has (const std::string &key) const |
| Check if a key exists in the configuration.
|
|
A utility class to load and access configuration values from .env files.
The ConfigLoader reads configuration from a .env file and provides access to these values. It automatically falls back to environment variables if a key is not found in the config file.
- Examples
- actor_agent_example.cpp.
◆ ConfigLoader()
agents::ConfigLoader::ConfigLoader |
( |
const std::string & | customPath | ) |
|
|
explicit |
Construct a ConfigLoader with a custom .env file path.
- Parameters
-
customPath | Path to the .env file |
◆ get()
std::string agents::ConfigLoader::get |
( |
const std::string & | key, |
|
|
const std::string & | defaultValue = "" ) const |
Get a configuration value.
- Parameters
-
key | The key to look up |
defaultValue | Value to return if key is not found |
- Returns
- The value for the key, or defaultValue if not found
◆ getInstance()
◆ has()
bool agents::ConfigLoader::has |
( |
const std::string & | key | ) |
const |
Check if a key exists in the configuration.
- Parameters
-
- Returns
- true if the key exists, false otherwise