Cppcheck
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | List of all members
FileList Class Reference

A class for listing files and directories to check. More...

#include <filelist.h>

Public Member Functions

void addFile (const QString &filepath)
 Add filename to the list. More...
 
void addDirectory (const QString &directory, bool recursive=false)
 Add files in the directory to the list. More...
 
void addPathList (const QStringList &paths)
 Add list of filenames and directories to the list. More...
 
QStringList getFileList () const
 Return list of filenames (to check). More...
 
void addExcludeList (const QStringList &paths)
 Add list of paths to exclusion list. More...
 

Static Public Member Functions

static QStringList getDefaultFilters ()
 Return list of default filename extensions included. More...
 

Protected Member Functions

QStringList applyExcludeList () const
 Get filtered list of paths. More...
 

Static Protected Member Functions

static bool filterMatches (const QFileInfo &inf)
 Test if filename matches the filename extensions filtering. More...
 

Private Attributes

QFileInfoList mFileList
 
QStringList mExcludedPaths
 

Detailed Description

A class for listing files and directories to check.

This class creates a list of files to check. If directory name is given then all files in the directory matching the filter will be added. The directory can be also added recursively when all files in subdirectories are added too. The filenames are matched against the filter and only those files whose filename extension is included in the filter list are added.

This class also handles filtering of paths against ignore filters given. If there is ignore filters then only paths not matching those filters are returned.

Definition at line 39 of file filelist.h.

Member Function Documentation

◆ addDirectory()

void FileList::addDirectory ( const QString &  directory,
bool  recursive = false 
)

Add files in the directory to the list.

Parameters
directoryFull pathname to directory to add.
recursiveIf true also files in subdirectories are added.

Definition at line 57 of file filelist.cpp.

References getDefaultFilters(), mFileList, and CppcheckXml::Name.

Referenced by addPathList().

◆ addExcludeList()

void FileList::addExcludeList ( const QStringList &  paths)

Add list of paths to exclusion list.

Parameters
pathsPaths to exclude.

Definition at line 106 of file filelist.cpp.

References mExcludedPaths.

Referenced by MainWindow::doAnalyzeFiles(), and MainWindow::reAnalyzeSelected().

◆ addFile()

void FileList::addFile ( const QString &  filepath)

Add filename to the list.

Parameters
filepathFull path to the file.

Definition at line 50 of file filelist.cpp.

References filterMatches(), and mFileList.

Referenced by addPathList(), and ComplianceReportDialog::save().

◆ addPathList()

void FileList::addPathList ( const QStringList &  paths)

Add list of filenames and directories to the list.

Parameters
pathsList of paths to add.

Definition at line 82 of file filelist.cpp.

References addDirectory(), and addFile().

Referenced by MainWindow::doAnalyzeFiles(), MainWindow::reAnalyzeSelected(), and ComplianceReportDialog::save().

◆ applyExcludeList()

QStringList FileList::applyExcludeList ( ) const
protected

Get filtered list of paths.

This method takes the list of paths and applies the exclude lists to it. And then returns the list of paths that did not match the exclude filters.

Returns
Filtered list of paths.

Definition at line 120 of file filelist.cpp.

References PathMatch::match(), mExcludedPaths, mFileList, and toStdStringList().

Referenced by getFileList().

◆ filterMatches()

bool FileList::filterMatches ( const QFileInfo &  inf)
staticprotected

Test if filename matches the filename extensions filtering.

Returns
true if filename matches filtering.

Definition at line 38 of file filelist.cpp.

References getDefaultFilters().

Referenced by addFile().

◆ getDefaultFilters()

QStringList FileList::getDefaultFilters ( )
static

Return list of default filename extensions included.

Returns
list of default filename extensions included.

Definition at line 31 of file filelist.cpp.

Referenced by addDirectory(), filterMatches(), and MainWindow::selectFilesToAnalyze().

◆ getFileList()

QStringList FileList::getFileList ( ) const

Return list of filenames (to check).

Returns
list of filenames to check.

Definition at line 93 of file filelist.cpp.

References applyExcludeList(), mExcludedPaths, and mFileList.

Referenced by MainWindow::doAnalyzeFiles(), MainWindow::reAnalyzeSelected(), and ComplianceReportDialog::save().

Member Data Documentation

◆ mExcludedPaths

QStringList FileList::mExcludedPaths
private

Definition at line 98 of file filelist.h.

Referenced by addExcludeList(), applyExcludeList(), and getFileList().

◆ mFileList

QFileInfoList FileList::mFileList
private

Definition at line 97 of file filelist.h.

Referenced by addDirectory(), addFile(), applyExcludeList(), and getFileList().


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