KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ENV_VAR Namespace Reference

Typedefs

using ENV_VAR_LIST = std::vector< wxString >
 

Functions

KICOMMON_API bool IsEnvVarImmutable (const wxString &aEnvVar)
 Determine if an environment variable is "predefined", i.e.
 
KICOMMON_API const ENV_VAR_LISTGetPredefinedEnvVars ()
 Get the list of pre-defined environment variables.
 
KICOMMON_API wxString GetVersionedEnvVarName (const wxString &aBaseName)
 Constructs a versioned environment variable based on this KiCad major version.
 
KICOMMON_API std::optional< wxString > GetVersionedEnvVarValue (const std::map< wxString, ENV_VAR_ITEM > &aMap, const wxString &aBaseName)
 Attempts to retrieve the value of a versioned environment variable, such as KICAD8_TEMPLATE_DIR.
 
KICOMMON_API wxString LookUpEnvVarHelp (const wxString &aEnvVar)
 Look up long-form help text for a given environment variable.
 
template<typename VAL_TYPE >
KICOMMON_API std::optional< VAL_TYPE > GetEnvVar (const wxString &aEnvVarName)
 Get an environment variable as a specific type, if set correctly.
 
template<>
KICOMMON_API std::optional< wxString > GetEnvVar (const wxString &aEnvVarName)
 Get a string environment variable, if it is set.
 
template<>
KICOMMON_API std::optional< double > GetEnvVar (const wxString &aEnvVarName)
 Get a double from an environment variable, if set.
 

Typedef Documentation

◆ ENV_VAR_LIST

using ENV_VAR::ENV_VAR_LIST = typedef std::vector<wxString>

Definition at line 38 of file env_vars.h.

Function Documentation

◆ GetEnvVar() [1/3]

template<typename VAL_TYPE >
KICOMMON_API std::optional< VAL_TYPE > ENV_VAR::GetEnvVar ( const wxString &  aEnvVarName)

Get an environment variable as a specific type, if set correctly.

Parameters
aEnvVarNamethe name of the environment variable
Returns
an std::optional containing the value, if set and parseable, otherwise empty.

◆ GetEnvVar() [2/3]

template<>
std::optional< wxString > ENV_VAR::GetEnvVar ( const wxString &  aEnvVarName)

Get a string environment variable, if it is set.

Parameters
aEnvVarNamethe name of the environment variable
Returns
an std::optional containing the value, if set, otherwise empty.

Definition at line 157 of file env_vars.cpp.

◆ GetEnvVar() [3/3]

template<>
KICOMMON_API std::optional< double > ENV_VAR::GetEnvVar ( const wxString &  aEnvVarName)

Get a double from an environment variable, if set.

Parameters
aEnvVarNamethe name of the environment variable
Returns
an std::optional containing the value, if set and parseable as a double, otherwise empty.

◆ GetPredefinedEnvVars()

const ENV_VAR::ENV_VAR_LIST & ENV_VAR::GetPredefinedEnvVars ( )

Get the list of pre-defined environment variables.

Definition at line 68 of file env_vars.cpp.

References predefinedEnvVars.

Referenced by KIwxExpandEnvVars(), and DIALOG_CONFIGURE_PATHS::OnHelp().

◆ GetVersionedEnvVarName()

◆ GetVersionedEnvVarValue()

std::optional< wxString > ENV_VAR::GetVersionedEnvVarValue ( const std::map< wxString, ENV_VAR_ITEM > &  aMap,
const wxString &  aBaseName 
)

Attempts to retrieve the value of a versioned environment variable, such as KICAD8_TEMPLATE_DIR.

If this value exists in the map, it will be returned. If not, the map will be searched for keys matching KICAD*_<aBaseName>, and the first match's value will be returned. If there are no matches, std::nullopt will be returned.

Parameters
aMapis an ENV_VAR_MAP (
See also
environment.h)
Parameters
aBaseNameis the suffix for the environment variable (
See also
GetVersionedEnvVarName)

Definition at line 83 of file env_vars.cpp.

References GetVersionedEnvVarName().

Referenced by DESIGN_BLOCK_LIB_TABLE::LoadGlobalTable(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), KICAD_MANAGER_CONTROL::NewFromTemplate(), PGM_KICAD::OnPgmInit(), PLUGIN_CONTENT_MANAGER::ReadEnvVar(), and DIALOG_GLOBAL_LIB_TABLE_CONFIG::TransferDataToWindow().

◆ IsEnvVarImmutable()

bool ENV_VAR::IsEnvVarImmutable ( const wxString &  aEnvVar)

Determine if an environment variable is "predefined", i.e.

if the name of the variable is special to KiCad, and isn't just a user-specified substitution name.

Parameters
aEnvVarthe variable to check
Returns
true if predefined

Definition at line 53 of file env_vars.cpp.

References predefinedEnvVars, and versionedEnvVarRegex().

Referenced by DIALOG_CONFIGURE_PATHS::AppendEnvVar(), and DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar().

◆ LookUpEnvVarHelp()

wxString ENV_VAR::LookUpEnvVarHelp ( const wxString &  aEnvVar)

Look up long-form help text for a given environment variable.

This is intended for use in more verbose help resources (as opposed to tooltip text)

Parameters
aEnvVarThe variable to look up
Returns
A string with help for that variable. Empty if no help available for this variable.

Definition at line 145 of file env_vars.cpp.

References initialiseEnvVarHelp().

Referenced by DIALOG_CONFIGURE_PATHS::OnHelp().