KiCad PCB EDA Suite
Loading...
Searching...
No Matches
common.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) 2014-2020 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#pragma once
24
25#include <kicommon.h>
26#include <functional>
27#include <memory>
28#include <vector>
29
30#include <wx/fileconf.h>
31#include <wx/string.h>
32#include <wx/process.h>
33
34#include <text_var_dependency.h>
35
36class PROJECT;
37class SEARCH_STACK;
38class REPORTER;
39
52KICOMMON_API wxString SearchHelpFileFullPath( const wxString& aBaseName );
53
63KICOMMON_API bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, const wxString& aBaseFilename,
64 REPORTER* aReporter = nullptr );
65
69KICOMMON_API wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtension );
70
76KICOMMON_API wxString JoinExtensions( const std::vector<std::string>& aExts );
77
84KICOMMON_API const wxString ExpandEnvVarSubstitutions( const wxString& aString, const PROJECT* aProject );
85
87{
92 INTERNAL, // Importantly, keeps the escape on literal variable references (such as "\${foo}")
95};
96
97KICOMMON_API void FinalizeTextVarExpansion( wxString& aText, RESOLUTION_CONTEXT aContext );
98
99KICOMMON_API wxString ExpandTextVars( const wxString& aSource, const std::function<bool( wxString* )>* aResolver,
100 RESOLUTION_CONTEXT aContext, int aDepth = 0 );
101
102KICOMMON_API wxString ExpandTextVars( const wxString& aSource, const PROJECT* aProject,
103 RESOLUTION_CONTEXT aContext );
104
114KICOMMON_API wxString NormalizeFilePathForTextVars( const wxString& aPath );
115
124KICOMMON_API std::vector<TEXT_VAR_REF_KEY> ExtractTextVarReferences( const wxString& aSource );
125
143KICOMMON_API wxString ResolveTextVars( const wxString& aSource, const std::function<bool( wxString* )>* aResolver,
144 int& aDepth );
145
149KICOMMON_API wxString GetGeneratedFieldDisplayName( const wxString& aSource );
150
154KICOMMON_API bool IsGeneratedField( const wxString& aFieldName );
155
159KICOMMON_API bool IsGeneratedValue( const wxString& aValue );
160
164KICOMMON_API wxString DescribeRef( const wxString& aRef );
165
169KICOMMON_API const wxString ResolveUriByEnvVars( const wxString& aUri, const PROJECT* aProject );
170
171
178
Container for project specific data.
Definition project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Look for files in a number of paths.
KICOMMON_API wxString GetGeneratedFieldDisplayName(const wxString &aSource)
Returns any variables unexpanded, e.g.
Definition common.cpp:481
KICOMMON_API wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition common.cpp:848
KICOMMON_API bool IsGeneratedField(const wxString &aFieldName)
Returns true if the entire string is generated, e.g is a single text var reference.
Definition common.cpp:494
KICOMMON_API wxString NormalizeFilePathForTextVars(const wxString &aPath)
Normalize a file path so its text variables survive ExpandTextVars.
Definition common.cpp:72
KICOMMON_API bool IsGeneratedValue(const wxString &aValue)
Returns true if some of the string is generated, e.g contains a text var or expression.
Definition common.cpp:502
KICOMMON_API wxString ExpandTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, RESOLUTION_CONTEXT aContext, int aDepth=0)
Definition common.cpp:103
KICOMMON_API const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition common.cpp:776
KICOMMON_API wxString JoinExtensions(const std::vector< std::string > &aExts)
Join a list of file extensions for use in a file dialog.
Definition common.cpp:867
KICOMMON_API wxString ResolveTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, int &aDepth)
Multi-pass text variable expansion and math expression evaluation.
Definition common.cpp:333
KICOMMON_API const wxString ResolveUriByEnvVars(const wxString &aUri, const PROJECT *aProject)
Replace any environment and/or text variables in URIs.
Definition common.cpp:789
KICOMMON_API std::vector< TEXT_VAR_REF_KEY > ExtractTextVarReferences(const wxString &aSource)
Lex-scan aSource and return every ${...} reference that appears, without resolving.
Definition common.cpp:468
RESOLUTION_CONTEXT
Definition common.h:87
@ FOR_ERC_DRC
Definition common.h:91
@ FOR_GUI
Definition common.h:89
@ FOR_CANVAS
Definition common.h:88
@ FOR_NETNAME
Definition common.h:90
@ RAW_VALUE
Definition common.h:94
@ INTERNAL
Definition common.h:92
@ RESOLVED
Definition common.h:93
KICOMMON_API bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter=nullptr)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
Definition common.cpp:797
KICOMMON_API wxString SearchHelpFileFullPath(const wxString &aBaseName)
Return the help file's full path.
KICOMMON_API void FinalizeTextVarExpansion(wxString &aText, RESOLUTION_CONTEXT aContext)
Definition common.cpp:88
KICOMMON_API wxString DescribeRef(const wxString &aRef)
Returns a user-visible HTML string describing a footprint reference designator.
Definition common.cpp:508
KICOMMON_API bool WarnUserIfOperatingSystemUnsupported()
Checks if the operating system is explicitly unsupported and displays a disclaimer message box.
Definition common.cpp:1001
#define KICOMMON_API
Definition kicommon.h:27