|
KiCad PCB EDA Suite
|
RAII helper that sets a KiCad program-level environment variable for the lifetime of the object. More...
#include <env_var_utils.h>
Public Member Functions | |
| SCOPED_PGM_ENV_VAR (const wxString &aName, const std::optional< wxString > &aValue) | |
| ~SCOPED_PGM_ENV_VAR () | |
| SCOPED_PGM_ENV_VAR (const SCOPED_PGM_ENV_VAR &)=delete | |
| SCOPED_PGM_ENV_VAR & | operator= (const SCOPED_PGM_ENV_VAR &)=delete |
| ENV_VAR_ITEM & | GetItem () |
| Get the wrapped environment variable item. | |
| const ENV_VAR_ITEM & | GetItem () const |
| void | ClearItem () |
| Clear the environment variable for the lifetime of the object. | |
Private Attributes | |
| ENV_VAR_MAP & | m_pgmEnvVars |
| wxString | m_name |
| std::optional< ENV_VAR_ITEM > | m_oldValue |
RAII helper that sets a KiCad program-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 only affects the KiCad program-level environment variable map. It will not affect code that uses wxGetEnv() directly.
Definition at line 83 of file env_var_utils.h.
| KI_TEST::SCOPED_PGM_ENV_VAR::SCOPED_PGM_ENV_VAR | ( | const wxString & | aName, |
| const std::optional< wxString > & | aValue ) |
| aName | the name of the environment variable to set |
| aValue | the value to set the variable to. If nullopt, the variable is removed for the lifetime of the object. |
Definition at line 75 of file env_var_utils.cpp.
References m_name, m_oldValue, m_pgmEnvVars, and Pgm().
Referenced by operator=(), and SCOPED_PGM_ENV_VAR().
| KI_TEST::SCOPED_PGM_ENV_VAR::~SCOPED_PGM_ENV_VAR | ( | ) |
Definition at line 93 of file env_var_utils.cpp.
References m_name, m_oldValue, and m_pgmEnvVars.
|
delete |
References SCOPED_PGM_ENV_VAR().
|
inline |
Clear the environment variable for the lifetime of the object.
Definition at line 108 of file env_var_utils.h.
References m_name, and m_pgmEnvVars.
| ENV_VAR_ITEM & KI_TEST::SCOPED_PGM_ENV_VAR::GetItem | ( | ) |
Get the wrapped environment variable item.
The caller can modify this freely. Whatever it is set to will be restored on destruction.
Definition at line 102 of file env_var_utils.cpp.
References m_name, and m_pgmEnvVars.
Referenced by BOOST_AUTO_TEST_CASE().
| const ENV_VAR_ITEM & KI_TEST::SCOPED_PGM_ENV_VAR::GetItem | ( | ) | const |
Definition at line 108 of file env_var_utils.cpp.
References m_name, and m_pgmEnvVars.
|
delete |
References SCOPED_PGM_ENV_VAR().
|
private |
Definition at line 112 of file env_var_utils.h.
Referenced by ClearItem(), GetItem(), GetItem(), SCOPED_PGM_ENV_VAR(), and ~SCOPED_PGM_ENV_VAR().
|
private |
Definition at line 113 of file env_var_utils.h.
Referenced by SCOPED_PGM_ENV_VAR(), and ~SCOPED_PGM_ENV_VAR().
|
private |
Definition at line 111 of file env_var_utils.h.
Referenced by ClearItem(), GetItem(), GetItem(), SCOPED_PGM_ENV_VAR(), and ~SCOPED_PGM_ENV_VAR().