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.

76 lines
2.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation.
  4. //
  5. // File: tokstr.hxx
  6. //
  7. // Contents: Used to break down a string into its tokens
  8. //
  9. // History: 96/Jan/3 DwightKr Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #pragma once
  13. #define WORD_STR L"{}!&|~*@#()[],=<> \t\n\"" // chars that cannot appear in a word
  14. //+---------------------------------------------------------------------------
  15. //
  16. // Class: CTokenizeString
  17. //
  18. // Purpose: Breaks a string down into its tokens
  19. //
  20. // History: 96/Jan/23 DwightKr Created
  21. //
  22. //----------------------------------------------------------------------------
  23. class CTokenizeString
  24. {
  25. public:
  26. CTokenizeString( WCHAR const * wcsString );
  27. void Accept();
  28. WCHAR * AcqWord();
  29. WCHAR * AcqPhrase();
  30. void AcqVector( PROPVARIANT & variant );
  31. void AcceptQuote()
  32. {
  33. Win4Assert( L'"' == *_wcsCurrentToken );
  34. _wcsCurrentToken++;
  35. }
  36. BOOL GetNumber( unsigned _int64 & number );
  37. BOOL GetNumber( _int64 & number );
  38. BOOL GetNumber( double & number );
  39. BOOL GetGUID( GUID & guid );
  40. Token LookAhead() const { return _token; }
  41. private:
  42. void EatWhiteSpace()
  43. {
  44. while ( iswspace(*_wcsNextToken) != 0 )
  45. {
  46. _wcsNextToken++;
  47. }
  48. }
  49. BOOL IsEndOfTextToken()
  50. {
  51. if ( (_token == TEXT_TOKEN) && (_wcsCurrentToken < _wcsNextToken) )
  52. {
  53. return FALSE;
  54. }
  55. return TRUE;
  56. }
  57. WCHAR const * _wcsString; // The string to tokenize
  58. WCHAR const * _wcsCurrentToken; // A ptr to the current token
  59. WCHAR const * _wcsNextToken; // A ptr to the next token
  60. Token _token; // type of the current token
  61. };