File indexing completed on 2024-04-21 05:42:28

0001 // clang-format off
0002 /**
0003  * KDiff3 - Text Diff And Merge Tool
0004  *
0005  * SPDX-FileCopyrightText: 2021 Michael Reeves <reeves.87@gmail.com>
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  *
0008  */
0009 // clang-format on
0010 
0011 #ifndef CVSIGNORELIST_H
0012 #define CVSIGNORELIST_H
0013 
0014 //#include "fileaccess.h"
0015 
0016 #include "DirectoryList.h"
0017 #include "IgnoreList.h"
0018 
0019 #include <QString>
0020 #include <QStringList>
0021 
0022 #include <map>
0023 
0024 struct CvsIgnorePatterns
0025 {
0026     QStringList m_exactPatterns;
0027     QStringList m_startPatterns;
0028     QStringList m_endPatterns;
0029     QStringList m_generalPatterns;
0030 };
0031 
0032 class CvsIgnoreList : public IgnoreList
0033 {
0034 public:
0035     CvsIgnoreList();
0036     ~CvsIgnoreList() override;
0037     void enterDir(const QString& dir, const DirectoryList& directoryList) override;
0038     [[nodiscard]] bool matches(const QString& dir, const QString& text, bool bCaseSensitive) const override;
0039 
0040 protected:
0041     bool ignoreExists(const DirectoryList& pDirList);
0042 
0043     void addEntriesFromString(const QString& dir, const QString& str);
0044     void addEntriesFromFile(const QString& dir, const QString& name);
0045     void addEntry(const QString& dir, const QString& pattern);
0046 
0047     std::map<QString, CvsIgnorePatterns> m_ignorePatterns;
0048 private:
0049     friend class CvsIgnoreListTest;
0050     /*
0051         The name of the users global ignore can be changed separately in some cases in the future
0052         kdiff will handle this through a user settings.
0053         For now just return the same thing as gerIngoreName. That works
0054     */
0055     [[nodiscard]] inline virtual const QString getGlobalIgnoreName() const { return getIgnoreName(); }
0056     [[nodiscard]] inline const char* getVarName() const { return "CVSIGNORE"; }
0057     [[nodiscard]] inline const QString getIgnoreName() const { return QStringLiteral(".cvsignore"); }
0058 };
0059 
0060 #endif /* CVSIGNORELIST_H */