Blame lib/pathmatch.h

Packit 2035a7
/*
Packit 2035a7
 * Cppcheck - A tool for static C/C++ code analysis
Packit 2035a7
 * Copyright (C) 2007-2017 Cppcheck team.
Packit 2035a7
 *
Packit 2035a7
 * This program is free software: you can redistribute it and/or modify
Packit 2035a7
 * it under the terms of the GNU General Public License as published by
Packit 2035a7
 * the Free Software Foundation, either version 3 of the License, or
Packit 2035a7
 * (at your option) any later version.
Packit 2035a7
 *
Packit 2035a7
 * This program is distributed in the hope that it will be useful,
Packit 2035a7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 2035a7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 2035a7
 * GNU General Public License for more details.
Packit 2035a7
 *
Packit 2035a7
 * You should have received a copy of the GNU General Public License
Packit 2035a7
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 2035a7
 */
Packit 2035a7
Packit 2035a7
#ifndef PATHMATCH_H
Packit 2035a7
#define PATHMATCH_H
Packit 2035a7
Packit 2035a7
#include "config.h"
Packit 2035a7
Packit 2035a7
#include <string>
Packit 2035a7
#include <vector>
Packit 2035a7
Packit 2035a7
/// @addtogroup CLI
Packit 2035a7
/// @{
Packit 2035a7
Packit 2035a7
/**
Packit 2035a7
 * @brief Simple path matching for ignoring paths in CLI.
Packit 2035a7
 */
Packit 2035a7
class CPPCHECKLIB PathMatch {
Packit 2035a7
public:
Packit 2035a7
Packit 2035a7
    /**
Packit 2035a7
     * The constructor.
Packit 2035a7
     * @param excludedPaths List of masks.
Packit 2035a7
     * @param caseSensitive Match the case of the characters when
Packit 2035a7
     *   matching paths?
Packit 2035a7
     */
Packit 2035a7
    explicit PathMatch(const std::vector<std::string> &excludedPaths, bool caseSensitive = true);
Packit 2035a7
Packit 2035a7
    /**
Packit 2035a7
     * @brief Match path against list of masks.
Packit 2035a7
     * @param path Path to match.
Packit 2035a7
     * @return true if any of the masks match the path, false otherwise.
Packit 2035a7
     */
Packit 2035a7
    bool match(const std::string &path) const;
Packit 2035a7
Packit 2035a7
protected:
Packit 2035a7
Packit 2035a7
    /**
Packit 2035a7
     * @brief Remove filename part from the path.
Packit 2035a7
     * @param path Path to edit.
Packit 2035a7
     * @return path without filename part.
Packit 2035a7
     */
Packit 2035a7
    static std::string removeFilename(const std::string &path);
Packit 2035a7
Packit 2035a7
private:
Packit 2035a7
    std::vector<std::string> _excludedPaths;
Packit 2035a7
    bool _caseSensitive;
Packit 2035a7
    std::vector<std::string> _workingDirectory;
Packit 2035a7
};
Packit 2035a7
Packit 2035a7
/// @}
Packit 2035a7
Packit 2035a7
#endif // PATHMATCH_H