BashSpark
Loading...
Searching...
No Matches
bs::shell_env Class Reference

Represents an environment for shell commands. More...

#include <shell_env.h>

Public Member Functions

 shell_env ()=default
 Default constructor (empty environment).
 
std::string get_env (const std::string &sVar) const
 Retrieves the value of an environment variable.
 
std::string get_env_hop2 (const std::string &sVar) const
 Retrieves the value of an environment variable, whose value is another variable (1-hop resolution).
 
void set_env (std::string sVar, std::string sValue)
 Sets the value of an environment variable.
 
bool has_env (const std::string &sVar) const noexcept
 Checks if an environment variable exists.
 
std::size_t get_env_size () const noexcept
 Gets the number of environment variables.
 
const std::unordered_map< std::string, std::string, shell_hash > & get_env () const noexcept
 Retrieves all environment variables.
 

Detailed Description

Represents an environment for shell commands.

This class manages environment variables.

Member Function Documentation

◆ get_env() [1/2]

const std::unordered_map< std::string, std::string, shell_hash > & bs::shell_env::get_env ( ) const
inlinenoexcept

Retrieves all environment variables.

Returns
A const reference to the map of environment variables.

◆ get_env() [2/2]

std::string bs::shell_env::get_env ( const std::string &  sVar) const
inline

Retrieves the value of an environment variable.

Parameters
sVarThe name of the environment variable.
Returns
The value of the environment variable, or an empty string if not found.

◆ get_env_hop2()

std::string bs::shell_env::get_env_hop2 ( const std::string &  sVar) const
inline

Retrieves the value of an environment variable, whose value is another variable (1-hop resolution).

Parameters
sVarThe name of the environment variable.
Returns
The value of the resolved environment variable, or an empty string if not found.

◆ get_env_size()

std::size_t bs::shell_env::get_env_size ( ) const
inlinenoexcept

Gets the number of environment variables.

Returns
The size of the environment variables map.

◆ has_env()

bool bs::shell_env::has_env ( const std::string &  sVar) const
inlinenoexcept

Checks if an environment variable exists.

Parameters
sVarThe name of the environment variable.
Returns
True if the variable exists, false otherwise.

◆ set_env()

void bs::shell_env::set_env ( std::string  sVar,
std::string  sValue 
)
inline

Sets the value of an environment variable.

Parameters
sVarThe name of the environment variable.
sValueThe value to be set.

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