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.

115 lines
3.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation.
  4. //
  5. // File: express.hxx
  6. //
  7. // Contents: Used to parse and evaluate expressions
  8. //
  9. // History: 96/Jan/3 DwightKr Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #pragma once
  13. //+---------------------------------------------------------------------------
  14. //
  15. // Class: CHTXIfExpression
  16. //
  17. // Purpose: Parses an 'if' expression
  18. //
  19. // History: 96/Jan/23 DwightKr Created
  20. //
  21. //----------------------------------------------------------------------------
  22. class CHTXIfExpression
  23. {
  24. public:
  25. CHTXIfExpression( CTokenizeString & scanner,
  26. CVariableSet & variableSet,
  27. COutputFormat & outputFormat );
  28. BOOL Evaluate();
  29. private:
  30. CTokenizeString & _scanner;
  31. CVariableSet & _variableSet;
  32. COutputFormat & _outputFormat;
  33. };
  34. //+---------------------------------------------------------------------------
  35. //
  36. // Class: CHTXIfExpressionValue
  37. //
  38. // Purpose: Parses the value portion of an 'if' expression
  39. //
  40. // History: 96/Jan/23 DwightKr Created
  41. //
  42. //----------------------------------------------------------------------------
  43. class CHTXIfExpressionValue : INHERIT_UNWIND
  44. {
  45. INLINE_UNWIND(CHTXIfExpressionValue);
  46. public:
  47. CHTXIfExpressionValue( CTokenizeString & scanner,
  48. CVariableSet & variableSet,
  49. COutputFormat & outputFormat );
  50. ~CHTXIfExpressionValue();
  51. void ParseValue();
  52. VARTYPE GetType() const { return _propVariant.vt; }
  53. WCHAR * GetStringValue();
  54. PROPVARIANT * GetValue() { return &_propVariant; }
  55. BOOL IsConstant() const { return _fIsConstant; }
  56. BOOL GetVectorValueInteger( unsigned i, _int64 & value );
  57. BOOL GetVectorValueUnsignedInteger( unsigned i, unsigned __int64 & value );
  58. BOOL GetVectorValueDouble( unsigned i, double & dblValue );
  59. BOOL GetVectorValueStr( unsigned i, XCoMem<CHAR> & pszString);
  60. BOOL GetVectorValueBStr( unsigned i, BSTR & bwszString);
  61. BOOL GetVectorValueWStr( unsigned i, XCoMem<WCHAR> & wszString);
  62. private:
  63. PROPVARIANT _propVariant; // The value
  64. WCHAR * _wcsStringValue; // String value of expression
  65. CTokenizeString & _scanner; // Scans the buffer
  66. CVariableSet & _variableSet; // List of replaceable parameters
  67. COutputFormat & _outputFormat; // Format for numbers & dates
  68. GUID _guid; // Guid for this propVariant
  69. BOOL _fOwnVector; // vector in _propVariant owned?
  70. BOOL _fIsConstant; // Is this a constant or a variable?
  71. };
  72. //+---------------------------------------------------------------------------
  73. //
  74. // Class: CHTXIfExpressionOperator
  75. //
  76. // Purpose: Parses the operator portion of an 'if' expression
  77. //
  78. // History: 96/Jan/23 DwightKr Created
  79. //
  80. //----------------------------------------------------------------------------
  81. class CHTXIfExpressionOperator
  82. {
  83. public:
  84. CHTXIfExpressionOperator( CTokenizeString & scanner );
  85. void ParseOperator();
  86. BOOL Evaluate( CHTXIfExpressionValue & lhvalue,
  87. CHTXIfExpressionValue & rhvalue );
  88. BOOL Evaluate( CHTXIfExpressionValue & lhvalue );
  89. ULONG Operator() { return _operator; }
  90. private:
  91. ULONG _operator; // Current operator
  92. CTokenizeString & _scanner; // Scans the buffer
  93. };