KiCad PCB EDA Suite
LIBRARY_TRAVERSER Class Reference

Traverser implementation that looks to find any and all "folder" libraries by looking for files with a specific extension inside folders. More...

Inheritance diagram for LIBRARY_TRAVERSER:

Public Member Functions

 LIBRARY_TRAVERSER (wxString aSearchExtension, wxString aInitialDir)
 
virtual wxDirTraverseResult OnFile (const wxString &aFileName) override
 
virtual wxDirTraverseResult OnOpenError (const wxString &aOpenErrorName) override
 
bool HasDirectoryOpenFailures ()
 
virtual wxDirTraverseResult OnDir (const wxString &aDirName) override
 
void GetPaths (wxArrayString &aPathArray)
 
void GetFailedPaths (wxArrayString &aPathArray)
 

Private Attributes

wxString m_searchExtension
 
wxString m_currentDir
 
std::unordered_map< wxString, int > m_foundDirs
 
std::unordered_map< wxString, int > m_failedDirs
 

Detailed Description

Traverser implementation that looks to find any and all "folder" libraries by looking for files with a specific extension inside folders.

Definition at line 139 of file panel_fp_lib_table.cpp.

Constructor & Destructor Documentation

◆ LIBRARY_TRAVERSER()

LIBRARY_TRAVERSER::LIBRARY_TRAVERSER ( wxString  aSearchExtension,
wxString  aInitialDir 
)
inline

Definition at line 142 of file panel_fp_lib_table.cpp.

143  : m_searchExtension( aSearchExtension ),
144  m_currentDir( aInitialDir )
145  {
146  }

Member Function Documentation

◆ GetFailedPaths()

void LIBRARY_TRAVERSER::GetFailedPaths ( wxArrayString &  aPathArray)
inline

Definition at line 181 of file panel_fp_lib_table.cpp.

182  {
183  for( std::pair<const wxString, int>& failedDirsPair : m_failedDirs )
184  aPathArray.Add( failedDirsPair.first );
185  }
std::unordered_map< wxString, int > m_failedDirs

References m_failedDirs.

◆ GetPaths()

void LIBRARY_TRAVERSER::GetPaths ( wxArrayString &  aPathArray)
inline

Definition at line 175 of file panel_fp_lib_table.cpp.

176  {
177  for( std::pair<const wxString, int>& foundDirsPair : m_foundDirs )
178  aPathArray.Add( foundDirsPair.first );
179  }
std::unordered_map< wxString, int > m_foundDirs

References m_foundDirs.

Referenced by PANEL_FP_LIB_TABLE::browseLibrariesHandler().

◆ HasDirectoryOpenFailures()

bool LIBRARY_TRAVERSER::HasDirectoryOpenFailures ( )
inline

Definition at line 164 of file panel_fp_lib_table.cpp.

165  {
166  return m_failedDirs.size() > 0;
167  }
std::unordered_map< wxString, int > m_failedDirs

References m_failedDirs.

◆ OnDir()

virtual wxDirTraverseResult LIBRARY_TRAVERSER::OnDir ( const wxString &  aDirName)
inlineoverridevirtual

Definition at line 169 of file panel_fp_lib_table.cpp.

170  {
171  m_currentDir = aDirName;
172  return wxDIR_CONTINUE;
173  }

References m_currentDir.

◆ OnFile()

virtual wxDirTraverseResult LIBRARY_TRAVERSER::OnFile ( const wxString &  aFileName)
inlineoverridevirtual

Definition at line 148 of file panel_fp_lib_table.cpp.

149  {
150  wxFileName file( aFileName );
151 
152  if( m_searchExtension.IsSameAs( file.GetExt(), false ) )
153  m_foundDirs.insert( { m_currentDir, 1 } );
154 
155  return wxDIR_CONTINUE;
156  }
std::unordered_map< wxString, int > m_foundDirs

References m_currentDir, m_foundDirs, and m_searchExtension.

◆ OnOpenError()

virtual wxDirTraverseResult LIBRARY_TRAVERSER::OnOpenError ( const wxString &  aOpenErrorName)
inlineoverridevirtual

Definition at line 158 of file panel_fp_lib_table.cpp.

159  {
160  m_failedDirs.insert( { aOpenErrorName, 1 } );
161  return wxDIR_IGNORE;
162  }
std::unordered_map< wxString, int > m_failedDirs

References m_failedDirs.

Member Data Documentation

◆ m_currentDir

wxString LIBRARY_TRAVERSER::m_currentDir
private

Definition at line 189 of file panel_fp_lib_table.cpp.

Referenced by OnDir(), and OnFile().

◆ m_failedDirs

std::unordered_map<wxString, int> LIBRARY_TRAVERSER::m_failedDirs
private

Definition at line 191 of file panel_fp_lib_table.cpp.

Referenced by GetFailedPaths(), HasDirectoryOpenFailures(), and OnOpenError().

◆ m_foundDirs

std::unordered_map<wxString, int> LIBRARY_TRAVERSER::m_foundDirs
private

Definition at line 190 of file panel_fp_lib_table.cpp.

Referenced by GetPaths(), and OnFile().

◆ m_searchExtension

wxString LIBRARY_TRAVERSER::m_searchExtension
private

Definition at line 188 of file panel_fp_lib_table.cpp.

Referenced by OnFile().


The documentation for this class was generated from the following file: