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.

50 lines
1.6 KiB

  1. //***************************************************************************
  2. //
  3. // (c) 2000-2001 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. //
  14. // The CLike class implements the SQL "like" operation. To compare test
  15. // strings to an expression, construct an instance of the CLike class using
  16. // the expression and an optional escape character. Then use the Match()
  17. // method on that instance to test each string. Note, this class makes it's
  18. // own copy of the expression used to construct it. This implementation
  19. // supports the '%' and '_' wildard characters as well as the [] and [^]
  20. // constructs for matching sets of characters and ranges of characters.
  21. //
  22. class POLARITY CLike
  23. {
  24. public:
  25. CLike() : m_expression(NULL) {}
  26. CLike( LPCWSTR expression, WCHAR escape='\0' );
  27. CLike( const CLike& rOther ) : m_expression(NULL) { *this = rOther; }
  28. CLike& operator= ( const CLike& rOther );
  29. ~CLike();
  30. bool Match (LPCWSTR string);
  31. LPCWSTR GetExpression() { return m_expression; }
  32. void SetExpression( LPCWSTR string, WCHAR escape='\0' );
  33. protected:
  34. LPWSTR m_expression;
  35. WCHAR m_escape;
  36. // Recursive function and helpers for performing like operation.
  37. bool DoLike (LPCWSTR pattern, LPCWSTR string, WCHAR escape);
  38. bool MatchSet (LPCWSTR pattern, LPCWSTR string, int &skip);
  39. };
  40. #endif // _LIKE_H_