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.

146 lines
3.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // propcmd.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file defines commands for manipulating the Objects table.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/20/1998 Original version.
  16. // 04/03/1998 Increase property value length from 64 to 4096.
  17. // Bind integers as DBTYPE_I4.
  18. // Add PARAMETERS clause to all commands.
  19. // 02/15/1999 Make commands MT safe.
  20. //
  21. ///////////////////////////////////////////////////////////////////////////////
  22. #ifndef _PROPCMD_H_
  23. #define _PROPCMD_H_
  24. #include <iasdefs.h>
  25. #include <cmdbase.h>
  26. #include <propbag.h>
  27. #include <rowset.h>
  28. //////////
  29. // Column widths including null-terminator (i.e., Jet column size + 1).
  30. //////////
  31. const size_t PROPERTY_NAME_LENGTH = 256;
  32. //////////
  33. // Command to erase the contents of a property bag.
  34. //////////
  35. class EraseBag : public CommandBase
  36. {
  37. public:
  38. void execute(ULONG bagKey)
  39. {
  40. _serialize
  41. bag = bagKey;
  42. CommandBase::execute();
  43. }
  44. PCWSTR getCommandText() const throw ()
  45. {
  46. return L"PARAMETERS X LONG;"
  47. L"DELETE FROM Properties WHERE Bag = X;";
  48. }
  49. protected:
  50. ULONG bag;
  51. BEGIN_BIND_MAP(EraseBag, ParamIO, DBACCESSOR_PARAMETERDATA)
  52. BIND_COLUMN(bag, 1, DBTYPE_I4),
  53. END_BIND_MAP()
  54. };
  55. //////////
  56. // Command to retrieve a property bag.
  57. //////////
  58. class GetBag : public CommandBase
  59. {
  60. public:
  61. ~GetBag()
  62. {
  63. finalize();
  64. }
  65. void execute(ULONG bagKey, PropertyBag& output);
  66. PCWSTR getCommandText() const throw ()
  67. {
  68. return L"PARAMETERS X LONG;"
  69. L"SELECT Name, Type, StrVal FROM Properties WHERE Bag = X;";
  70. }
  71. void initialize(IUnknown* session)
  72. {
  73. CommandBase::initialize(session);
  74. readAccess = createReadAccessor(command);
  75. }
  76. void finalize() throw ()
  77. {
  78. releaseAccessor(readAccess);
  79. CommandBase::finalize();
  80. }
  81. protected:
  82. ULONG bag;
  83. WCHAR name[PROPERTY_NAME_LENGTH];
  84. ULONG type;
  85. WCHAR value[PROPERTY_VALUE_LENGTH];
  86. HACCESSOR readAccess;
  87. BEGIN_BIND_MAP(GetBag, ParamIO, DBACCESSOR_PARAMETERDATA)
  88. BIND_COLUMN(bag, 1, DBTYPE_I4),
  89. END_BIND_MAP()
  90. BEGIN_BIND_MAP(GetBag, ReadAccessor, DBACCESSOR_ROWDATA)
  91. BIND_COLUMN(name, 1, DBTYPE_WSTR),
  92. BIND_COLUMN(type, 2, DBTYPE_I4),
  93. BIND_COLUMN(value, 3, DBTYPE_WSTR),
  94. END_BIND_MAP()
  95. };
  96. //////////
  97. // Command to save a property bag.
  98. //////////
  99. class SetBag : public CommandBase
  100. {
  101. public:
  102. void execute(ULONG bagKey, PropertyBag& input);
  103. PCWSTR getCommandText() const throw ()
  104. {
  105. return L"PARAMETERS W LONG, X TEXT, Y LONG, Z LONGTEXT;"
  106. L"INSERT INTO Properties (Bag, Name, Type, StrVal) VALUES (W, X, Y, Z);";
  107. }
  108. protected:
  109. ULONG bag;
  110. WCHAR name[PROPERTY_NAME_LENGTH];
  111. ULONG type;
  112. WCHAR value[PROPERTY_VALUE_LENGTH];
  113. BEGIN_BIND_MAP(SetBag, ParamIO, DBACCESSOR_PARAMETERDATA)
  114. BIND_COLUMN(bag, 1, DBTYPE_I4),
  115. BIND_COLUMN(name, 2, DBTYPE_WSTR),
  116. BIND_COLUMN(type, 3, DBTYPE_I4),
  117. BIND_COLUMN(value, 4, DBTYPE_WSTR),
  118. END_BIND_MAP()
  119. };
  120. #endif // _PROPCMD_H_