Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::ConfigLoader Class Reference

A utility class to load and access configuration values from .env files. More...

#include <config_loader.h>

Public Member Functions

 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.
 

Static Public Member Functions

static ConfigLoadergetInstance ()
 Get the singleton instance of ConfigLoader.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ConfigLoader()

agents::ConfigLoader::ConfigLoader ( const std::string & customPath)
explicit

Construct a ConfigLoader with a custom .env file path.

Parameters
customPathPath to the .env file

Member Function Documentation

◆ get()

std::string agents::ConfigLoader::get ( const std::string & key,
const std::string & defaultValue = "" ) const

Get a configuration value.

Parameters
keyThe key to look up
defaultValueValue to return if key is not found
Returns
The value for the key, or defaultValue if not found

◆ getInstance()

static ConfigLoader & agents::ConfigLoader::getInstance ( )
static

Get the singleton instance of ConfigLoader.

Returns
Reference to the global ConfigLoader instance

◆ has()

bool agents::ConfigLoader::has ( const std::string & key) const

Check if a key exists in the configuration.

Parameters
keyThe key to check
Returns
true if the key exists, false otherwise