source: box/trunk/lib/common/ExcludeList.h @ 1771

Revision 1771, 1.8 KB checked in by chris, 5 years ago (diff)

Work around the fact that we may have regex support without having
regex.h (e.g. from pcreposix.h/libpcreposix) and disabuse HAVE_REGEX_H,
define and use HAVE_REGEX_SUPPORT instead, thanks Gary!
(refs #3, merges [1677] [1678] [1679])

  • Property svn:eol-style set to native
Line 
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
22class Archive;
23
24// --------------------------------------------------------------------------
25//
26// Class
27//              Name:    ExcludeList
28//              Purpose: General purpose exclusion list
29//              Created: 28/1/04
30//
31// --------------------------------------------------------------------------
32class ExcludeList
33{
34public:
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
59private:
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
Note: See TracBrowser for help on using the repository browser.