Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

  1. //***************************************************************************
  2. //
  3. // (c) 2000 by Microsoft Corp. All Rights Reserved.
  4. //
  5. // like.h
  6. //
  7. // a-davcoo 28-Feb-00 Implements the SQL like operation.
  8. //
  9. //***************************************************************************
  10. #ifndef _LIKE_H_
  11. #define _LIKE_H_
  12. #include <string.h>
  13. // The CLike class implements the SQL "like" operation. To compare test strings
  14. // to an expression, construct an instance of the CLike class using the expression
  15. // and an optional escape character. Then use the Match() method on that instance
  16. // to test each string. Note, this class makes it's own copy of the expression
  17. // used to construct it. This implementation supports the '%' and '_' wildard
  18. // characters as well as the [] and [^] constructs for matching sets of characters
  19. // and ranges of characters.
  20. class CLike
  21. {
  22. public:
  23. CLike (LPCWSTR expression, WCHAR escape='\0');
  24. ~CLike (void);
  25. bool Match (LPCWSTR string);
  26. protected:
  27. LPWSTR m_expression;
  28. WCHAR m_escape;
  29. // Recursive function and helpers for performing like operation.
  30. bool DoLike (LPCWSTR pattern, LPCWSTR string, WCHAR escape);
  31. bool MatchSet (LPCWSTR pattern, LPCWSTR string, int &skip);
  32. };
  33. #endif // _LIKE_H_
  34.