lintel 0.2.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lintel::EnvironmentConfiguration Class Reference

#include <EnvironmentConfiguration.h>

Public Types

enum  Environment : std::uint8_t { ConfigDirectory , BootstrapConfigName , Home , Path }
 

Public Member Functions

 EnvironmentConfiguration ()
 
 ~EnvironmentConfiguration ()=default
 
const std::string & of (Environment environment)
 
std::vector< std::filesystem::path > pathsOf ()
 
std::optional< std::filesystem::path > pathOf (const std::string &fileName)
 
void overrides (Environment environment, const std::string &value)
 

Static Public Member Functions

static std::string expand (const std::string &value)
 

Detailed Description

Provides environment-specific configuration values and file path resolution

Member Enumeration Documentation

◆ Environment

Environment configuration keys

Enumerator
ConfigDirectory 

Configuration directory

BootstrapConfigName 

Bootstrap configuration file name

Home 

Home directory

Path 

Search path

Constructor & Destructor Documentation

◆ EnvironmentConfiguration()

lintel::EnvironmentConfiguration::EnvironmentConfiguration ( )

Construct an environment configuration from the current process environment

◆ ~EnvironmentConfiguration()

lintel::EnvironmentConfiguration::~EnvironmentConfiguration ( )
default

Destructor

Member Function Documentation

◆ expand()

static std::string lintel::EnvironmentConfiguration::expand ( const std::string &  value)
static

Expand environment variables in the given string.

Expands every occurrence of ${NAME} where NAME matches [A-Za-z_][A-Za-z0-9_]*.

  • If NAME is set in the environment (std::getenv), its value is substituted.
  • If NAME is not set, the literal ${NAME} text is left unchanged.
  • Escaping: $${NAME} produces the literal ${NAME}.

Note: This is a simple expansion and may expand ${...} inside XML comments when the variable is set (this is acceptable for bootstrap configuration).

Parameters
valueThe string to expand
Returns
The expanded string

◆ of()

const std::string & lintel::EnvironmentConfiguration::of ( Environment  environment)

Get the value for the given environment key

Parameters
environmentThe environment key
Returns
The environment value

◆ overrides()

void lintel::EnvironmentConfiguration::overrides ( Environment  environment,
const std::string &  value 
)

Override an environment value

Parameters
environmentThe environment key to override
valueThe new value

◆ pathOf()

std::optional< std::filesystem::path > lintel::EnvironmentConfiguration::pathOf ( const std::string &  fileName)

Find a file by name in the configured search paths

Parameters
fileNameThe file name to search for
Returns
The full path if found, nullopt otherwise

◆ pathsOf()

std::vector< std::filesystem::path > lintel::EnvironmentConfiguration::pathsOf ( )

Get all configured search paths

Returns
Vector of filesystem paths

The documentation for this class was generated from the following file: