Source code of Windows XP (NT5)
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.

53 lines
2.0 KiB

  1. //---------------------------------------------------------------------------
  2. // Scanner.h - supports parsing lines & text files
  3. //---------------------------------------------------------------------------
  4. #pragma once
  5. //---------------------------------------------------------------------------
  6. #define ISNUMSTART(p) ((isdigit(*p)) || (*p == '-') || (*p == '+'))
  7. #define IS_NAME_CHAR(p) ((isalnum(*p)) || (*p == '_') || (*p == '-'))
  8. //---------------------------------------------------------------------------
  9. #define MAX_ID_LEN _MAX_PATH
  10. #define MAX_INPUT_LINE 255
  11. //---------------------------------------------------------------------------
  12. class CScanner
  13. {
  14. public:
  15. CScanner(LPCWSTR pszTextToScan=NULL);
  16. ~CScanner();
  17. HRESULT AttachFile(LPCWSTR pszFileName);
  18. BOOL AttachLine(LPCWSTR pszLine);
  19. BOOL AttachMultiLineBuffer(LPCWSTR pszBuffer, LPCWSTR pszFileName);
  20. BOOL GetId(LPWSTR pszIdBuff, DWORD dwMaxLen=MAX_ID_LEN);
  21. BOOL GetIdPair(LPWSTR pszIdBuff, LPWSTR pszValueBuff, DWORD dwMaxLen=MAX_ID_LEN);
  22. BOOL GetKeyword(LPCWSTR pszKeyword);
  23. BOOL GetFileName(LPWSTR pszBuff, DWORD dwMaxLen);
  24. BOOL GetNumber(int *piVal);
  25. BOOL IsNameChar(BOOL fOkToSkip=TRUE);
  26. BOOL IsFileNameChar(BOOL fOkToSkip);
  27. BOOL IsNumStart();
  28. BOOL GetChar(const WCHAR val);
  29. BOOL EndOfLine();
  30. BOOL EndOfFile();
  31. BOOL ForceNextLine();
  32. BOOL SkipSpaces(); // called by CScanner before all checking routines
  33. BOOL ReadNextLine();
  34. void UseSymbol(LPCWSTR pszSymbol);
  35. protected:
  36. void ResetAll(BOOL fPossiblyAllocated);
  37. public:
  38. //---- data ----
  39. const WCHAR *_p; // accessible for special comparisons
  40. const WCHAR *_pSymbol; // if not null, use this instead of _p
  41. WCHAR _szLineBuff[MAX_INPUT_LINE+1];
  42. WCHAR _szFileName[_MAX_PATH+1];
  43. LPCWSTR _pszMultiLineBuffer;
  44. LPWSTR _pszFileText;
  45. int _iLineNum;
  46. BOOL _fEndOfFile;
  47. BOOL _fBlankSoFar;
  48. BOOL _fUnicodeInput;
  49. };
  50. //---------------------------------------------------------------------------