|
KiCad PCB EDA Suite
|
RAII helper that sets a process-level environment variable for the lifetime of the object. More...
#include <env_var_utils.h>
Public Member Functions | |
| SCOPED_PROCESS_ENV_VAR (const wxString &aName, const std::optional< wxString > &aValue) | |
| ~SCOPED_PROCESS_ENV_VAR () | |
| SCOPED_PROCESS_ENV_VAR (const SCOPED_PROCESS_ENV_VAR &)=delete | |
| SCOPED_PROCESS_ENV_VAR & | operator= (const SCOPED_PROCESS_ENV_VAR &)=delete |
| void | SetValue (const wxString &aValue) |
| Set a new value for the environment variable (which will still only be in effect for the lifetime of this object). | |
| std::optional< wxString > | GetValue () const |
| Get the current value of the environment variable, if it exists. | |
| void | ClearValue () |
| Clear the environment variable for the lifetime of this object. | |
Private Attributes | |
| wxString | m_name |
| std::optional< wxString > | m_oldValue |
RAII helper that sets a process-level environment variable for the lifetime of the object.
On destruction, it restores the previous entry, or removes the entry if it did not previously exist.
Note that this affects the process-level environment, so it will affect code that uses wxGetEnv() directly, but if variables have already been read into the KiCad program-level environment variable map, those will not be affected. If you want to affect the program-level environment variable map, use SCOPED_PGM_ENV_VAR
Definition at line 42 of file env_var_utils.h.
| KI_TEST::SCOPED_PROCESS_ENV_VAR::SCOPED_PROCESS_ENV_VAR | ( | const wxString & | aName, |
| const std::optional< wxString > & | aValue ) |
Definition at line 27 of file env_var_utils.cpp.
References m_name, and m_oldValue.
Referenced by operator=(), and SCOPED_PROCESS_ENV_VAR().
| KI_TEST::SCOPED_PROCESS_ENV_VAR::~SCOPED_PROCESS_ENV_VAR | ( | ) |
Definition at line 44 of file env_var_utils.cpp.
References m_name, and m_oldValue.
|
delete |
References SCOPED_PROCESS_ENV_VAR().
| void KI_TEST::SCOPED_PROCESS_ENV_VAR::ClearValue | ( | ) |
Clear the environment variable for the lifetime of this object.
if it was previously set, it will be restored on destruction.
Definition at line 69 of file env_var_utils.cpp.
References m_name.
Referenced by BOOST_AUTO_TEST_CASE().
| std::optional< wxString > KI_TEST::SCOPED_PROCESS_ENV_VAR::GetValue | ( | ) | const |
Get the current value of the environment variable, if it exists.
Definition at line 59 of file env_var_utils.cpp.
References m_name.
|
delete |
References SCOPED_PROCESS_ENV_VAR().
| void KI_TEST::SCOPED_PROCESS_ENV_VAR::SetValue | ( | const wxString & | aValue | ) |
Set a new value for the environment variable (which will still only be in effect for the lifetime of this object).
Definition at line 53 of file env_var_utils.cpp.
References m_name.
|
private |
Definition at line 70 of file env_var_utils.h.
Referenced by ClearValue(), GetValue(), SCOPED_PROCESS_ENV_VAR(), SetValue(), and ~SCOPED_PROCESS_ENV_VAR().
|
private |
Definition at line 71 of file env_var_utils.h.
Referenced by SCOPED_PROCESS_ENV_VAR(), and ~SCOPED_PROCESS_ENV_VAR().