|
KiCad PCB EDA Suite
|
#include <cctype>#include <filesystem>#include <functional>#include <set>#include <string>#include <utility>#include <vector>#include <wx/dir.h>#include <wx/ffile.h>#include <wx/filefn.h>#include <wx/filename.h>#include <wx/intl.h>#include <wx/string.h>#include <wx/utils.h>Go to the source code of this file.
Classes | |
| struct | DATED_TOKEN |
| A token dated by the format that introduced it, for the fail-closed downgrade gates. More... | |
| class | DOWNGRADE_FILE_TRANSACTION |
| Stage related design and library files together, retaining originals until every write is ready. More... | |
| struct | DOWNGRADE_FILE_TRANSACTION::ENTRY |
Enumerations | |
| enum class | DOWNGRADE_FILE_RESULT { CONVERTED , SKIPPED , REFUSED } |
| What a per-file converter did with one library file. More... | |
Functions | |
| std::string | StripSexprStrings (const std::string &aText) |
| Drop quoted strings so a token inside a text value cannot cause a false refusal. | |
| bool | ContainsSexprNode (const std::string &aText, const std::string &aToken) |
| bool | ContainsSexprValue (const std::string &aText, const std::string &aToken) |
| Some features are written as a bareword value, not a node head, so the node scan cannot see them. | |
| wxString | FindUnsupportedToken (const wxString &aSerialized, const DATED_TOKEN *aNodes, size_t aNodeCount, const DATED_TOKEN *aValues, size_t aValueCount, int aTargetVersion) |
| Scan serialized s-expression text against dated node and value denylists. | |
| std::set< std::string > | ExtractSexprNodeHeads (const std::string &aText) |
| Every lowercase node head in the text, e.g. for checking output against a release keyword set. | |
| bool | IsDowngradeWorkingArtifact (const wxString &aPath) |
| Editor working state (autosaves, local history, backups) holds current-format copies nothing downgrades, so exports and scans must skip it. | |
| bool | IsDowngradeDesignFile (const wxString &aPath) |
| Files the project export carries over. | |
| bool | VerifyDowngradedFile (const wxString &aPath, int aStampVersion, const std::function< wxString(const wxString &)> &aFindForbidden, wxString *aForbidden=nullptr) |
| Read back a downgraded output and require the target stamp plus a clean token scan. | |
| wxString | DowngradeLibraryFilesInPlace (const wxString &aDir, const wxString &aGlob, int aStampVersion, const std::function< wxString(const wxString &)> &aFindForbidden, const std::function< DOWNGRADE_FILE_RESULT(const wxString &, const wxString &)> &aConvert, DOWNGRADE_FILE_TRANSACTION *aTransaction=nullptr, wxString *aRecoveryError=nullptr) |
| Downgrade every library file matching aGlob under aDir in place. | |
|
strong |
What a per-file converter did with one library file.
| Enumerator | |
|---|---|
| CONVERTED | The temp file holds the downgraded copy. |
| SKIPPED | Not a convertible file, leave it alone. |
| REFUSED | The target cannot represent this file. |
Definition at line 239 of file downgrade_scan.h.
|
inline |
Definition at line 81 of file downgrade_scan.h.
References next().
Referenced by FindUnsupportedToken().
|
inline |
Some features are written as a bareword value, not a node head, so the node scan cannot see them.
Match the token as a whole word instead.
Definition at line 101 of file downgrade_scan.h.
References next().
Referenced by DrcRuleUnsupportedByTarget(), and FindUnsupportedToken().
|
inline |
Downgrade every library file matching aGlob under aDir in place.
aConvert writes one file's downgraded copy to the temp path. With aTransaction, leave replacements staged for its owner. Otherwise commit all library replacements together after every converted file is verified. Returns the first file the target could not open or replace, or empty when all are safe.
Definition at line 473 of file downgrade_scan.h.
References DOWNGRADE_FILE_TRANSACTION::Commit(), CONVERTED, DOWNGRADE_FILE_TRANSACTION::Discard(), DOWNGRADE_FILE_TRANSACTION::GetRecoveryError(), IsDowngradeWorkingArtifact(), REFUSED, SKIPPED, DOWNGRADE_FILE_TRANSACTION::Stage(), and VerifyDowngradedFile().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), downgradeFootprintLibraries(), and downgradeSymbolLibraries().
|
inline |
Every lowercase node head in the text, e.g. for checking output against a release keyword set.
Definition at line 146 of file downgrade_scan.h.
|
inline |
Scan serialized s-expression text against dated node and value denylists.
Returns the first token the target cannot parse, or empty if the text is safe.
Definition at line 122 of file downgrade_scan.h.
References ContainsSexprNode(), ContainsSexprValue(), StripSexprStrings(), and text.
Referenced by FindUnsupportedBoardToken(), and FindUnsupportedSchToken().
|
inline |
Files the project export carries over.
Everything else in the project folder stays behind: UI state, backups, and non-KiCad files like datasheets and gerbers. Case-sensitive on purpose, so the filter agrees with the converter globs on every platform.
Definition at line 193 of file downgrade_scan.h.
References name.
Referenced by BOOST_AUTO_TEST_CASE(), CLI::PROJECT_DOWNGRADE_COMMAND::doPerform(), and ExportProjectForDowngrade().
|
inline |
Editor working state (autosaves, local history, backups) holds current-format copies nothing downgrades, so exports and scans must skip it.
Definition at line 173 of file downgrade_scan.h.
Referenced by classifyFootprintLibraries(), classifySymbolLibraries(), DowngradeLibraryFilesInPlace(), ExportProjectForDowngrade(), firstTooNewFile(), IsDowngradeLibraryWorkingArtifact(), and legacyLibraryTables().
|
inline |
Drop quoted strings so a token inside a text value cannot cause a false refusal.
Definition at line 48 of file downgrade_scan.h.
References result.
Referenced by containsGroupPlacementSource(), DrcRuleUnsupportedByTarget(), FindUnsupportedToken(), and readSexprVersion().
|
inline |
Read back a downgraded output and require the target stamp plus a clean token scan.
An output that cannot be read back to verify counts as a failure too.
Definition at line 211 of file downgrade_scan.h.
Referenced by DowngradeLibraryFilesInPlace(), ExportBoardToOlderVersion(), and EESCHEMA_JOBS_HANDLER::JobDowngrade().