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.

70 lines
2.1 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // bind.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file declares various macros and helper functions for binding
  12. // an OLE-DB accessor to the members of a class.
  13. //
  14. // MODIFICATION HISTORY
  15. //
  16. // 02/20/1998 Original version.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #ifndef _BIND_H_
  20. #define _BIND_H_
  21. #include <oledb.h>
  22. namespace Bind
  23. {
  24. // Returns the buffer size required for a given DBBINDING array.
  25. DBLENGTH getRowSize(DBCOUNTITEM cBindings,
  26. const DBBINDING rgBindings[]) throw ();
  27. // Creates an accessor on the pUnk object.
  28. HACCESSOR createAccessor(IUnknown* pUnk,
  29. DBACCESSORFLAGS dwAccessorFlags,
  30. DBCOUNTITEM cBindings,
  31. const DBBINDING rgBindings[],
  32. DBLENGTH cbRowSize);
  33. // Releases an accessor on the pUnk object.
  34. void releaseAccessor(IUnknown* pUnk,
  35. HACCESSOR hAccessor) throw ();
  36. }
  37. //////////
  38. // Marks the beginning of DBBINDING map.
  39. //////////
  40. #define BEGIN_BIND_MAP(class, name, flags) \
  41. HACCESSOR create ## name(IUnknown* p) const \
  42. { typedef class _theClass; \
  43. const DBACCESSORFLAGS dbFlags = flags; \
  44. static const DBBINDING binding[] = {
  45. //////////
  46. // Terminates a DBBINDING map.
  47. //////////
  48. #define END_BIND_MAP() \
  49. }; const DBCOUNTITEM count = sizeof(binding)/sizeof(DBBINDING); \
  50. static const DBLENGTH rowsize = Bind::getRowSize(count, binding); \
  51. return Bind::createAccessor(p, dbFlags, count, binding, rowsize); \
  52. }
  53. //////////
  54. // Entry in a DBBINDING map. Entries must be separated by commas.
  55. //////////
  56. #define BIND_COLUMN(member, ordinal, type) \
  57. { ordinal, offsetof(_theClass, member), 0, 0, NULL, NULL, NULL, \
  58. DBPART_VALUE, DBMEMOWNER_CLIENTOWNED, \
  59. (dbFlags == DBACCESSOR_ROWDATA ? DBPARAMIO_NOTPARAM : DBPARAMIO_INPUT), \
  60. sizeof(_theClass :: member), 0, type, 0, 0 }
  61. #endif // _BIND_H_