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.

74 lines
1.9 KiB

  1. /*++
  2. Copyright (C) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. Converter.h
  5. Abstract:
  6. interface for the CConverter class.
  7. History:
  8. 9/15/98 Created
  9. 9/22/98 Removed Convert(ULONG); Added Convert(CVar) & Convert(CVarVector)
  10. --*/
  11. #ifndef __CONVERTER_H
  12. #define __CONVERTER_H
  13. #define ERR_NOERROR 0x00000000
  14. #define ERR_UNKNOWN 0x00000001
  15. #define ERR_INVALID_SIGNED_VALUE 0x00000002
  16. #define ERR_INVALID_TOKEN 0x00000003
  17. #define ERR_OUT_OF_RANGE 0x00000004
  18. #define ERR_NULL_CIMTYPE 0x00000005
  19. #define ERR_INVALID_INPUT_STRING 0x00000006
  20. #define ERR_NULL_TOKEN 0x00000007
  21. #define ERR_UNKNOWN_BASE 0x00000008
  22. #define ERR_UNMATCHED_BRACE 0x00000009
  23. #define BASE_DEC 10
  24. #define BASE_HEX 16
  25. typedef long CIMType;
  26. class CConverter
  27. {
  28. CIMType m_ct; // CIM type
  29. char* m_szString; // Input string
  30. // char* m_szCurrent; // Current token pointer
  31. CConverter(const char* szString, CIMType ct);
  32. virtual ~CConverter();
  33. UINT SetBoundary(BOOL bNeg, ULONG *uMaxSize);
  34. BOOL Done(char *ch);
  35. BOOL Separator();
  36. BOOL IsValidDec(char ch);
  37. BOOL IsValidHex(char ch);
  38. char PeekToken(char *ch);
  39. BOOL GetToken(char **ch);
  40. void ReplaceToken(char **ch);
  41. UINT Token_Sequence(CVarVector *pVarVec);
  42. UINT Token_Sequence(CVar *pVar);
  43. UINT Token_Number(char **ch, CVar *pVar);
  44. UINT Token_Digit(char **ch, ULONG *ulRes);
  45. UINT Token_Separator(char **ch);
  46. UINT Token_DecField(char **ch, BOOL bNeg, ULONG *pVal);
  47. UINT Token_HexField(char **ch, BOOL bNeg, ULONG *pVal);
  48. UINT Token_DecDigit(char **ch, ULONG *pVal);
  49. UINT Token_HexDigit(char **ch, ULONG *pVal);
  50. UINT Token_Comment(char **ch);
  51. UINT Token_WhiteSpace(char **ch);
  52. public:
  53. static UINT Convert(const char* szString, CIMType ct, ULONG *ulRes);
  54. static UINT Convert(const char* szString, CIMType ct, CVar *pVar);
  55. static UINT Convert(const char* szString, CIMType ct, CVarVector *pVarVec);
  56. };
  57. #endif //__CONVERTER_H