KiCad PCB EDA Suite
Loading...
Searching...
No Matches
env_var_utils.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <optional>
23
24#include <wx/string.h>
25
27
28
29namespace KI_TEST
30{
43{
44public:
45 SCOPED_PROCESS_ENV_VAR( const wxString& aName, const std::optional<wxString>& aValue );
47
48 // No copying, or the destructor will restore multiple times.
51
56 void SetValue( const wxString& aValue );
57
61 std::optional<wxString> GetValue() const;
62
67 void ClearValue();
68
69private:
70 wxString m_name;
71 std::optional<wxString> m_oldValue;
72};
73
74
84{
85public:
91 SCOPED_PGM_ENV_VAR( const wxString& aName, const std::optional<wxString>& aValue );
93
94 // No copying, or the destructor will restore multiple times.
97
103 const ENV_VAR_ITEM& GetItem() const;
104
108 void ClearItem() { m_pgmEnvVars.erase( m_name ); }
109
110private:
112 wxString m_name;
113 std::optional<ENV_VAR_ITEM> m_oldValue;
114};
115
116} // namespace KI_TEST
KiCad uses environment variables internally for determining the base paths for libraries,...
void ClearItem()
Clear the environment variable for the lifetime of the object.
SCOPED_PGM_ENV_VAR & operator=(const SCOPED_PGM_ENV_VAR &)=delete
std::optional< ENV_VAR_ITEM > m_oldValue
SCOPED_PGM_ENV_VAR(const SCOPED_PGM_ENV_VAR &)=delete
ENV_VAR_ITEM & GetItem()
Get the wrapped environment variable item.
SCOPED_PGM_ENV_VAR(const wxString &aName, const std::optional< wxString > &aValue)
std::optional< wxString > m_oldValue
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.
void SetValue(const wxString &aValue)
Set a new value for the environment variable (which will still only be in effect for the lifetime of ...
SCOPED_PROCESS_ENV_VAR(const SCOPED_PROCESS_ENV_VAR &)=delete
SCOPED_PROCESS_ENV_VAR(const wxString &aName, const std::optional< wxString > &aValue)
SCOPED_PROCESS_ENV_VAR & operator=(const SCOPED_PROCESS_ENV_VAR &)=delete
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP