Wildcard.h
Go to the documentation of this file.
1 
2 // This source file is part of the ZipArchive Library Open Source distribution
3 // and is Copyrighted 2000 - 2022 by Artpol Software - Tadeusz Dracz
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // For the licensing details refer to the License.txt file.
11 //
12 // Web Site: https://www.artpol-software.com
14 
15 /*
16  This class is based on code by J. Kercheval, created 01/05/1991
17  and available as a public domain at http://www.snippets.org.
18 */
19 
26 #if !defined(ZIPARCHIVE_WILDCARD_DOT_H)
27 #define ZIPARCHIVE_WILDCARD_DOT_H
28 
29 #if _MSC_VER > 1000
30  #pragma once
31  #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
32  #pragma warning( push )
33  #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
34  #endif
35 #endif
36 
37 #include "ZipString.h"
38 
39 namespace ZipArchiveLib
40 {
47  class ZIP_API CWildcard
48  {
49  public:
50 
51  enum Match
52  {
59  matchPattern
60  };
61 
62  enum Pattern
63  {
64  patternEmpty = -4,
69  };
70 
71 
89  bool IsMatch(LPCTSTR lpszText, int* iRetCode = NULL);
90 
101  static bool IsPattern(LPCTSTR lpszPattern);
102 
116  static bool IsPatternValid(LPCTSTR lpszPattern, int* iErrorType = NULL);
117 
135  static int Match(LPCTSTR lpszPattern, LPCTSTR lpszText);
136 
141  {
142  m_bCaseSensitive = false;
143  }
144 
157 #pragma warning(suppress: 26495)
158  CWildcard(LPCTSTR lpszPattern, bool bCaseSensitive)
159  {
160  SetPattern(lpszPattern, bCaseSensitive);
161  }
162 
163  virtual ~CWildcard(){}
164 
177  void SetPattern(LPCTSTR lpszPattern, bool bCaseSensitive)
178  {
179  m_szPattern = lpszPattern;
180  m_bCaseSensitive = bCaseSensitive;
181  if (!bCaseSensitive)
182  m_szPattern.MakeLower();
183  }
184  operator LPCTSTR()
185  {
186  return (LPCTSTR)m_szPattern;
187  }
188  private:
189  bool m_bCaseSensitive;
190  static int MatchAfterStar(LPCTSTR p , LPCTSTR t);
191  CZipString m_szPattern;
192  };
193 }
194 
195 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
196  #pragma warning (pop)
197 #endif
198 
199 #endif

The ZipArchive Library Copyright © 2000 - 2022 Artpol Software - Tadeusz Dracz. Generated at Sat Dec 17 2022 19:57:03.