KiCad PCB EDA Suite
Loading...
Searching...
No Matches
database_autofill.cpp File Reference
#include <database/database_autofill.h>
#include <algorithm>
#include <tuple>
#include <wx/wxcrt.h>

Go to the source code of this file.

Namespaces

namespace  DB_AUTOFILL
 Guesses the table and column mappings of a new database library from their names.
 

Enumerations

enum  DB_AUTOFILL::MATCH_SCORE {
  DB_AUTOFILL::NO_MATCH = 0 , DB_AUTOFILL::SUBSTRING = 10 , DB_AUTOFILL::AFFIX = 30 , DB_AUTOFILL::INNER_WORD = 60 ,
  DB_AUTOFILL::EDGE_WORD = 80 , DB_AUTOFILL::EXACT = 100 , DB_AUTOFILL::REMEMBERED = 1000
}
 

Functions

static std::vector< wxString > DB_AUTOFILL::SplitWords (const wxString &aName)
 Splits an identifier into lower case words: "PCBFootprint_ref2" gives pcb, footprint, ref, 2.
 
static bool DB_AUTOFILL::sameWord (const wxString &aA, const wxString &aB)
 
static bool DB_AUTOFILL::wordsMatchAt (const std::vector< wxString > &aWords, const std::vector< wxString > &aTerm, size_t aPos)
 
static wxString DB_AUTOFILL::joined (const std::vector< wxString > &aWords)
 
static int DB_AUTOFILL::MatchScore (const wxString &aName, const wxString &aTerm)
 
static int DB_AUTOFILL::roleScore (const ROLE &aRole, const std::string &aColumn)
 
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.
 
std::string DB_AUTOFILL::MatchTable (const std::vector< std::string > &aTables, const std::string &aLibraryName)
 
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.
 
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.
 

Variables

static constexpr size_t DB_AUTOFILL::MAX_REMEMBERED = 8