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 148 of file panel_fp_lib_table.cpp.

Constructor & Destructor Documentation

◆ LIBRARY_TRAVERSER()

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

Definition at line 151 of file panel_fp_lib_table.cpp.

152 : m_searchExtension( aSearchExtension ),
153 m_currentDir( aInitialDir )
154 {
155 }

Member Function Documentation

◆ GetFailedPaths()

void LIBRARY_TRAVERSER::GetFailedPaths ( wxArrayString &  aPathArray)
inline

Definition at line 190 of file panel_fp_lib_table.cpp.

191 {
192 for( std::pair<const wxString, int>& failedDirsPair : m_failedDirs )
193 aPathArray.Add( failedDirsPair.first );
194 }
std::unordered_map< wxString, int > m_failedDirs

References m_failedDirs.

◆ GetPaths()

void LIBRARY_TRAVERSER::GetPaths ( wxArrayString &  aPathArray)
inline

Definition at line 184 of file panel_fp_lib_table.cpp.

185 {
186 for( std::pair<const wxString, int>& foundDirsPair : m_foundDirs )
187 aPathArray.Add( foundDirsPair.first );
188 }
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 173 of file panel_fp_lib_table.cpp.

174 {
175 return m_failedDirs.size() > 0;
176 }

References m_failedDirs.

Referenced by PANEL_FP_LIB_TABLE::browseLibrariesHandler().

◆ OnDir()

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

Definition at line 178 of file panel_fp_lib_table.cpp.

179 {
180 m_currentDir = aDirName;
181 return wxDIR_CONTINUE;
182 }

References m_currentDir.

◆ OnFile()

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

Definition at line 157 of file panel_fp_lib_table.cpp.

158 {
159 wxFileName file( aFileName );
160
161 if( m_searchExtension.IsSameAs( file.GetExt(), false ) )
162 m_foundDirs.insert( { m_currentDir, 1 } );
163
164 return wxDIR_CONTINUE;
165 }

References m_currentDir, m_foundDirs, and m_searchExtension.

◆ OnOpenError()

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

Definition at line 167 of file panel_fp_lib_table.cpp.

168 {
169 m_failedDirs.insert( { aOpenErrorName, 1 } );
170 return wxDIR_IGNORE;
171 }

References m_failedDirs.

Member Data Documentation

◆ m_currentDir

wxString LIBRARY_TRAVERSER::m_currentDir
private

Definition at line 198 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 200 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 199 of file panel_fp_lib_table.cpp.

Referenced by GetPaths(), and OnFile().

◆ m_searchExtension

wxString LIBRARY_TRAVERSER::m_searchExtension
private

Definition at line 197 of file panel_fp_lib_table.cpp.

Referenced by OnFile().


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