KiCad PCB EDA Suite
Loading...
Searching...
No Matches
include/settings/environment.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_ENVIRONMENT_H
21#define KICAD_ENVIRONMENT_H
22
23#include <map>
24#include <wx/string.h>
25
60{
61public:
62 ENV_VAR_ITEM( const wxString& aValue = wxEmptyString, bool aIsDefinedExternally = false ) :
63 m_value( aValue ),
64 m_isBuiltin( true ),
65 m_isDefinedExternally( aIsDefinedExternally ),
67 {
68 }
69
70 ENV_VAR_ITEM( const wxString& aKey, const wxString& aValue,
71 const wxString& aDefaultValue = wxEmptyString ) :
72 m_key( aKey ),
73 m_value( aValue ),
74 m_defaultValue( aDefaultValue ),
75 m_isBuiltin( true ),
76 m_isDefinedExternally( false ),
78 {
79 }
80
81 ~ENV_VAR_ITEM() throw() {} // tell SWIG no exception
82
84 void SetDefinedExternally( bool aIsDefinedExternally = true )
85 {
86 m_isDefinedExternally = aIsDefinedExternally;
87 }
88
90 void SetDefinedInSettings( bool aDefined = true ) { m_isDefinedInSettings = aDefined; }
91
92 wxString GetKey() const { return m_key; }
93
94 const wxString& GetValue() const { return m_value; }
95 void SetValue( const wxString& aValue ) { m_value = aValue; }
96
97 wxString GetDefault() const { return m_defaultValue; }
98
99 wxString GetSettingsValue() const { return m_settingsValue; }
100 void SetSettingsValue( const wxString& aValue ) { m_settingsValue = aValue; }
101
102 bool GetBuiltin() const { return m_isBuiltin; }
103
108 bool IsDefault() const
109 {
111 }
112
113private:
115 wxString m_key;
116
118 wxString m_value;
119
122
125
128
131
134};
135
136typedef std::map<wxString, ENV_VAR_ITEM> ENV_VAR_MAP;
137typedef std::map<wxString, ENV_VAR_ITEM>::iterator ENV_VAR_MAP_ITER;
138typedef std::map<wxString, ENV_VAR_ITEM>::const_iterator ENV_VAR_MAP_CITER;
139
140#endif // KICAD_ENVIRONMENT_H
KiCad uses environment variables internally for determining the base paths for libraries,...
bool m_isDefinedInSettings
Flag to indicate if the environment variable was defined in the settings file.
wxString m_key
The environment variable string key.
void SetValue(const wxString &aValue)
bool m_isDefinedExternally
Flag to indicate if the environment variable was defined externally to the process.
wxString m_defaultValue
The default value, for built-in variables that are always defined.
bool GetDefinedExternally() const
wxString GetSettingsValue() const
wxString GetDefault() const
void SetDefinedExternally(bool aIsDefinedExternally=true)
bool m_isBuiltin
Set to true for KiCad built-in variables that are always defined one way or another.
void SetSettingsValue(const wxString &aValue)
wxString m_settingsValue
The value that was originally loaded from JSON.
const wxString & GetValue() const
ENV_VAR_ITEM(const wxString &aValue=wxEmptyString, bool aIsDefinedExternally=false)
ENV_VAR_ITEM(const wxString &aKey, const wxString &aValue, const wxString &aDefaultValue=wxEmptyString)
void SetDefinedInSettings(bool aDefined=true)
bool IsDefault() const
Checks if the variable matches its default value (always false for non-built-in vars)
wxString m_value
The environment variable string value.
bool GetDefinedInSettings() const
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
std::map< wxString, ENV_VAR_ITEM >::const_iterator ENV_VAR_MAP_CITER
std::map< wxString, ENV_VAR_ITEM >::iterator ENV_VAR_MAP_ITER