userver: engine::subprocess::EnvironmentVariables Class Reference
Loading...
Searching...
No Matches
engine::subprocess::EnvironmentVariables Class Reference

#include <userver/engine/subprocess/environment_variables.hpp>

Detailed Description

Environment variables representation.

Wrapper to save environment variables and pass them to ProcessStarter::Exec. Changing an instance does not change current environment variables of the process.

Definition at line 44 of file environment_variables.hpp.

Public Types

using Map = EnvironmentVariablesUpdate::Map
 
using const_iterator = Map::const_iterator
 

Public Member Functions

 EnvironmentVariables (Map vars)
 Constructs an instance from pairs: key, value taken from the map.
 
 EnvironmentVariables (const EnvironmentVariables &)=default
 Constructs copy of the instance.
 
EnvironmentVariablesUpdateWith (EnvironmentVariablesUpdate update)
 Updates variable.
 
const std::string & GetValue (const std::string &variable_name) const
 Returns the value of the variable.
 
const std::string * GetValueOptional (const std::string &variable_name) const
 
void SetValue (std::string variable_name, std::string value)
 Sets the value of the variable.
 
std::string & operator[] (const std::string &variable_name)
 Returns the reference to the value.
 
auto empty () const
 Checks whether the container is empty.
 
auto size () const
 Returns the number of elements.
 
auto begin () const
 Returns a const iterator to the beginning.
 
auto end () const
 Returns a const iterator to the ending.
 

Member Typedef Documentation

◆ const_iterator

using engine::subprocess::EnvironmentVariables::const_iterator = Map::const_iterator

Definition at line 78 of file environment_variables.hpp.

◆ Map

using engine::subprocess::EnvironmentVariables::Map = EnvironmentVariablesUpdate::Map

Definition at line 46 of file environment_variables.hpp.

Member Function Documentation

◆ begin()

auto engine::subprocess::EnvironmentVariables::begin ( ) const
inline

Returns a const iterator to the beginning.

Definition at line 81 of file environment_variables.hpp.

◆ empty()

auto engine::subprocess::EnvironmentVariables::empty ( ) const
inline

Checks whether the container is empty.

Definition at line 73 of file environment_variables.hpp.

◆ end()

auto engine::subprocess::EnvironmentVariables::end ( ) const
inline

Returns a const iterator to the ending.

Definition at line 84 of file environment_variables.hpp.

◆ GetValue()

const std::string & engine::subprocess::EnvironmentVariables::GetValue ( const std::string & variable_name) const

Returns the value of the variable.

Warning
Throws std::runtime_error if there is no variable.

◆ GetValueOptional()

const std::string * engine::subprocess::EnvironmentVariables::GetValueOptional ( const std::string & variable_name) const

Returns the pointer to the value of the variable or nullptr if there is no variable.

◆ size()

auto engine::subprocess::EnvironmentVariables::size ( ) const
inline

Returns the number of elements.

Definition at line 76 of file environment_variables.hpp.

◆ UpdateWith()

EnvironmentVariables & engine::subprocess::EnvironmentVariables::UpdateWith ( EnvironmentVariablesUpdate update)

Updates variable.

Note
If variable does not exist then it is added.

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