|
KiCad PCB EDA Suite
|
Guesses the table and column mappings of a new database library from their names. More...
Classes | |
| struct | ROLE |
| One mapping to fill, such as the key column or the Value field. More... | |
Enumerations | |
| enum | MATCH_SCORE { NO_MATCH = 0 , SUBSTRING = 10 , AFFIX = 30 , INNER_WORD = 60 , EDGE_WORD = 80 , EXACT = 100 , REMEMBERED = 1000 } |
Functions | |
| static std::vector< wxString > | SplitWords (const wxString &aName) |
| Splits an identifier into lower case words: "PCBFootprint_ref2" gives pcb, footprint, ref, 2. | |
| static bool | sameWord (const wxString &aA, const wxString &aB) |
| static bool | wordsMatchAt (const std::vector< wxString > &aWords, const std::vector< wxString > &aTerm, size_t aPos) |
| static wxString | joined (const std::vector< wxString > &aWords) |
| static int | MatchScore (const wxString &aName, const wxString &aTerm) |
| static int | roleScore (const ROLE &aRole, const std::string &aColumn) |
| std::vector< std::string > | AssignColumns (const std::vector< std::string > &aColumns, const std::vector< ROLE > &aRoles) |
| Chooses a column for each role, best scores first, so no column serves two roles. | |
| std::string | MatchTable (const std::vector< std::string > &aTables, const std::string &aLibraryName) |
| std::map< std::string, size_t > | RepeatCounts (const std::vector< std::map< std::string, std::any > > &aRows) |
| Counts, per column, the rows whose value already appeared in an earlier row, with NULL counted as empty. | |
| void | RememberChoice (std::vector< std::string > &aHistory, const std::string &aColumn) |
| Moves aColumn to the front of a role's history, dropping repeats and the oldest entries. | |
Variables | |
| static constexpr size_t | MAX_REMEMBERED = 8 |
Guesses the table and column mappings of a new database library from their names.
Names are compared word by word, where words break at separators, digits and case changes, so "PartID" and "part_id" both end in the word "id" while "Identical" and "Flacid" only contain it.
| Enumerator | |
|---|---|
| NO_MATCH | |
| SUBSTRING | The term is buried inside a word: "myfootprintref" for "footprint". |
| AFFIX | The name starts or ends with the term mid-word: "Identical", "partid". |
| INNER_WORD | The term is a whole word inside the name: "Main ID Code". |
| EDGE_WORD | The term is a whole word at either end: "PartID", "symbol_ref". |
| EXACT | The name is the term: "ID", "Symbols". |
| REMEMBERED | A column the user chose before; earlier choices score lower. |
Definition at line 33 of file database_autofill.cpp.
| KICOMMON_API std::vector< std::string > DB_AUTOFILL::AssignColumns | ( | const std::vector< std::string > & | aColumns, |
| const std::vector< ROLE > & | aRoles ) |
Chooses a column for each role, best scores first, so no column serves two roles.
Definition at line 183 of file database_autofill.cpp.
References candidates(), NO_MATCH, and roleScore().
Referenced by DIALOG_DATABASE_LIB_SETTINGS::autofillColumns().
|
static |
Definition at line 110 of file database_autofill.cpp.
Referenced by MatchScore().
|
static |
Definition at line 122 of file database_autofill.cpp.
References AFFIX, EDGE_WORD, EXACT, INNER_WORD, joined(), name, NO_MATCH, SplitWords(), SUBSTRING, and wordsMatchAt().
Referenced by MatchTable(), and roleScore().
| KICOMMON_API std::string DB_AUTOFILL::MatchTable | ( | const std::vector< std::string > & | aTables, |
| const std::string & | aLibraryName ) |
Definition at line 217 of file database_autofill.cpp.
References INNER_WORD, library, MatchScore(), name, and table.
Referenced by DIALOG_DATABASE_LIB_SETTINGS::autofillTable().
| KICOMMON_API void DB_AUTOFILL::RememberChoice | ( | std::vector< std::string > & | aHistory, |
| const std::string & | aColumn ) |
Moves aColumn to the front of a role's history, dropping repeats and the oldest entries.
Definition at line 264 of file database_autofill.cpp.
References MAX_REMEMBERED.
Referenced by DIALOG_DATABASE_LIB_SETTINGS::TransferDataFromWindow().
| KICOMMON_API std::map< std::string, size_t > DB_AUTOFILL::RepeatCounts | ( | const std::vector< std::map< std::string, std::any > > & | aRows | ) |
Counts, per column, the rows whose value already appeared in an earlier row, with NULL counted as empty.
A key column needs a count of zero, or parts sharing a key hide each other.
Definition at line 241 of file database_autofill.cpp.
References text.
Referenced by DIALOG_DATABASE_LIB_SETTINGS::ensureSample().
|
static |
Definition at line 161 of file database_autofill.cpp.
References DB_AUTOFILL::ROLE::excluded, MatchScore(), NO_MATCH, REMEMBERED, DB_AUTOFILL::ROLE::remembered, and DB_AUTOFILL::ROLE::terms.
Referenced by AssignColumns().
|
static |
Definition at line 91 of file database_autofill.cpp.
Referenced by wordsMatchAt().
|
static |
Splits an identifier into lower case words: "PCBFootprint_ref2" gives pcb, footprint, ref, 2.
Definition at line 46 of file database_autofill.cpp.
Referenced by MatchScore().
|
static |
Definition at line 98 of file database_autofill.cpp.
References sameWord().
Referenced by MatchScore().
|
staticconstexpr |
Definition at line 31 of file database_autofill.cpp.
Referenced by RememberChoice().