Source code of Windows XP (NT5)
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.

152 lines
3.2 KiB

  1. #include "stdinc.idl"
  2. //
  3. // REVIEW Are we supposed to give structs guids?
  4. //
  5. struct SxApwColumnInfo; typedef struct SxApwColumnInfo SxApwColumnInfo;
  6. struct SxApwColumnInfo
  7. {
  8. LPCWSTR Name;
  9. BOOL IsNumber;
  10. };
  11. cpp_quote("#if defined(__cplusplus)
  12. extern \"C++\" {
  13. template <typename T>
  14. class CSxApwColumnInfoTemplate
  15. {
  16. public:
  17. void SetName(LPCWSTR name)
  18. {
  19. T::FreeString(m.Name);
  20. m.Name = T::DupString(name);
  21. }
  22. CSxApwColumnInfoTemplate(const CSxApwColumnInfoTemplate& that)
  23. {
  24. m.Name = T::DupString(that.m.Name);
  25. m.IsNumber = that.m.IsNumber;
  26. }
  27. void operator=(const CSxApwColumnInfoTemplate& that)
  28. {
  29. if (&that != this)
  30. {
  31. if (that.m.Name != NULL)
  32. {
  33. PWSTR temp = T::DupString(that.m.Name);
  34. if (temp == NULL)
  35. return;
  36. T::FreeString(m.Name);
  37. m.Name = temp;
  38. }
  39. m.IsNumber = that.m.IsNumber;
  40. }
  41. }
  42. CSxApwColumnInfoTemplate() { m.Name = NULL; m.IsNumber = FALSE; }
  43. ~CSxApwColumnInfoTemplate() { T::FreeString(m.Name); }
  44. SxApwColumnInfo m;
  45. };")
  46. /* break up cpp_quote to avoid Midl bug that drops random characters */
  47. cpp_quote("
  48. class CSxApwColumnInfoTraits
  49. {
  50. public:
  51. static void FreeString(LPCWSTR& s)
  52. {
  53. ::CoTaskMemFree(const_cast<PWSTR>(s));
  54. s = NULL;
  55. }
  56. static LPWSTR DupString(LPCWSTR s)
  57. {
  58. if (s == NULL)
  59. return NULL;
  60. PWSTR t = reinterpret_cast<LPWSTR>(::CoTaskMemAlloc((wcslen(s) + 1) * sizeof(*s)));
  61. if (t == NULL)
  62. return NULL;
  63. wcscpy(t, s);
  64. return t;
  65. }
  66. };")
  67. /* break up cpp_quote to avoid Midl bug that drops random characters */
  68. cpp_quote("
  69. typedef CSxApwColumnInfoTemplate<CSxApwColumnInfoTraits> CSxApwColumnInfo;
  70. class CSxApwBstrColumnInfoTraits
  71. {
  72. public:
  73. static void FreeString(LPCWSTR& s)
  74. {
  75. ::SysFreeString(const_cast<BSTR>(s));
  76. s = NULL;
  77. }
  78. static BSTR DupString(LPCWSTR s)
  79. {
  80. if (s == NULL)
  81. return NULL;
  82. BSTR t = reinterpret_cast<BSTR>(::SysAllocString(s));
  83. if (t == NULL)
  84. return NULL;
  85. wcscpy(t, s);
  86. return t;
  87. }
  88. };")
  89. /* break up cpp_quote to avoid Midl bug that drops random characters */
  90. cpp_quote("
  91. typedef CSxApwColumnInfoTemplate<CSxApwBstrColumnInfoTraits> CSxApwBstrColumnInfo;
  92. typedef CSxApwBstrColumnInfo CSxApwAdoColumnInfo;
  93. } /* extern C++ */")
  94. cpp_quote("#endif")
  95. [
  96. object,
  97. uuid(IID_ISxApwHost_midl)
  98. ]
  99. interface ISxApwHost : IUnknown
  100. {
  101. HRESULT
  102. SetDataSource(
  103. [in] LPCWSTR
  104. );
  105. HRESULT
  106. CreateView(
  107. [in] LPCWSTR
  108. );
  109. HRESULT
  110. DestroyView(
  111. [in] LPCWSTR
  112. );
  113. HRESULT
  114. RunQuery(
  115. [in] LPCWSTR
  116. );
  117. HRESULT
  118. OnNextRow(
  119. [in] int nColumns,
  120. [in, size_is(nColumns)] const LPCWSTR columns[]
  121. );
  122. HRESULT
  123. OnRowCountEstimateAvailable(
  124. [in] int
  125. );
  126. HRESULT
  127. OnQueryDone(
  128. );
  129. HRESULT
  130. InformSchema(
  131. [in, size_is(nColumns)] const SxApwColumnInfo rgColumnInfo[],
  132. [in] int nColumns
  133. );
  134. };