| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: ExcludeList.h |
|---|
| 5 | // Purpose: General purpose exclusion list |
|---|
| 6 | // Created: 28/1/04 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef EXCLUDELIST__H |
|---|
| 11 | #define EXCLUDELIST__H |
|---|
| 12 | |
|---|
| 13 | #include <string> |
|---|
| 14 | #include <set> |
|---|
| 15 | #include <vector> |
|---|
| 16 | |
|---|
| 17 | // avoid including regex.h in lots of places |
|---|
| 18 | #ifndef EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED |
|---|
| 19 | typedef int regex_t; |
|---|
| 20 | #endif |
|---|
| 21 | |
|---|
| 22 | class Archive; |
|---|
| 23 | |
|---|
| 24 | // -------------------------------------------------------------------------- |
|---|
| 25 | // |
|---|
| 26 | // Class |
|---|
| 27 | // Name: ExcludeList |
|---|
| 28 | // Purpose: General purpose exclusion list |
|---|
| 29 | // Created: 28/1/04 |
|---|
| 30 | // |
|---|
| 31 | // -------------------------------------------------------------------------- |
|---|
| 32 | class ExcludeList |
|---|
| 33 | { |
|---|
| 34 | public: |
|---|
| 35 | ExcludeList(); |
|---|
| 36 | ~ExcludeList(); |
|---|
| 37 | |
|---|
| 38 | void Deserialize(Archive & rArchive); |
|---|
| 39 | void Serialize(Archive & rArchive) const; |
|---|
| 40 | |
|---|
| 41 | void AddDefiniteEntries(const std::string &rEntries); |
|---|
| 42 | void AddRegexEntries(const std::string &rEntries); |
|---|
| 43 | |
|---|
| 44 | // Add exceptions to the exclusions (takes ownership) |
|---|
| 45 | void SetAlwaysIncludeList(ExcludeList *pAlwaysInclude); |
|---|
| 46 | |
|---|
| 47 | // Test function |
|---|
| 48 | bool IsExcluded(const std::string &rTest) const; |
|---|
| 49 | |
|---|
| 50 | // Mainly for tests |
|---|
| 51 | unsigned int SizeOfDefiniteList() const {return mDefinite.size();} |
|---|
| 52 | unsigned int SizeOfRegexList() const |
|---|
| 53 | #ifdef HAVE_REGEX_SUPPORT |
|---|
| 54 | {return mRegex.size();} |
|---|
| 55 | #else |
|---|
| 56 | {return 0;} |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|
| 59 | private: |
|---|
| 60 | std::set<std::string> mDefinite; |
|---|
| 61 | #ifdef HAVE_REGEX_SUPPORT |
|---|
| 62 | std::vector<regex_t *> mRegex; |
|---|
| 63 | std::vector<std::string> mRegexStr; // save original regular expression string-based source for Serialize |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|
| 66 | #ifdef WIN32 |
|---|
| 67 | std::string ReplaceSlashesDefinite(const std::string& input) const; |
|---|
| 68 | std::string ReplaceSlashesRegex (const std::string& input) const; |
|---|
| 69 | #endif |
|---|
| 70 | |
|---|
| 71 | // For exceptions to the excludes |
|---|
| 72 | ExcludeList *mpAlwaysInclude; |
|---|
| 73 | }; |
|---|
| 74 | |
|---|
| 75 | #endif // EXCLUDELIST__H |
|---|
| 76 | |
|---|