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.

132 lines
3.3 KiB

  1. //
  2. // varcomp.h
  3. //
  4. #pragma once
  5. #define PRLT ( 0 )
  6. #define PRLE ( 1 )
  7. #define PRGT ( 2 )
  8. #define PRGE ( 3 )
  9. #define PREQ ( 4 )
  10. #define PRNE ( 5 )
  11. #define PRRE ( 6 )
  12. #define PRAllBits ( 7 )
  13. #define PRSomeBits ( 8 )
  14. #define PRAll ( 0x100 )
  15. #define PRAny ( 0x200 )
  16. typedef BOOL (* FRel)(PROPVARIANT const &, PROPVARIANT const &);
  17. typedef BOOL (* FPRel)(BYTE const *, BYTE const *);
  18. typedef int (* FCmp)(PROPVARIANT const &, PROPVARIANT const &);
  19. typedef int (* FPCmp)(BYTE const *, BYTE const *);
  20. class CComparators
  21. {
  22. public:
  23. static FCmp GetComparator( VARENUM vt );
  24. static FRel GetRelop( VARENUM vt, ULONG rel );
  25. static FPCmp GetPointerComparator( PROPVARIANT const & v1,
  26. PROPVARIANT const & v2 );
  27. static FPRel GetPointerRelop( PROPVARIANT const & v1,
  28. PROPVARIANT const & v2,
  29. ULONG rel );
  30. private:
  31. //
  32. // There is one SComparators structure for each base variant type.
  33. // They are accessed off aVariantComarators by VT_xxx. Within
  34. // the SComparators structure relops are accessed by PRxxx.
  35. //
  36. struct SComparators
  37. {
  38. FCmp comparator;
  39. FPCmp pointercomparator;
  40. FRel relops[9];
  41. FPRel pointerrelops[9];
  42. };
  43. static ULONG const _iStart;
  44. static SComparators const _aVariantComparators[];
  45. static ULONG const _cVariantComparators;
  46. static ULONG const _iStart2;
  47. static SComparators const _aVariantComparators2[];
  48. static ULONG const _cVariantComparators2;
  49. static FRel const _aVectorComparators[];
  50. static ULONG const _cVectorComparators;
  51. static FRel const _aVectorComparatorsAll[];
  52. static ULONG const _cVectorComparatorsAll;
  53. static FRel const _aVectorComparatorsAny[];
  54. static ULONG const _cVectorComparatorsAny;
  55. };
  56. extern CComparators VariantCompare;
  57. inline BOOL isVector(VARTYPE vt)
  58. {
  59. return 0 != ( vt & VT_VECTOR );
  60. }
  61. inline BOOL isVector(PROPVARIANT const & v)
  62. {
  63. return isVector( v.vt );
  64. }
  65. inline BOOL isArray(VARTYPE vt)
  66. {
  67. return 0 != ( vt & VT_ARRAY );
  68. }
  69. inline BOOL isArray(PROPVARIANT const & v)
  70. {
  71. return isArray( v.vt );
  72. }
  73. inline BOOL isVectorOrArray(VARTYPE vt)
  74. {
  75. return 0 != ( vt & (VT_ARRAY|VT_VECTOR) );
  76. }
  77. inline BOOL isVectorOrArray(PROPVARIANT const & v)
  78. {
  79. return isVectorOrArray( v.vt );
  80. }
  81. inline BOOL isVectorRelop(ULONG relop)
  82. {
  83. return relop & (PRAny | PRAll);
  84. }
  85. inline BOOL isRelopAny(ULONG relop)
  86. {
  87. return relop & PRAny;
  88. }
  89. inline BOOL isRelopAll(ULONG relop)
  90. {
  91. return relop & PRAll;
  92. }
  93. inline VARENUM getBaseType(PROPVARIANT const &v)
  94. {
  95. return (VARENUM) (VT_TYPEMASK & v.vt);
  96. }
  97. inline ULONG getBaseRelop(ULONG relop)
  98. {
  99. return relop & ~(PRAny | PRAll);
  100. }
  101. BOOL VT_VARIANT_LT( PROPVARIANT const & v1, PROPVARIANT const & v2 );
  102. BOOL VT_VARIANT_LE( PROPVARIANT const & v1, PROPVARIANT const & v2 );
  103. BOOL VT_VARIANT_GE( PROPVARIANT const & v1, PROPVARIANT const & v2 );
  104. BOOL VT_VARIANT_GT( PROPVARIANT const & v1, PROPVARIANT const & v2 );
  105. BOOL VT_VARIANT_EQ( PROPVARIANT const & v1, PROPVARIANT const & v2 );
  106. BOOL VT_VARIANT_NE( PROPVARIANT const & v1, PROPVARIANT const & v2 );