KiCad PCB EDA Suite
ENV_VAR Namespace Reference

Typedefs

using ENV_VAR_LIST = std::vector< wxString >
 

Functions

bool IsEnvVarImmutable (const wxString &aEnvVar)
 Determine if an environment variable is "predefined", i.e. More...
 
const ENV_VAR_LISTGetPredefinedEnvVars ()
 Get the list of pre-defined environment variables. More...
 
wxString LookUpEnvVarHelp (const wxString &aEnvVar)
 Look up long-form help text for a given environment variable. More...
 
template<typename VAL_TYPE >
OPT< VAL_TYPE > GetEnvVar (const wxString &aEnvVarName)
 Get an environment variable as a specific type, if set correctly. More...
 
template<>
OPT< wxString > GetEnvVar (const wxString &aEnvVarName)
 Get a string environment variable, if it is set. More...
 
template<>
OPT< double > GetEnvVar (const wxString &aEnvVarName)
 Get a double from an environment variable, if set. More...
 

Typedef Documentation

◆ ENV_VAR_LIST

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

Definition at line 34 of file env_vars.h.

Function Documentation

◆ GetEnvVar() [1/3]

template<typename VAL_TYPE >
OPT< 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 OPT containing the value, if set and parseable, otherwise empty.

◆ GetEnvVar() [2/3]

template<>
OPT< 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 OPT containing the value, if set, otherwise empty.

Definition at line 120 of file env_vars.cpp.

121{
122 wxString env;
123
124 if( wxGetEnv( aEnvVarName, &env ) )
125 {
126 double value;
127
128 if( env.ToDouble( &value ) )
129 return value;
130 }
131
132 return NULLOPT;
133}
const auto NULLOPT
Definition: optional.h:9

References NULLOPT.

◆ GetEnvVar() [3/3]

template<>
OPT< 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 OPT 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 60 of file env_vars.cpp.

61{
62 return predefinedEnvVars;
63}
static const ENV_VAR::ENV_VAR_LIST predefinedEnvVars
Definition: env_vars.cpp:36

References predefinedEnvVars.

Referenced by DIALOG_CONFIGURE_PATHS::OnHelp().

◆ 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 48 of file env_vars.cpp.

49{
50 for( const wxString& s : predefinedEnvVars )
51 {
52 if( s == aEnvVar )
53 return true;
54 }
55
56 return false;
57}

References predefinedEnvVars.

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 108 of file env_vars.cpp.

109{
110 static STRING_MAP envVarHelpText;
111
112 if( envVarHelpText.size() == 0 )
113 initialiseEnvVarHelp( envVarHelpText );
114
115 return envVarHelpText[ aEnvVar ];
116}
static void initialiseEnvVarHelp(STRING_MAP &aMap)
Definition: env_vars.cpp:66
std::map< wxString, wxString > STRING_MAP
Definition: env_vars.cpp:27

References initialiseEnvVarHelp().

Referenced by DIALOG_CONFIGURE_PATHS::OnHelp().