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.

90 lines
2.1 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // exprbuilder.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class ExpressionBuilder.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 08/14/1998 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _EXPRBUILDER_H_
  19. #define _EXPRBUILDER_H_
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif
  23. #include <nocopy.h>
  24. #include <varvec.h>
  25. #include <vector>
  26. #include <nap.h>
  27. #include <factory.h>
  28. ///////////////////////////////////////////////////////////////////////////////
  29. //
  30. // CLASS
  31. //
  32. // ExpressionBuilder
  33. //
  34. // DESCRIPTION
  35. //
  36. // Assembles a vector of expression tokens.
  37. //
  38. ///////////////////////////////////////////////////////////////////////////////
  39. class ExpressionBuilder
  40. : public NonCopyable
  41. {
  42. public:
  43. // Add a condition object to the expression.
  44. void addCondition(PCWSTR progID)
  45. {
  46. IConditionPtr condition;
  47. theFactoryCache.createInstance(progID,
  48. NULL,
  49. __uuidof(ICondition),
  50. (PVOID*)&condition);
  51. expression.push_back(condition.GetInterfacePtr());
  52. }
  53. // Set the condition text for the condition object just added.
  54. void addConditionText(PCWSTR text)
  55. {
  56. if (expression.empty()) { _com_issue_error(E_INVALIDARG); }
  57. IConditionTextPtr cond(expression.back());
  58. _com_util::CheckError(cond->put_ConditionText(_bstr_t(text)));
  59. }
  60. // Add a logical operator.
  61. void addToken(IAS_LOGICAL_TOKEN eToken)
  62. {
  63. expression.push_back((LONG)eToken);
  64. }
  65. // Detach the fully assembled expression.
  66. void detach(VARIANT* pVal)
  67. {
  68. CVariantVector<VARIANT> vec(pVal, expression.size());
  69. for (size_t i = 0; i < expression.size(); ++i)
  70. {
  71. vec[i] = expression[i].Detach();
  72. }
  73. expression.clear();
  74. }
  75. protected:
  76. std::vector<_variant_t> expression;
  77. };
  78. #endif // _EXPRBUILDER_H_