KiCad PCB EDA Suite
Loading...
Searching...
No Matches
database_autofill.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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#ifndef KICAD_DATABASE_AUTOFILL_H
21#define KICAD_DATABASE_AUTOFILL_H
22
23#include <any>
24#include <map>
25#include <set>
26#include <string>
27#include <vector>
28
29#include <kicommon.h>
30#include <wx/string.h>
31#include <wx/arrstr.h> // for MSVC to see std::vector<wxString> is exported from wx
32
39namespace DB_AUTOFILL
40{
41
43struct ROLE
44{
45 std::vector<wxString> terms;
46 std::vector<std::string> remembered;
47 std::set<std::string> excluded;
48};
49
55KICOMMON_API std::vector<std::string> AssignColumns( const std::vector<std::string>& aColumns,
56 const std::vector<ROLE>& aRoles );
57
59KICOMMON_API std::string MatchTable( const std::vector<std::string>& aTables, const std::string& aLibraryName );
60
65KICOMMON_API std::map<std::string, size_t>
66RepeatCounts( const std::vector<std::map<std::string, std::any>>& aRows );
67
69KICOMMON_API void RememberChoice( std::vector<std::string>& aHistory, const std::string& aColumn );
70
71} // namespace DB_AUTOFILL
72
73#endif // KICAD_DATABASE_AUTOFILL_H
#define KICOMMON_API
Definition kicommon.h:27
Guesses the table and column mappings of a new database library from their names.
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.
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.
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 emp...
One mapping to fill, such as the key column or the Value field.
std::vector< std::string > remembered
Columns the user chose before, most recent first.
std::set< std::string > excluded
Columns this role must not take, even when remembered.
std::vector< wxString > terms
Words to look for, in English and translated.