KiCad PCB EDA Suite
readwrite_dlgs.cpp File Reference
#include <fctsys.h>
#include <kiway.h>
#include <common.h>
#include <confirm.h>
#include <build_version.h>
#include <macros.h>
#include <lib_id.h>
#include <fp_lib_table.h>
#include <reporter.h>
#include <html_messagebox.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <listview_classes.h>
#include <wildcards_and_files_ext.h>
#include <fp_conflict_assignment_selector.h>

Go to the source code of this file.

Functions

static int guessNickname (FP_LIB_TABLE *aTbl, LIB_ID *aFootprintId)
 Return true if the resultant LIB_ID has a certain nickname. More...
 

Function Documentation

static int guessNickname ( FP_LIB_TABLE aTbl,
LIB_ID aFootprintId 
)
static

Return true if the resultant LIB_ID has a certain nickname.

The guess is only made if this footprint resides in only one library.

Returns
int - 0 on success, 1 on not found, 2 on ambiguous i.e. multiple matches

Definition at line 140 of file readwrite_dlgs.cpp.

References FP_LIB_TABLE::FootprintEnumerate(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), LIB_TABLE::GetLogicalLibs(), LIB_ID::SetLibNickname(), and UTF8::size().

Referenced by CVPCB_MAINFRAME::ReadNetListAndFpFiles().

141 {
142  if( aFootprintId->GetLibNickname().size() )
143  return 0;
144 
145  wxString nick;
146  wxString fpname = aFootprintId->GetLibItemName();
147 
148  std::vector<wxString> nicks = aTbl->GetLogicalLibs();
149 
150  // Search each library going through libraries alphabetically.
151  for( unsigned libNdx = 0; libNdx<nicks.size(); ++libNdx )
152  {
153  wxArrayString fpnames;
154 
155  aTbl->FootprintEnumerate( fpnames, nicks[libNdx] );
156 
157  for( unsigned nameNdx = 0; nameNdx<fpnames.size(); ++nameNdx )
158  {
159  if( fpname == fpnames[nameNdx] )
160  {
161  if( !nick )
162  nick = nicks[libNdx];
163  else
164  return 2; // duplicate, the guess would not be certain
165  }
166  }
167  }
168 
169  if( nick.size() )
170  {
171  aFootprintId->SetLibNickname( nick );
172  return 0;
173  }
174 
175  return 1;
176 }
std::string::size_type size() const
Definition: utf8.h:115
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:219
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname)
Return a list of footprint names contained within the library given by aNickname. ...
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:98
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE...