|
| 1 | +/* |
| 2 | + * Cppcheck - A tool for static C/C++ code analysis |
| 3 | + * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | + |
| 19 | +#ifndef PATHMATCH_H |
| 20 | +#define PATHMATCH_H |
| 21 | + |
| 22 | +#include <string> |
| 23 | +#include <vector> |
| 24 | + |
| 25 | +/// @addtogroup CLI |
| 26 | +/// @{ |
| 27 | + |
| 28 | +/** |
| 29 | + * @brief Simple path matching for ignoring paths in CLI. |
| 30 | + */ |
| 31 | +class PathMatch |
| 32 | +{ |
| 33 | +public: |
| 34 | + |
| 35 | + /** |
| 36 | + * The constructor. |
| 37 | + * @param masks List of masks. |
| 38 | + */ |
| 39 | + PathMatch(const std::vector<std::string> &masks); |
| 40 | + |
| 41 | + /** |
| 42 | + * @brief Match path against list of masks. |
| 43 | + * @param path Path to match. |
| 44 | + * @return true if any of the masks match the path, false otherwise. |
| 45 | + */ |
| 46 | + bool Match(const std::string &path); |
| 47 | + |
| 48 | +protected: |
| 49 | + |
| 50 | + /** |
| 51 | + * @brief Remove filename part from the path. |
| 52 | + * @param path Path to edit. |
| 53 | + * @return path without filename part. |
| 54 | + */ |
| 55 | + std::string RemoveFilename(const std::string &path); |
| 56 | + |
| 57 | +private: |
| 58 | + std::vector<std::string> _masks; |
| 59 | +}; |
| 60 | + |
| 61 | +/// @} |
| 62 | + |
| 63 | +#endif // PATHMATCH_H |
0 commit comments