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.

104 lines
2.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // propcmd.cpp
  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 Bind integers as DBTYPE_I4.
  17. // 02/15/1999 Make commands MT safe.
  18. // 02/19/1999 Added definition of CommandBase::Execute
  19. // 05/30/2000 Add trace support.
  20. //
  21. ///////////////////////////////////////////////////////////////////////////////
  22. #include <ias.h>
  23. #include <propcmd.h>
  24. void GetBag::execute(ULONG bagKey, PropertyBag& output)
  25. {
  26. _serialize
  27. bag = bagKey;
  28. Rowset rowset;
  29. CommandBase::execute(__uuidof(IRowset), (IUnknown**)&rowset);
  30. // Iterate through the rowset and insert the properties into the bag.
  31. while (rowset.moveNext())
  32. {
  33. rowset.getData(readAccess, this);
  34. // Make a variant from the row data.
  35. _variant_t v(value);
  36. // Convert it to the appropriate type.
  37. v.ChangeType(type);
  38. // Add it to the PropertyBag
  39. output.appendValue(name, &v);
  40. }
  41. }
  42. void SetBag::execute(ULONG bagKey, PropertyBag& input)
  43. {
  44. _serialize
  45. bag = bagKey;
  46. PropertyBag::const_iterator i;
  47. // Iterate through all the properties.
  48. for (i = input.begin(); i != input.end(); ++i)
  49. {
  50. // Store the property name.
  51. wcsncpy(name, i->first, sizeof(name)/sizeof(WCHAR));
  52. PropertyValue::const_iterator j;
  53. // Iterate through all the values.
  54. for (j = i->second.begin(); j != i->second.end(); ++j)
  55. {
  56. // Set the type.
  57. type = V_VT(j);
  58. // Copy the value VARIANT.
  59. _variant_t v(*j);
  60. // Convert it to a BSTR.
  61. v.ChangeType(VT_BSTR);
  62. // Copy it into the parameter buffer.
  63. if (wcslen(V_BSTR(&v)) >= sizeof(value)/sizeof(WCHAR))
  64. {
  65. // Too big. Throw an exception.
  66. _com_issue_error(E_INVALIDARG);
  67. }
  68. else
  69. {
  70. wcscpy(value, V_BSTR(&v));
  71. }
  72. // Load the row data into the table.
  73. CommandBase::execute();
  74. }
  75. }
  76. }
  77. void CommandBase::execute(REFIID refiid, IUnknown** result)
  78. {
  79. CheckOleDBError(
  80. "ICommand::Execute",
  81. command->Execute(NULL, refiid, &dbParams, NULL, result)
  82. );
  83. }