00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef SHWILD_INCL_SRC_HPP_MATCHES
00042 #define SHWILD_INCL_SRC_HPP_MATCHES
00043
00044
00045
00046
00047
00048 #ifndef SHWILD_DOCUMENTATION_SKIP_SECTION
00049 # define SHWILD_VER_HPP_MATCHES_MAJOR 1
00050 # define SHWILD_VER_HPP_MATCHES_MINOR 1
00051 # define SHWILD_VER_HPP_MATCHES_REVISION 5
00052 # define SHWILD_VER_HPP_MATCHES_EDIT 10
00053 #endif
00054
00055
00056
00057
00058
00059 #include <shwild/shwild.h>
00060 #include "shwild_string.hpp"
00061
00062 #include <stlsoft/stlsoft.h>
00063 #if !defined(_STLSOFT_VER) || \
00064 _STLSOFT_VER < 0x01091eff
00065 # error Requires STLSoft 1.9.30, or later. (www.stlsoft.org/downloads.html)
00066 #endif
00067
00068
00069
00070
00071
00072 #if !defined(SHWILD_NO_NAMESPACE)
00073 namespace shwild
00074 {
00075 namespace impl
00076 {
00077 #endif
00078
00079
00080
00081
00082
00083 char *STLSOFT_CDECL shwild_strchr(const char *, int);
00084 char *STLSOFT_CDECL shwild_strichr(const char *, int);
00085 char *STLSOFT_CDECL shwild_strstr(const char *, const char *);
00086 char *STLSOFT_CDECL shwild_stristr(const char *, const char *);
00087 int STLSOFT_CDECL shwild_strncmp(const char *, const char *, size_t);
00088 int STLSOFT_CDECL shwild_strnicmp(const char *, const char *, size_t);
00089
00090
00091
00092
00093
00095 class Match
00096 {
00097 public:
00098 virtual ~Match() = 0;
00099
00101 virtual void setNext(Match *next) = 0;
00102
00103 public:
00108 virtual bool match(char const *first, char const *last) const = 0;
00114 virtual char const *nextSub(char const *first, char const *last, size_t *nextLen) const = 0;
00115 };
00116
00118 class MatchWild
00119 : public Match
00120 {
00121 public:
00122 typedef MatchWild class_type;
00123
00124 public:
00125 explicit MatchWild(unsigned flags);
00126 virtual ~MatchWild();
00127
00128 virtual void setNext(Match *next);
00129 public:
00130 virtual bool match(char const *first, char const *last) const;
00131 virtual char const *nextSub(char const *first, char const *last, size_t *nextLen) const;
00132 private:
00133 Match *m_next;
00134 private:
00135 class_type &operator =(class_type const &);
00136 };
00137
00139 class MatchWild1
00140 : public Match
00141 {
00142 public:
00143 typedef MatchWild1 class_type;
00144
00145 public:
00146 explicit MatchWild1(unsigned flags);
00147 virtual ~MatchWild1();
00148
00149 virtual void setNext(Match *next);
00150 public:
00151 virtual bool match(char const *first, char const *last) const;
00152 virtual char const *nextSub(char const *first, char const *last, size_t *nextLen) const;
00153 private:
00154 Match *m_next;
00155 private:
00156 class_type &operator =(class_type const &);
00157 };
00158
00160 class MatchRange
00161 : public Match
00162 {
00163 public:
00164 typedef MatchRange class_type;
00165
00166 public:
00167 MatchRange(size_t len, char const *chars, unsigned flags);
00168 virtual ~MatchRange();
00169
00170 virtual void setNext(Match *next);
00171 public:
00172 virtual bool match(char const *first, char const *last) const;
00173 virtual char const *nextSub(char const *first, char const *last, size_t *nextLen) const;
00174 protected:
00175 bool matchContents(char ch) const;
00176 protected:
00177 Match *m_next;
00178 const shwild_string_t m_chars;
00179 const unsigned m_flags;
00180 private:
00181 class_type &operator =(class_type const &);
00182 };
00183
00185 class MatchNotRange
00186 : public MatchRange
00187 {
00188 public:
00189 typedef MatchRange parent_class_type;
00190 typedef MatchNotRange class_type;
00191
00192 public:
00193 MatchNotRange(size_t len, char const *chars, unsigned flags);
00194 virtual ~MatchNotRange();
00195
00196 public:
00197 virtual bool match(char const *first, char const *last) const;
00198
00199 private:
00200 class_type &operator =(class_type const &);
00201 };
00202
00204 class MatchEnd
00205 : public Match
00206 {
00207 public:
00208 typedef MatchEnd class_type;
00209
00210 public:
00211 explicit MatchEnd(unsigned flags);
00212 virtual ~MatchEnd();
00213
00214 virtual void setNext(Match *next);
00215 public:
00216 virtual bool match(char const *first, char const *last) const;
00217 virtual char const *nextSub(char const *first, char const *last, size_t *nextLen) const;
00218 private:
00219 Match *m_next;
00220 private:
00221 class_type &operator =(class_type const &);
00222 };
00223
00225 class MatchLiteral
00226 : public Match
00227 {
00228 public:
00229 typedef MatchLiteral class_type;
00230
00231 public:
00232 MatchLiteral(size_t cchContents, char const *contents, unsigned flags);
00233 virtual ~MatchLiteral();
00234
00235 virtual void setNext(Match *next);
00236 public:
00237 virtual bool match(char const *first, char const *last) const;
00238 virtual char const *nextSub(char const *first, char const *last, size_t *nextLen) const;
00239 private:
00240 Match *m_next;
00241 const shwild_string_t m_contents;
00242 const unsigned m_flags;
00243 private:
00244 class_type &operator =(class_type const &);
00245 };
00246
00247
00248
00249
00250
00251 #if !defined(SHWILD_NO_NAMESPACE)
00252 }
00253
00254 }
00255 #endif
00256
00257
00258
00259 #endif
00260
00261