00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef GLOBPATTERN_H
00016 #define GLOBPATTERN_H
00017
00018 #include "dtoolbase.h"
00019 #include "filename.h"
00020 #include "vector_string.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class EXPCL_DTOOL GlobPattern {
00038 PUBLISHED:
00039 INLINE GlobPattern(const string &pattern = string());
00040 INLINE GlobPattern(const GlobPattern ©);
00041 INLINE void operator = (const GlobPattern ©);
00042
00043 INLINE bool operator == (const GlobPattern &other) const;
00044 INLINE bool operator != (const GlobPattern &other) const;
00045 INLINE bool operator < (const GlobPattern &other) const;
00046
00047 INLINE void set_pattern(const string &pattern);
00048 INLINE const string &get_pattern() const;
00049
00050 INLINE void set_case_sensitive(bool case_sensitive);
00051 INLINE bool get_case_sensitive() const;
00052
00053 INLINE void set_nomatch_chars(const string &nomatch_chars);
00054 INLINE const string &get_nomatch_chars() const;
00055
00056 INLINE bool matches(const string &candidate) const;
00057
00058 INLINE void output(ostream &out) const;
00059
00060 bool has_glob_characters() const;
00061 string get_const_prefix() const;
00062 int match_files(vector_string &results, const Filename &cwd = Filename()) const;
00063 #ifdef HAVE_PYTHON
00064 PyObject *match_files(const Filename &cwd = Filename()) const;
00065 #endif
00066
00067 private:
00068 bool matches_substr(string::const_iterator pi,
00069 string::const_iterator pend,
00070 string::const_iterator ci,
00071 string::const_iterator cend) const;
00072
00073 bool matches_set(string::const_iterator &pi,
00074 string::const_iterator pend,
00075 char ch) const;
00076
00077 int r_match_files(const Filename &prefix, const string &suffix,
00078 vector_string &results, const Filename &cwd);
00079
00080 string _pattern;
00081 bool _case_sensitive;
00082 string _nomatch_chars;
00083 };
00084
00085 INLINE ostream &operator << (ostream &out, const GlobPattern &glob) {
00086 glob.output(out);
00087 return out;
00088 }
00089
00090
00091 #include "globPattern.I"
00092
00093 #endif