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.

1838 lines
62 KiB

  1. //--------------------------------------------------------------------
  2. // Microsoft OLE-DB Query
  3. //
  4. // Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // @doc
  7. //
  8. // @module treeutil.cpp |
  9. //
  10. // Contains tree manipulation utility functions for both OLE-DB and QTE trees.
  11. //
  12. // @devnote None
  13. //
  14. // @rev 0 | 12-Feb-97 | v-charca | Created
  15. //
  16. #pragma hdrstop
  17. #include "msidxtr.h"
  18. #define INDENTLINE setfill('\t') << setw(indentLevel) << ""
  19. #define VAL_AND_CCH_MINUS_NULL(p1) (p1), ((sizeof(p1) / sizeof(*(p1))) - 1)
  20. //--------------------------------------------------------------------
  21. // @func Converts a wide character string string into a LARGEINTEGER
  22. // @rdesc Pointer to new UNICODE string
  23. HRESULT PropVariantChangeTypeI64(
  24. PROPVARIANT* pvarValue )
  25. {
  26. LPWSTR pwszVal = pvarValue->bstrVal;
  27. ULONGLONG uhVal = 0;
  28. UINT iBase = 10;
  29. BOOL fNegative = FALSE;
  30. UINT uiDigitVal = 0;
  31. if (L'-' == *pwszVal)
  32. {
  33. fNegative = TRUE; // remember we need to negate later
  34. pwszVal++;
  35. }
  36. else if (L'+' == *pwszVal)
  37. pwszVal++; // a plus sign is simply noise
  38. if ((L'0' == pwszVal[0]) && (L'x' == pwszVal[1] || L'X' == pwszVal[1]))
  39. {
  40. iBase = 16;
  41. pwszVal += 2;
  42. }
  43. ULONGLONG uhMaxPartial = _UI64_MAX / iBase;
  44. while (*pwszVal)
  45. {
  46. if (iswdigit(*pwszVal))
  47. uiDigitVal = *pwszVal - L'0';
  48. else /* a-fA-F */
  49. uiDigitVal = towupper(*pwszVal) - L'A' + 10;
  50. if (uhVal < uhMaxPartial ||
  51. (uhVal == uhMaxPartial && (ULONGLONG)uiDigitVal <= _UI64_MAX % iBase))
  52. uhVal = uhVal * iBase + uiDigitVal;
  53. else // adding this digit would cause an overflow to occur
  54. return DISP_E_OVERFLOW;
  55. pwszVal++;
  56. }
  57. if (fNegative)
  58. {
  59. if (uhVal > -_I64_MIN)
  60. return DISP_E_OVERFLOW;
  61. else
  62. {
  63. SysFreeString(pvarValue->bstrVal);
  64. pvarValue->vt = VT_I8;
  65. pvarValue->hVal.QuadPart = -(LONGLONG)uhVal;
  66. }
  67. }
  68. else
  69. {
  70. SysFreeString(pvarValue->bstrVal);
  71. pvarValue->vt = VT_UI8;
  72. pvarValue->uhVal.QuadPart = uhVal;
  73. }
  74. return S_OK;
  75. }
  76. #ifdef DEBUG
  77. //--------------------------------------------------------------------
  78. // @func ostream& | operator shift-left |
  79. // Dumps the given LPOLESTR string into the given ostream.
  80. // @rdesc ostream
  81. ostream & operator <<
  82. (
  83. ostream &osOut, //@parm INOUT | ostream in which node is to be placed.
  84. LPWSTR pwszName //@parm IN | LPWSTR string to dump.
  85. )
  86. {
  87. UINT cLen = wcslen(pwszName);
  88. for (UINT i=0; i<cLen; i++)
  89. osOut << char(pwszName[i]);
  90. return osOut;
  91. }
  92. #endif
  93. //--------------------------------------------------------------------
  94. //@func Allocates and initializes an OLE-DB DBCOMMANDTREE
  95. // of the given kind and op.
  96. //
  97. //@rdesc DBCommandTree node of the correct kind and
  98. // with any additional memory for the value field allocated.
  99. // All other fields are NULL or default values.
  100. //
  101. DBCOMMANDTREE * PctAllocNode(
  102. DBVALUEKIND wKind, //@parm IN | kind of tree to create
  103. DBCOMMANDOP op ) //@parm IN
  104. {
  105. DBCOMMANDTREE* pTableNode = NULL;
  106. pTableNode = (DBCOMMANDTREE*) CoTaskMemAlloc(sizeof(DBCOMMANDTREE));
  107. if (NULL == pTableNode)
  108. return NULL;
  109. // Set default values
  110. pTableNode->op = op;
  111. pTableNode->wKind = (WORD)wKind;
  112. pTableNode->pctFirstChild = NULL;
  113. pTableNode->pctNextSibling = NULL;
  114. pTableNode->value.pvValue = NULL;
  115. pTableNode->hrError = S_OK;
  116. switch (wKind)
  117. {
  118. case DBVALUEKIND_BYGUID:
  119. pTableNode->value.pdbbygdValue = (DBBYGUID*) CoTaskMemAlloc(sizeof DBBYGUID);
  120. if (NULL == pTableNode->value.pdbbygdValue)
  121. {
  122. CoTaskMemFree(pTableNode);
  123. pTableNode = NULL;
  124. }
  125. break;
  126. case DBVALUEKIND_COLDESC:
  127. pTableNode->value.pcoldescValue = (DBCOLUMNDESC*) CoTaskMemAlloc(sizeof DBCOLUMNDESC);
  128. if (NULL == pTableNode->value.pcoldescValue)
  129. {
  130. CoTaskMemFree(pTableNode);
  131. pTableNode = NULL;
  132. }
  133. break;
  134. case DBVALUEKIND_ID:
  135. pTableNode->value.pdbidValue = (DBID*) CoTaskMemAlloc(sizeof DBID);
  136. if (NULL == pTableNode->value.pdbidValue)
  137. {
  138. CoTaskMemFree(pTableNode);
  139. pTableNode = NULL;
  140. }
  141. break;
  142. case DBVALUEKIND_CONTENT:
  143. pTableNode->value.pdbcntntValue = (DBCONTENT*) CoTaskMemAlloc(sizeof DBCONTENT);
  144. if (NULL == pTableNode->value.pdbcntntValue)
  145. {
  146. CoTaskMemFree(pTableNode);
  147. pTableNode = NULL;
  148. }
  149. break;
  150. case DBVALUEKIND_CONTENTSCOPE:
  151. pTableNode->value.pdbcntntscpValue = (DBCONTENTSCOPE*) CoTaskMemAlloc(sizeof DBCONTENTSCOPE);
  152. if ( NULL == pTableNode->value.pdbcntntscpValue )
  153. {
  154. CoTaskMemFree( pTableNode );
  155. pTableNode = NULL;
  156. }
  157. else
  158. RtlZeroMemory( pTableNode->value.pdbcntntscpValue, sizeof(DBCONTENTSCOPE) );
  159. break;
  160. case DBVALUEKIND_CONTENTTABLE:
  161. pTableNode->value.pdbcntnttblValue = (DBCONTENTTABLE*) CoTaskMemAlloc(sizeof DBCONTENTTABLE);
  162. if ( NULL == pTableNode->value.pdbcntnttblValue )
  163. {
  164. CoTaskMemFree( pTableNode );
  165. pTableNode = NULL;
  166. }
  167. else
  168. RtlZeroMemory( pTableNode->value.pdbcntnttblValue, sizeof(DBCONTENTTABLE) );
  169. break;
  170. case DBVALUEKIND_CONTENTVECTOR:
  171. pTableNode->value.pdbcntntvcValue = (DBCONTENTVECTOR*) CoTaskMemAlloc(sizeof DBCONTENTVECTOR);
  172. if (NULL == pTableNode->value.pdbcntntvcValue)
  173. {
  174. CoTaskMemFree(pTableNode);
  175. pTableNode = NULL;
  176. }
  177. break;
  178. case DBVALUEKIND_GROUPINFO:
  179. pTableNode->value.pdbgrpinfValue = (DBGROUPINFO*) CoTaskMemAlloc(sizeof DBGROUPINFO);
  180. if (NULL == pTableNode->value.pdbgrpinfValue)
  181. {
  182. CoTaskMemFree(pTableNode);
  183. pTableNode = NULL;
  184. }
  185. break;
  186. // case DBVALUEKIND_PARAMETER:
  187. // case DBVALUEKIND_PROPERTY:
  188. case DBVALUEKIND_SETFUNC:
  189. pTableNode->value.pdbstfncValue = (DBSETFUNC*) CoTaskMemAlloc(sizeof DBSETFUNC);
  190. if (NULL == pTableNode->value.pdbstfncValue)
  191. {
  192. CoTaskMemFree(pTableNode);
  193. pTableNode = NULL;
  194. }
  195. break;
  196. case DBVALUEKIND_SORTINFO:
  197. pTableNode->value.pdbsrtinfValue = (DBSORTINFO*) CoTaskMemAlloc(sizeof DBSORTINFO);
  198. if (NULL == pTableNode->value.pdbsrtinfValue)
  199. {
  200. CoTaskMemFree(pTableNode);
  201. pTableNode = NULL;
  202. }
  203. break;
  204. case DBVALUEKIND_TEXT:
  205. pTableNode->value.pdbtxtValue = (DBTEXT*) CoTaskMemAlloc(sizeof DBTEXT);
  206. if (NULL == pTableNode->value.pdbtxtValue)
  207. {
  208. CoTaskMemFree(pTableNode);
  209. pTableNode = NULL;
  210. }
  211. break;
  212. case DBVALUEKIND_COMMAND:
  213. case DBVALUEKIND_MONIKER:
  214. case DBVALUEKIND_ROWSET:
  215. break;
  216. case DBVALUEKIND_LIKE:
  217. pTableNode->value.pdblikeValue = (DBLIKE*) CoTaskMemAlloc(sizeof DBLIKE);
  218. if (NULL == pTableNode->value.pdblikeValue)
  219. {
  220. CoTaskMemFree(pTableNode);
  221. pTableNode = NULL;
  222. }
  223. break;
  224. case DBVALUEKIND_CONTENTPROXIMITY:
  225. pTableNode->value.pdbcntntproxValue = (DBCONTENTPROXIMITY*) CoTaskMemAlloc(sizeof DBCONTENTPROXIMITY);
  226. if (NULL == pTableNode->value.pdbcntntproxValue)
  227. {
  228. CoTaskMemFree(pTableNode);
  229. pTableNode = NULL;
  230. }
  231. break;
  232. case DBVALUEKIND_IDISPATCH:
  233. case DBVALUEKIND_IUNKNOWN:
  234. case DBVALUEKIND_EMPTY:
  235. case DBVALUEKIND_NULL:
  236. case DBVALUEKIND_I2:
  237. case DBVALUEKIND_I4:
  238. case DBVALUEKIND_R4:
  239. case DBVALUEKIND_R8:
  240. case DBVALUEKIND_CY:
  241. case DBVALUEKIND_DATE:
  242. case DBVALUEKIND_BSTR:
  243. case DBVALUEKIND_ERROR:
  244. case DBVALUEKIND_BOOL:
  245. break;
  246. case DBVALUEKIND_VARIANT:
  247. // NOTE: This is really a PROPVARIANT node, but there is no DBVALUEKIND for PROPVARIANT.
  248. pTableNode->value.pvValue = (PROPVARIANT*) CoTaskMemAlloc(sizeof PROPVARIANT);
  249. if (NULL == pTableNode->value.pvValue )
  250. {
  251. CoTaskMemFree(pTableNode);
  252. pTableNode = NULL;
  253. }
  254. else
  255. PropVariantInit((PROPVARIANT*)(pTableNode->value.pvValue));
  256. break;
  257. case DBVALUEKIND_VECTOR:
  258. case DBVALUEKIND_ARRAY:
  259. case DBVALUEKIND_BYREF:
  260. case DBVALUEKIND_I1:
  261. case DBVALUEKIND_UI1:
  262. case DBVALUEKIND_UI2:
  263. case DBVALUEKIND_UI4:
  264. case DBVALUEKIND_I8:
  265. case DBVALUEKIND_UI8:
  266. break;
  267. case DBVALUEKIND_GUID:
  268. pTableNode->value.pGuid = (GUID*) CoTaskMemAlloc(sizeof GUID);
  269. if (NULL == pTableNode->value.pGuid)
  270. {
  271. CoTaskMemFree(pTableNode);
  272. pTableNode = NULL;
  273. }
  274. break;
  275. case DBVALUEKIND_BYTES:
  276. case DBVALUEKIND_STR:
  277. case DBVALUEKIND_WSTR:
  278. case DBVALUEKIND_NUMERIC:
  279. // case DBVALUEKIND_DBDATE:
  280. // case DBVALUEKIND_DBTIME:
  281. // case DBVALUEKIND_DBTIMESTAMP:
  282. break;
  283. default:
  284. assert(!"PctAllocNode: illegal wKind");
  285. CoTaskMemFree(pTableNode);
  286. pTableNode = NULL;
  287. break;
  288. }
  289. return pTableNode;
  290. }
  291. //--------------------------------------------------------------------
  292. // @func Reverses a linked list of DBCOMMANDTREE siblings. This is necessary
  293. // for left recursive rule in the YACC grammar.
  294. //
  295. // @rdesc DBCOMMANDTREE *
  296. //
  297. DBCOMMANDTREE * PctReverse(
  298. DBCOMMANDTREE * pct ) // @parm IN | original list to be reversed
  299. {
  300. DBCOMMANDTREE *pctPrev = NULL;
  301. DBCOMMANDTREE *pctNext = pct;
  302. /** NULL or 1 item list is itself **/
  303. if(pct == NULL || pct->pctNextSibling == NULL)
  304. return pct;
  305. Assert(pct != NULL);
  306. while(pct != NULL)
  307. {
  308. pctNext = pctNext->pctNextSibling;
  309. pct->pctNextSibling = pctPrev;
  310. pctPrev = pct;
  311. pct = pctNext;
  312. }
  313. return pctPrev;
  314. }
  315. //--------------------------------------------------------------------
  316. // @func Creates a DBCOMMANDTREE and tags it by the given op and sets its
  317. // arguments. Note that this routine is takes variable params to DBCOMMANDTREE's. This
  318. // allows the YACC grammer file to use a central entry point to create a
  319. // parse tree complete with all its children args.
  320. //
  321. // @side This routine will traverse arg inputs before appending trailing args. This
  322. // gives the effect of appending lists to lists.
  323. //
  324. // @rdesc DBCOMMANDTREE *
  325. //
  326. // @devnote
  327. // Last argument must be NULL: As end of var args is detected with NULL.
  328. //
  329. DBCOMMANDTREE *PctCreateNode(
  330. DBCOMMANDOP op, // @parm IN | op tag for new node
  331. DBVALUEKIND wKind, //@parm IN | kind to node to allocate
  332. DBCOMMANDTREE * pctArg, // @parm IN | var arg children
  333. ... )
  334. {
  335. HRESULT hr = S_OK;
  336. DBCOMMANDTREE * pctRoot = NULL;
  337. DBCOMMANDTREE * pctCurArg = NULL;
  338. USHORT cNode = 0;
  339. va_list pArg;
  340. if (pctArg != NULL)
  341. {
  342. va_start(pArg, pctArg); // start var arg list
  343. /** create arg list by chaining all input node togther **/
  344. pctCurArg = pctArg;
  345. while(TRUE)
  346. {
  347. /** walk to the end of the current list **/
  348. while (pctCurArg->pctNextSibling != NULL)
  349. {
  350. pctCurArg = pctCurArg->pctNextSibling;
  351. cNode++;
  352. }
  353. /** place the next arg onto the tail of the list (this might also be a list) **/
  354. pctCurArg->pctNextSibling = va_arg(pArg, DBCOMMANDTREE *); // get next var arg
  355. /** no more args to append to list**/
  356. if (pctCurArg->pctNextSibling == NULL)
  357. break;
  358. }
  359. va_end(pArg); // destruct var arg list
  360. }
  361. /** create the node and add specifc type info **/
  362. if((pctRoot = PctAllocNode(wKind)) == NULL)
  363. {
  364. hr = E_OUTOFMEMORY;
  365. goto CreateErr;
  366. }
  367. /** tag node type and set child arg list **/
  368. pctRoot->op = op;
  369. pctRoot->pctFirstChild = pctArg;
  370. Assert(NULL != pctRoot);
  371. /** Success **/
  372. return pctRoot;
  373. CreateErr:
  374. return NULL;
  375. }
  376. //--------------------------------------------------------------------
  377. // @func Creates a DBCOMMANDTREE and tags it by the given op and sets its
  378. // arguments. Note that this routine is takes variable params to DBCOMMANDTREE's. This
  379. // allows the YACC grammer file to use a central entry point to create a
  380. // parse tree complete with all its children args.
  381. //
  382. // @side This routine will traverse arg inputs before appending trailing args. This
  383. // gives the effect of appending lists to lists.
  384. //
  385. // @rdesc DBCOMMANDTREE *
  386. //
  387. // @devnote
  388. // Last argument must be NULL: As end of var args is detected with NULL.
  389. //
  390. DBCOMMANDTREE *PctCreateNode(
  391. DBCOMMANDOP op, // @parm IN | op tag for new node
  392. DBCOMMANDTREE * pctArg, // @parm IN | var arg children
  393. ... )
  394. {
  395. HRESULT hr = S_OK;
  396. DBCOMMANDTREE * pctRoot = NULL;
  397. DBCOMMANDTREE * pctCurArg = NULL;
  398. USHORT cNode = 0;
  399. va_list pArg;
  400. if (pctArg != NULL)
  401. {
  402. va_start(pArg, pctArg); // start var arg list
  403. /** create arg list by chaining all input node togther **/
  404. pctCurArg = pctArg;
  405. while(TRUE)
  406. {
  407. /** walk to the end of the current list **/
  408. while (pctCurArg->pctNextSibling != NULL)
  409. {
  410. pctCurArg = pctCurArg->pctNextSibling;
  411. cNode++;
  412. }
  413. /** place the next arg onto the tail of the list (this might also be a list) **/
  414. pctCurArg->pctNextSibling = va_arg(pArg, DBCOMMANDTREE *); // get next var arg
  415. /** no more args to append to list**/
  416. if (pctCurArg->pctNextSibling == NULL)
  417. break;
  418. }
  419. va_end(pArg); // destruct var arg list
  420. }
  421. /** create the node and add specifc type info **/
  422. if((pctRoot = PctAllocNode(DBVALUEKIND_EMPTY)) == NULL)
  423. {
  424. hr = E_OUTOFMEMORY;
  425. goto CreateErr;
  426. }
  427. /** tag node type and set child arg list **/
  428. pctRoot->op = op;
  429. pctRoot->pctFirstChild = pctArg;
  430. Assert(NULL != pctRoot);
  431. /** Success **/
  432. return pctRoot;
  433. CreateErr:
  434. return NULL;
  435. }
  436. //--------------------------------------------------------------------
  437. //@func Determines the number of siblings of a given node.
  438. //
  439. UINT GetNumberOfSiblings(
  440. DBCOMMANDTREE *pct ) //@parm IN | starting node
  441. {
  442. UINT cSiblings =0;
  443. while (pct)
  444. {
  445. cSiblings++;
  446. pct=pct->pctNextSibling;
  447. }
  448. return cSiblings;
  449. }
  450. //--------------------------------------------------------------------
  451. //@func Recursively deletes a command tree using CoTaskMemFree
  452. //
  453. void DeleteDBQT(
  454. DBCOMMANDTREE* pTableNode ) //@parm IN | Tree to delete
  455. {
  456. if ( 0 == pTableNode )
  457. return;
  458. //delete children and siblings
  459. if (pTableNode->pctFirstChild)
  460. DeleteDBQT(pTableNode->pctFirstChild);
  461. if (pTableNode->pctNextSibling)
  462. DeleteDBQT(pTableNode->pctNextSibling);
  463. //delete member pointers
  464. switch (pTableNode->wKind)
  465. {
  466. case DBVALUEKIND_BYGUID:
  467. CoTaskMemFree(pTableNode->value.pdbbygdValue);
  468. break;
  469. case DBVALUEKIND_COLDESC:
  470. CoTaskMemFree(pTableNode->value.pcoldescValue);
  471. break;
  472. case DBVALUEKIND_ID:
  473. switch (pTableNode->value.pdbidValue->eKind)
  474. {
  475. case DBKIND_NAME:
  476. case DBKIND_GUID_NAME:
  477. CoTaskMemFree(pTableNode->value.pdbidValue->uName.pwszName);
  478. break;
  479. case DBKIND_PGUID_PROPID:
  480. CoTaskMemFree(pTableNode->value.pdbidValue->uGuid.pguid);
  481. break;
  482. case DBKIND_PGUID_NAME:
  483. CoTaskMemFree(pTableNode->value.pdbidValue->uName.pwszName);
  484. CoTaskMemFree(pTableNode->value.pdbidValue->uGuid.pguid);
  485. break;
  486. case DBKIND_GUID:
  487. case DBKIND_GUID_PROPID:
  488. break; // nothing to get rid of
  489. default: // It shouldn't be anything else
  490. Assert(0);
  491. }
  492. CoTaskMemFree(pTableNode->value.pdbidValue);
  493. break;
  494. case DBVALUEKIND_CONTENT:
  495. CoTaskMemFree(pTableNode->value.pdbcntntValue->pwszPhrase);
  496. CoTaskMemFree(pTableNode->value.pdbcntntValue);
  497. break;
  498. case DBVALUEKIND_CONTENTSCOPE:
  499. CoTaskMemFree(pTableNode->value.pdbcntntscpValue->pwszElementValue);
  500. CoTaskMemFree(pTableNode->value.pdbcntntscpValue);
  501. break;
  502. case DBVALUEKIND_CONTENTTABLE:
  503. CoTaskMemFree(pTableNode->value.pdbcntnttblValue->pwszMachine);
  504. CoTaskMemFree(pTableNode->value.pdbcntnttblValue->pwszCatalog);
  505. CoTaskMemFree(pTableNode->value.pdbcntnttblValue);
  506. break;
  507. case DBVALUEKIND_CONTENTVECTOR:
  508. CoTaskMemFree(pTableNode->value.pdbcntntvcValue);
  509. break;
  510. case DBVALUEKIND_LIKE:
  511. CoTaskMemFree(pTableNode->value.pdblikeValue);
  512. break;
  513. case DBVALUEKIND_CONTENTPROXIMITY:
  514. CoTaskMemFree(pTableNode->value.pdbcntntproxValue);
  515. break;
  516. case DBVALUEKIND_GROUPINFO:
  517. CoTaskMemFree(pTableNode->value.pdbgrpinfValue);
  518. break;
  519. case DBVALUEKIND_SETFUNC:
  520. CoTaskMemFree(pTableNode->value.pdbstfncValue);
  521. break;
  522. case DBVALUEKIND_SORTINFO:
  523. CoTaskMemFree(pTableNode->value.pdbsrtinfValue);
  524. break;
  525. case DBVALUEKIND_TEXT:
  526. Assert(NULL != pTableNode->value.pdbtxtValue);
  527. Assert(NULL != pTableNode->value.pdbtxtValue->pwszText);
  528. CoTaskMemFree(pTableNode->value.pdbtxtValue->pwszText);
  529. CoTaskMemFree(pTableNode->value.pdbtxtValue);
  530. break;
  531. case DBVALUEKIND_COMMAND:
  532. case DBVALUEKIND_MONIKER:
  533. case DBVALUEKIND_ROWSET:
  534. case DBVALUEKIND_IDISPATCH:
  535. case DBVALUEKIND_IUNKNOWN:
  536. case DBVALUEKIND_EMPTY:
  537. case DBVALUEKIND_NULL:
  538. case DBVALUEKIND_I2:
  539. case DBVALUEKIND_I4:
  540. case DBVALUEKIND_R4:
  541. case DBVALUEKIND_R8:
  542. case DBVALUEKIND_CY:
  543. case DBVALUEKIND_DATE:
  544. break;
  545. case DBVALUEKIND_BSTR:
  546. CoTaskMemFree(pTableNode->value.pbstrValue);
  547. break;
  548. case DBVALUEKIND_ERROR:
  549. case DBVALUEKIND_BOOL:
  550. break;
  551. case DBVALUEKIND_VARIANT:
  552. {
  553. HRESULT hr = PropVariantClear((PROPVARIANT*)pTableNode->value.pvValue);
  554. if (FAILED(hr))
  555. Assert(0); // UNDONE: meaningful error message
  556. CoTaskMemFree(pTableNode->value.pvValue);
  557. }
  558. break;
  559. case DBVALUEKIND_VECTOR:
  560. case DBVALUEKIND_ARRAY:
  561. case DBVALUEKIND_BYREF:
  562. assert(!"DeleteDBQT Vector,array,byref not implemented");
  563. break;
  564. case DBVALUEKIND_I1:
  565. case DBVALUEKIND_UI1:
  566. case DBVALUEKIND_UI2:
  567. case DBVALUEKIND_UI4:
  568. case DBVALUEKIND_I8:
  569. case DBVALUEKIND_UI8:
  570. break;
  571. case DBVALUEKIND_GUID:
  572. CoTaskMemFree(pTableNode->value.pGuid);
  573. break;
  574. case DBVALUEKIND_BYTES:
  575. assert(!"DeleteDBQT BYTES not implemented");
  576. break;
  577. case DBVALUEKIND_WSTR:
  578. CoTaskMemFree(pTableNode->value.pwszValue);
  579. break;
  580. case DBVALUEKIND_NUMERIC:
  581. CoTaskMemFree(pTableNode->value.pdbnValue);
  582. break;
  583. default :
  584. Assert(FALSE);
  585. break;
  586. }
  587. CoTaskMemFree(pTableNode);
  588. }
  589. //--------------------------------------------------------------------
  590. //@func Copies the OLE-DB tree (pTableNodeSrc) into a new tree
  591. //@rdesc Return pointer to new tree in ppTableNodeDest
  592. //
  593. HRESULT HrQeTreeCopy(
  594. DBCOMMANDTREE **ppTableNodeDest, // @parm OUT | destination for copy
  595. const DBCOMMANDTREE *pTableNodeSrc ) // @parm IN | src OLE-DB tree
  596. {
  597. HRESULT hr = S_OK;
  598. *ppTableNodeDest = NULL;
  599. if (pTableNodeSrc == NULL)
  600. return hr;
  601. // Allocates the correct
  602. DBCOMMANDTREE * pTableNode = PctAllocNode(pTableNodeSrc->wKind);
  603. if (NULL == pTableNode)
  604. return E_OUTOFMEMORY;
  605. pTableNode->op = pTableNodeSrc->op;
  606. pTableNode->hrError = pTableNodeSrc->hrError;
  607. //Now for byref data, make a copy of the data
  608. switch(pTableNode->wKind)
  609. {
  610. case DBVALUEKIND_ID:
  611. RtlCopyMemory(pTableNode->value.pdbidValue,pTableNodeSrc->value.pdbidValue,sizeof(DBID));
  612. switch (pTableNodeSrc->value.pdbidValue->eKind)
  613. {
  614. case DBKIND_NAME:
  615. case DBKIND_GUID_NAME:
  616. // need to create a new string
  617. pTableNode->value.pdbidValue->uName.pwszName =
  618. CoTaskStrDup(pTableNodeSrc->value.pdbidValue->uName.pwszName);
  619. break;
  620. case DBKIND_GUID:
  621. case DBKIND_GUID_PROPID:
  622. // nothing new to copy
  623. break;
  624. case DBKIND_PGUID_NAME:
  625. // need to create a new string
  626. pTableNode->value.pdbidValue->uName.pwszName =
  627. CoTaskStrDup(pTableNodeSrc->value.pdbidValue->uName.pwszName);
  628. // need to allocate and copy guid
  629. pTableNode->value.pdbidValue->uGuid.pguid =
  630. (GUID*)CoTaskMemAlloc(sizeof(GUID));
  631. *pTableNode->value.pdbidValue->uGuid.pguid =
  632. *pTableNodeSrc->value.pdbidValue->uGuid.pguid;
  633. break;
  634. case DBKIND_PGUID_PROPID:
  635. // need to allocate and copy guid
  636. pTableNode->value.pdbidValue->uGuid.pguid =
  637. (GUID*)CoTaskMemAlloc(sizeof(GUID));
  638. *pTableNode->value.pdbidValue->uGuid.pguid =
  639. *pTableNodeSrc->value.pdbidValue->uGuid.pguid;
  640. break;
  641. default:
  642. Assert(0);
  643. }
  644. break;
  645. case DBVALUEKIND_BYGUID:
  646. RtlCopyMemory(pTableNode->value.pdbbygdValue,pTableNodeSrc->value.pdbbygdValue,sizeof(DBBYGUID));
  647. break;
  648. case DBVALUEKIND_COLDESC:
  649. if (NULL == pTableNodeSrc->value.pcoldescValue)
  650. pTableNode->value.pcoldescValue = NULL;
  651. else
  652. {
  653. RtlCopyMemory(pTableNode->value.pcoldescValue, pTableNodeSrc->value.pcoldescValue, sizeof(DBCOLUMNDESC));
  654. if (NULL != pTableNodeSrc->value.pcoldescValue->dbcid.uName.pwszName)
  655. pTableNode->value.pcoldescValue->dbcid.uName.pwszName = CoTaskStrDup(pTableNodeSrc->value.pcoldescValue->dbcid.uName.pwszName);
  656. else
  657. pTableNode->value.pcoldescValue->dbcid.uName.pwszName = NULL;
  658. }
  659. break;
  660. case DBVALUEKIND_CONTENT:
  661. RtlCopyMemory(pTableNode->value.pdbcntntValue, pTableNodeSrc->value.pdbcntntValue, sizeof(DBCONTENT));
  662. // UNDONE: allocate and stuff ->pwszPhrase
  663. break;
  664. case DBVALUEKIND_CONTENTSCOPE:
  665. (pTableNode->value.pdbcntntscpValue)->pwszElementValue = CoTaskStrDup( (pTableNodeSrc->value.pdbcntntscpValue)->pwszElementValue );
  666. (pTableNode->value.pdbcntntscpValue)->dwFlags = (pTableNodeSrc->value.pdbcntntscpValue)->dwFlags;
  667. // RtlCopyMemory(pTableNode->value.pdbcntntscpValue, pTableNodeSrc->value.pdbcntntscpValue, sizeof(DBCONTENTSCOPE));
  668. break;
  669. case DBVALUEKIND_CONTENTTABLE:
  670. (pTableNode->value.pdbcntnttblValue)->pwszMachine = CoTaskStrDup( (pTableNodeSrc->value.pdbcntnttblValue)->pwszMachine );
  671. (pTableNode->value.pdbcntnttblValue)->pwszCatalog = CoTaskStrDup( (pTableNodeSrc->value.pdbcntnttblValue)->pwszCatalog );
  672. // RtlCopyMemory(pTableNode->value.pdbcntnttblValue, pTableNodeSrc->value.pdbcntnttblValue, sizeof(DBCONTENTTABLE));
  673. break;
  674. case DBVALUEKIND_LIKE:
  675. RtlCopyMemory(pTableNode->value.pdblikeValue,pTableNodeSrc->value.pdblikeValue,sizeof(DBLIKE));
  676. break;
  677. case DBVALUEKIND_CONTENTPROXIMITY:
  678. RtlCopyMemory(pTableNode->value.pdbcntntproxValue, pTableNodeSrc->value.pdbcntntproxValue, sizeof(DBCONTENTPROXIMITY));
  679. // UNDONE: allocate and stuff ->pwszPhrase
  680. break;
  681. case DBVALUEKIND_CONTENTVECTOR:
  682. //UNDONE: CoTaskMemFree(pTableNode->value.pdbcntntvcValue->rgulWeights);
  683. RtlCopyMemory(pTableNode->value.pdbcntntvcValue, pTableNodeSrc->value.pdbcntntvcValue, sizeof(DBCONTENTVECTOR));
  684. break;
  685. case DBVALUEKIND_GROUPINFO:
  686. RtlCopyMemory(pTableNode->value.pdbgrpinfValue,pTableNodeSrc->value.pdbgrpinfValue,sizeof(DBGROUPINFO));
  687. break;
  688. case DBVALUEKIND_SETFUNC:
  689. RtlCopyMemory(pTableNode->value.pdbstfncValue,pTableNodeSrc->value.pdbstfncValue,sizeof(DBSETFUNC));
  690. break;
  691. case DBVALUEKIND_SORTINFO:
  692. RtlCopyMemory(pTableNode->value.pdbsrtinfValue,pTableNodeSrc->value.pdbsrtinfValue,sizeof(DBSORTINFO));
  693. break;
  694. case DBVALUEKIND_TEXT:
  695. pTableNode->value.pdbtxtValue->guidDialect = pTableNodeSrc->value.pdbtxtValue->guidDialect;
  696. pTableNode->value.pdbtxtValue->pwszText = CoTaskStrDup(pTableNodeSrc->value.pdbtxtValue->pwszText);
  697. pTableNode->value.pdbtxtValue->ulErrorLocator = pTableNodeSrc->value.pdbtxtValue->ulErrorLocator;
  698. pTableNode->value.pdbtxtValue->ulTokenLength = pTableNodeSrc->value.pdbtxtValue->ulTokenLength;
  699. break;
  700. case DBVALUEKIND_BSTR:
  701. assert(!"HrQeTreeCopy:BSTR not implemented");
  702. break;
  703. case DBVALUEKIND_VARIANT:
  704. PropVariantCopy((PROPVARIANT*)pTableNode->value.pvValue,
  705. (PROPVARIANT*)pTableNodeSrc->value.pvValue);
  706. break;
  707. case DBVALUEKIND_VECTOR:
  708. case DBVALUEKIND_ARRAY:
  709. case DBVALUEKIND_BYREF:
  710. assert(!"HrQeTreeCopy:Vector,Array,Byref not implemented");
  711. break;
  712. case DBVALUEKIND_GUID:
  713. *(pTableNode->value.pGuid) = *(pTableNodeSrc->value.pGuid);
  714. break;
  715. case DBVALUEKIND_BYTES:
  716. assert(!"HrQeTreeCopy:bytes not implemented");
  717. break;
  718. case DBVALUEKIND_WSTR:
  719. pTableNode->value.pwszValue = CoTaskStrDup(pTableNodeSrc->value.pwszValue);
  720. break;
  721. // Copied as part of first 8 bytes
  722. case DBVALUEKIND_COMMAND:
  723. case DBVALUEKIND_MONIKER:
  724. case DBVALUEKIND_ROWSET:
  725. case DBVALUEKIND_IDISPATCH:
  726. case DBVALUEKIND_IUNKNOWN:
  727. //NYI : rossbu (6/29/95) -- AddRef interfaces on copy
  728. case DBVALUEKIND_EMPTY:
  729. case DBVALUEKIND_NULL:
  730. case DBVALUEKIND_I2:
  731. case DBVALUEKIND_I4:
  732. case DBVALUEKIND_R4:
  733. case DBVALUEKIND_R8:
  734. case DBVALUEKIND_CY:
  735. case DBVALUEKIND_DATE:
  736. // Copied as part of first 8 bytes
  737. case DBVALUEKIND_ERROR:
  738. case DBVALUEKIND_BOOL:
  739. // Copied as part of first 8 bytes
  740. case DBVALUEKIND_I1:
  741. case DBVALUEKIND_UI1:
  742. case DBVALUEKIND_UI2:
  743. case DBVALUEKIND_UI4:
  744. case DBVALUEKIND_I8:
  745. case DBVALUEKIND_UI8:
  746. //Copy the data values
  747. RtlCopyMemory(&(pTableNode->value), &(pTableNodeSrc->value),(sizeof pTableNode->value));
  748. break;
  749. default :
  750. Assert(FALSE);
  751. break;
  752. }
  753. hr = HrQeTreeCopy(&pTableNode->pctFirstChild, pTableNodeSrc->pctFirstChild);
  754. if (FAILED(hr))
  755. return ResultFromScode(hr);
  756. hr = HrQeTreeCopy(&pTableNode->pctNextSibling, pTableNodeSrc->pctNextSibling);
  757. if (FAILED(hr))
  758. return ResultFromScode(hr);
  759. *ppTableNodeDest = pTableNode;
  760. return ResultFromScode(hr);
  761. }
  762. // ----------------------------------------------------------------------------
  763. //
  764. // Method: SetDepthAndInclusion
  765. //
  766. // Synopsis: Walks through the list of scopes and applies the scope
  767. // information provided by pctInfo to each node.
  768. //
  769. // Arguments: [pctInfo] -- a node with deep/shallow, include/exclude info
  770. // [pctScpList] -- a list of scope_list_element nodes
  771. //
  772. // History: 07-25-98 danleg Created
  773. //
  774. // ----------------------------------------------------------------------------
  775. void SetDepthAndInclusion(
  776. DBCOMMANDTREE * pctInfo,
  777. DBCOMMANDTREE * pctScpList )
  778. {
  779. Assert( 0 != pctInfo && NULL != pctScpList );
  780. DBCOMMANDTREE* pct = pctScpList;
  781. while( NULL != pct )
  782. {
  783. pct->value.pdbcntntscpValue->dwFlags |=
  784. (pctInfo->value.pdbcntntscpValue->dwFlags & (SCOPE_FLAG_MASK));
  785. pct = pct->pctNextSibling;
  786. }
  787. }
  788. /////////////////////////////////////////////////////////////////////////////////////////////////
  789. //////////////////////////// DEBUG OUTPUT////////////////////////////////////////////////////////
  790. /////////////////////////////////////////////////////////////////////////////////////////////////
  791. #ifdef DEBUG
  792. /*
  793. ** DBOP to string map. Used to dump name rather than op # in OLE-DB tree nodes
  794. ** This map should be kept consistent with the OLE-DB op definitions since there
  795. ** is a one to one mapping.
  796. */
  797. LPSTR mpoplpstr[] = {
  798. "DBOP_scalar_constant",
  799. "DBOP_DEFAULT",
  800. "DBOP_NULL",
  801. "DBOP_bookmark_name",
  802. "DBOP_catalog_name",
  803. "DBOP_column_name",
  804. "DBOP_schema_name",
  805. "DBOP_outall_name",
  806. "DBOP_qualifier_name",
  807. "DBOP_qualified_column_name",
  808. "DBOP_table_name",
  809. "DBOP_nested_table_name",
  810. "DBOP_nested_column_name",
  811. "DBOP_row",
  812. "DBOP_table",
  813. "DBOP_sort",
  814. "DBOP_distinct",
  815. "DBOP_distinct_order_preserving",
  816. "DBOP_alias",
  817. "DBOP_cross_join",
  818. "DBOP_union_join",
  819. "DBOP_inner_join",
  820. "DBOP_left_semi_join",
  821. "DBOP_right_semi_join",
  822. "DBOP_left_anti_semi_join",
  823. "DBOP_right_anti_semi_join",
  824. "DBOP_left_outer_join",
  825. "DBOP_right_outer_join",
  826. "DBOP_full_outer_join",
  827. "DBOP_natural_join",
  828. "DBOP_natural_left_outer_join",
  829. "DBOP_natural_right_outer_join",
  830. "DBOP_natural_full_outer_join",
  831. "DBOP_set_intersection",
  832. "DBOP_set_union",
  833. "DBOP_set_left_difference",
  834. "DBOP_set_right_difference",
  835. "DBOP_set_anti_difference",
  836. "DBOP_bag_intersection",
  837. "DBOP_bag_union",
  838. "DBOP_bag_left_difference",
  839. "DBOP_bag_right_difference",
  840. "DBOP_bag_anti_difference",
  841. "DBOP_division",
  842. "DBOP_relative_sampling",
  843. "DBOP_absolute_sampling",
  844. "DBOP_transitive_closure",
  845. "DBOP_recursive_union",
  846. "DBOP_aggregate",
  847. "DBOP_remote_table",
  848. "DBOP_select",
  849. "DBOP_order_preserving_select",
  850. "DBOP_project",
  851. "DBOP_project_order_preserving",
  852. "DBOP_top",
  853. "DBOP_top_percent",
  854. "DBOP_top_plus_ties",
  855. "DBOP_top_percent_plus_ties",
  856. "DBOP_rank",
  857. "DBOP_rank_ties_equally",
  858. "DBOP_rank_ties_equally_and_skip",
  859. "DBOP_navigate",
  860. "DBOP_nesting",
  861. "DBOP_unnesting",
  862. "DBOP_nested_apply",
  863. "DBOP_cross_tab",
  864. "DBOP_is_NULL",
  865. "DBOP_is_NOT_NULL",
  866. "DBOP_equal",
  867. "DBOP_not_equal",
  868. "DBOP_less",
  869. "DBOP_less_equal",
  870. "DBOP_greater",
  871. "DBOP_greater_equal",
  872. "DBOP_equal_all",
  873. "DBOP_not_equal_all",
  874. "DBOP_less_all",
  875. "DBOP_less_equal_all",
  876. "DBOP_greater_all",
  877. "DBOP_greater_equal_all",
  878. "DBOP_equal_any",
  879. "DBOP_not_equal_any",
  880. "DBOP_less_any",
  881. "DBOP_less_equal_any",
  882. "DBOP_greater_any",
  883. "DBOP_greater_equal_any",
  884. "DBOP_anybits",
  885. "DBOP_allbits",
  886. "DBOP_anybits_any",
  887. "DBOP_allbits_any",
  888. "DBOP_anybits_all",
  889. "DBOP_allbits_all",
  890. "DBOP_between",
  891. "DBOP_between_unordered",
  892. "DBOP_match",
  893. "DBOP_match_unique",
  894. "DBOP_match_partial",
  895. "DBOP_match_partial_unique",
  896. "DBOP_match_full",
  897. "DBOP_match_full_unique",
  898. "DBOP_scalar_parameter",
  899. "DBOP_scalar_function",
  900. "DBOP_plus",
  901. "DBOP_minus",
  902. "DBOP_times",
  903. "DBOP_over",
  904. "DBOP_div",
  905. "DBOP_modulo",
  906. "DBOP_power",
  907. "DBOP_like",
  908. "DBOP_sounds_like",
  909. "DBOP_like_any",
  910. "DBOP_like_all",
  911. "DBOP_is_INVALID",
  912. "DBOP_is_TRUE",
  913. "DBOP_is_FALSE",
  914. "DBOP_and",
  915. "DBOP_or",
  916. "DBOP_xor",
  917. "DBOP_equivalent",
  918. "DBOP_not",
  919. "DBOP_implies",
  920. "DBOP_overlaps",
  921. "DBOP_case_condition",
  922. "DBOP_case_value",
  923. "DBOP_nullif",
  924. "DBOP_cast",
  925. "DBOP_coalesce",
  926. "DBOP_position",
  927. "DBOP_extract",
  928. "DBOP_char_length",
  929. "DBOP_octet_length",
  930. "DBOP_bit_length",
  931. "DBOP_substring",
  932. "DBOP_upper",
  933. "DBOP_lower",
  934. "DBOP_trim",
  935. "DBOP_translate",
  936. "DBOP_convert",
  937. "DBOP_string_concat",
  938. "DBOP_current_date",
  939. "DBOP_current_time",
  940. "DBOP_current_timestamp",
  941. "DBOP_content_select",
  942. "DBOP_content",
  943. "DBOP_content_freetext",
  944. "DBOP_content_proximity",
  945. "DBOP_content_vector_or",
  946. "DBOP_delete",
  947. "DBOP_update",
  948. "DBOP_insert",
  949. "DBOP_min",
  950. "DBOP_max",
  951. "DBOP_count",
  952. "DBOP_sum",
  953. "DBOP_avg",
  954. "DBOP_any_sample",
  955. "DBOP_stddev",
  956. "DBOP_stddev_pop",
  957. "DBOP_var",
  958. "DBOP_var_pop",
  959. "DBOP_first",
  960. "DBOP_last",
  961. "DBOP_in",
  962. "DBOP_exists",
  963. "DBOP_unique",
  964. "DBOP_subset",
  965. "DBOP_proper_subset",
  966. "DBOP_superset",
  967. "DBOP_proper_superset",
  968. "DBOP_disjoint",
  969. "DBOP_pass_through",
  970. "DBOP_defined_by_GUID",
  971. "DBOP_text_command",
  972. "DBOP_SQL_select",
  973. "DBOP_prior_command_tree",
  974. "DBOP_add_columns",
  975. "DBOP_column_list_anchor",
  976. "DBOP_column_list_element",
  977. "DBOP_command_list_anchor",
  978. "DBOP_command_list_element",
  979. "DBOP_from_list_anchor",
  980. "DBOP_from_list_element",
  981. "DBOP_project_list_anchor",
  982. "DBOP_project_list_element",
  983. "DBOP_row_list_anchor",
  984. "DBOP_row_list_element",
  985. "DBOP_scalar_list_anchor",
  986. "DBOP_scalar_list_element",
  987. "DBOP_set_list_anchor",
  988. "DBOP_set_list_element",
  989. "DBOP_sort_list_anchor",
  990. "DBOP_sort_list_element",
  991. "DBOP_alter_character_set",
  992. "DBOP_alter_collation",
  993. "DBOP_alter_domain",
  994. "DBOP_alter_index",
  995. "DBOP_alter_procedure",
  996. "DBOP_alter_schema",
  997. "DBOP_alter_table",
  998. "DBOP_alter_trigger",
  999. "DBOP_alter_view",
  1000. "DBOP_coldef_list_anchor",
  1001. "DBOP_coldef_list_element",
  1002. "DBOP_create_assertion",
  1003. "DBOP_create_character_set",
  1004. "DBOP_create_collation",
  1005. "DBOP_create_domain",
  1006. "DBOP_create_index",
  1007. "DBOP_create_procedure",
  1008. "DBOP_create_schema",
  1009. "DBOP_create_synonym",
  1010. "DBOP_create_table",
  1011. "DBOP_create_temporary_tab",
  1012. "DBOP_create_translation",
  1013. "DBOP_create_trigger",
  1014. "DBOP_create_view",
  1015. "DBOP_drop_assertion",
  1016. "DBOP_drop_character_set",
  1017. "DBOP_drop_collation",
  1018. "DBOP_drop_domain",
  1019. "DBOP_drop_index",
  1020. "DBOP_drop_procedure",
  1021. "DBOP_drop_schema",
  1022. "DBOP_drop_synonym",
  1023. "DBOP_drop_table",
  1024. "DBOP_drop_translation",
  1025. "DBOP_drop_trigger",
  1026. "DBOP_drop_view",
  1027. "DBOP_foreign_key",
  1028. "DBOP_grant_privileges",
  1029. "DBOP_index_list_anchor",
  1030. "DBOP_index_list_element",
  1031. "DBOP_primary_key",
  1032. "DBOP_property_list_anchor",
  1033. "DBOP_property_list_element",
  1034. "DBOP_referenced_table",
  1035. "DBOP_rename_object",
  1036. "DBOP_revoke_privileges",
  1037. "DBOP_schema_authorization",
  1038. "DBOP_unique_key",
  1039. "DBOP_scope_list_anchor",
  1040. "DBOP_scope_list_element",
  1041. "DBOP_content_table",
  1042. NULL, // needed for DBOP_from_string (able to find the end of the list)
  1043. };
  1044. int indentLevel=0;
  1045. //--------------------------------------------------------------------
  1046. // @func ostream& | operator shift-left |
  1047. // Dumps the given GUID node into the given ostream.
  1048. // @rdesc ostream
  1049. ostream & operator <<
  1050. (
  1051. ostream &osOut, //@parm INOUT | ostream in which node is to be placed.
  1052. GUID guid //@parm IN | DBID node to dump.
  1053. )
  1054. {
  1055. osOut.setf(ios::hex,ios::basefield);
  1056. osOut << guid.Data1 << "-" << guid.Data2 << "-" << guid.Data3 << "-";
  1057. for (int i=0; i<8; i++)
  1058. osOut << (unsigned int)guid.Data4[i] << " ";
  1059. osOut.setf(ios::dec,ios::basefield);
  1060. return osOut;
  1061. }
  1062. //--------------------------------------------------------------------
  1063. // @func ostream& | operator shift-left |
  1064. // Dumps the given DBID node into the given ostream.
  1065. // @rdesc ostream
  1066. ostream & operator <<
  1067. (
  1068. ostream &osOut, //@parm INOUT | ostream in which node is to be placed.
  1069. VARIANT __RPC_FAR *pvarValue //@parm IN | DBID node to dump.
  1070. )
  1071. {
  1072. switch (pvarValue->vt)
  1073. {
  1074. case VT_EMPTY:
  1075. osOut << "VT_EMPTY" << endl;
  1076. break;
  1077. case VT_NULL:
  1078. osOut << "VT_NULL" << endl;
  1079. break;
  1080. case VT_UI1:
  1081. osOut << "VT_UI1 = " << pvarValue->bVal << endl;
  1082. break;
  1083. case VT_I2:
  1084. osOut << "VT_I2 = " << pvarValue->iVal << endl;
  1085. break;
  1086. case VT_UI2:
  1087. osOut << "VT_UI2 = " << pvarValue->uiVal << endl;
  1088. break;
  1089. case VT_BOOL:
  1090. if (VARIANT_TRUE == pvarValue->boolVal)
  1091. osOut << "VT_BOOL = TRUE" << endl;
  1092. else
  1093. osOut << "VT_BOOL = FALSE" << endl;
  1094. break;
  1095. case VT_I4:
  1096. osOut << "VT_I4 = " << pvarValue->lVal << endl;
  1097. break;
  1098. case VT_UI4:
  1099. osOut << "VT_UI4 = " << pvarValue->ulVal << endl;
  1100. break;
  1101. case VT_I8:
  1102. {
  1103. WCHAR pwszI8[20];
  1104. swprintf(pwszI8, L"%I64d", ((PROPVARIANT*)pvarValue)->hVal);
  1105. osOut << "VT_I8 = " << pwszI8 << endl;
  1106. }
  1107. break;
  1108. case VT_UI8:
  1109. {
  1110. WCHAR pwszUI8[20];
  1111. swprintf(pwszUI8, L"%I64u (%I64x)",
  1112. ((PROPVARIANT*)pvarValue)->uhVal,
  1113. ((PROPVARIANT*)pvarValue)->uhVal);
  1114. osOut << "VT_UI8 = " << pwszUI8 << endl;
  1115. }
  1116. break;
  1117. case VT_R4:
  1118. osOut << "VT_R4 = " << pvarValue->fltVal << endl;
  1119. break;
  1120. case VT_R8:
  1121. osOut << "VT_R8 = " << pvarValue->dblVal << endl;
  1122. break;
  1123. case VT_CY:
  1124. {
  1125. WCHAR pwszI8[20];
  1126. swprintf(pwszI8, L"%I64d", ((PROPVARIANT*)pvarValue)->cyVal);
  1127. osOut << "VT_CY = " << pwszI8 << endl;
  1128. }
  1129. break;
  1130. case VT_DATE:
  1131. {
  1132. BSTR bstrVal = NULL;
  1133. HRESULT hr = VarBstrFromDate(pvarValue->date , LOCALE_SYSTEM_DEFAULT, 0, &bstrVal);
  1134. osOut << "VT_DATE = \"" << (LPWSTR)bstrVal << "\"" << endl;
  1135. SysFreeString(bstrVal);
  1136. }
  1137. break;
  1138. case VT_CLSID:
  1139. osOut << "VT_CLSID = " << ((PROPVARIANT*)pvarValue)->puuid << " "
  1140. << *((PROPVARIANT*)pvarValue)->puuid << endl;
  1141. break;
  1142. case VT_BSTR:
  1143. osOut << "VT_BSTR = \"" << pvarValue->bstrVal << "\"" << endl;
  1144. break;
  1145. case VT_LPSTR:
  1146. osOut << "VT_LPSTR (tagDBVARIANT) = \"" << ((PROPVARIANT*)pvarValue)->pszVal << "\"" << endl;
  1147. break;
  1148. case VT_LPWSTR:
  1149. osOut << "VT_LPWSTR (tagDBVARIANT) = \"" << ((PROPVARIANT*)pvarValue)->pwszVal << "\"" << endl;
  1150. break;
  1151. case VT_FILETIME:
  1152. {
  1153. SYSTEMTIME systemTime;
  1154. FileTimeToSystemTime(&(((PROPVARIANT*)pvarValue)->filetime),&systemTime);
  1155. osOut << "VT_FILETIME (tagPROPVARIANT) = \"" << systemTime.wYear << "-" <<
  1156. systemTime.wMonth << "-" << systemTime.wDay << " " <<
  1157. systemTime.wHour << ":" << systemTime.wMinute << ":" <<
  1158. systemTime.wSecond << "." << systemTime.wMilliseconds << endl;
  1159. }
  1160. break;
  1161. case (VT_UI1|VT_VECTOR):
  1162. {
  1163. osOut << "VT_UI1|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->caub.cElems;
  1164. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->caub.cElems; i++)
  1165. osOut << " " << ((PROPVARIANT*)pvarValue)->caub.pElems[i];
  1166. osOut << endl;
  1167. }
  1168. break;
  1169. case (VT_I2|VT_VECTOR):
  1170. {
  1171. osOut << "VT_I2|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cai.cElems;
  1172. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cai.cElems; i++)
  1173. osOut << " " << ((PROPVARIANT*)pvarValue)->cai.pElems[i];
  1174. osOut << endl;
  1175. }
  1176. break;
  1177. case (VT_UI2|VT_VECTOR):
  1178. {
  1179. osOut << "VT_UI2|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->caui.cElems;
  1180. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->caui.cElems; i++)
  1181. osOut << " " << ((PROPVARIANT*)pvarValue)->caui.pElems[i];
  1182. osOut << endl;
  1183. }
  1184. break;
  1185. case (VT_BOOL|VT_VECTOR):
  1186. {
  1187. osOut << "VT_BOOL|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cabool.cElems;
  1188. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cabool.cElems; i++)
  1189. osOut << " " << ((PROPVARIANT*)pvarValue)->cabool.pElems[i];
  1190. osOut << endl;
  1191. }
  1192. break;
  1193. case (VT_I4|VT_VECTOR):
  1194. {
  1195. osOut << "VT_I4|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cal.cElems;
  1196. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cal.cElems; i++)
  1197. osOut << " " << ((PROPVARIANT*)pvarValue)->cal.pElems[i];
  1198. osOut << endl;
  1199. }
  1200. break;
  1201. case (VT_UI4|VT_VECTOR):
  1202. {
  1203. osOut << "VT_UI4|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->caul.cElems;
  1204. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->caul.cElems; i++)
  1205. osOut << " " << ((PROPVARIANT*)pvarValue)->caul.pElems[i];
  1206. osOut << endl;
  1207. }
  1208. break;
  1209. case (VT_R4|VT_VECTOR):
  1210. {
  1211. osOut << "VT_R4|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->caflt.cElems;
  1212. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->caflt.cElems; i++)
  1213. osOut << " " << ((PROPVARIANT*)pvarValue)->caflt.pElems[i];
  1214. osOut << endl;
  1215. }
  1216. break;
  1217. case (VT_ERROR|VT_VECTOR):
  1218. {
  1219. osOut << "VT_ERROR|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cascode.cElems;
  1220. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cascode.cElems; i++)
  1221. osOut << " " << ((PROPVARIANT*)pvarValue)->cascode.pElems[i];
  1222. osOut << endl;
  1223. }
  1224. break;
  1225. case (VT_I8|VT_VECTOR):
  1226. {
  1227. osOut << "VT_I8|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cah.cElems;
  1228. // for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cah.cElems; i++)
  1229. // osOut << " " << ((PROPVARIANT*)pvarValue)->cah.pElems[i];
  1230. osOut << endl;
  1231. }
  1232. break;
  1233. case (VT_UI8|VT_VECTOR):
  1234. {
  1235. osOut << "VT_UI8|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cauh.cElems;
  1236. // for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cauh.cElems; i++)
  1237. // osOut << " " << ((PROPVARIANT*)pvarValue)->cauh.pElems[i];
  1238. osOut << endl;
  1239. }
  1240. break;
  1241. case (VT_R8|VT_VECTOR):
  1242. {
  1243. osOut << "VT_R8|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cadbl.cElems;
  1244. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cadbl.cElems; i++)
  1245. osOut << " " << ((PROPVARIANT*)pvarValue)->cadbl.pElems[i];
  1246. osOut << endl;
  1247. }
  1248. break;
  1249. case (VT_CY|VT_VECTOR):
  1250. {
  1251. osOut << "VT_CY|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cacy.cElems;
  1252. // for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cacy.cElems; i++)
  1253. // osOut << " " << ((PROPVARIANT*)pvarValue)->cacy.pElems[i];
  1254. osOut << endl;
  1255. }
  1256. break;
  1257. case (VT_DATE|VT_VECTOR):
  1258. {
  1259. osOut << "VT_DATE|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cadate.cElems;
  1260. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cadate.cElems; i++)
  1261. osOut << " " << ((PROPVARIANT*)pvarValue)->cadate.pElems[i];
  1262. osOut << endl;
  1263. }
  1264. break;
  1265. case (VT_FILETIME|VT_VECTOR):
  1266. {
  1267. osOut << "VT_FILETIME|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cafiletime.cElems;
  1268. // for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cafiletime.cElems; i++)
  1269. // osOut << " " << ((PROPVARIANT*)pvarValue)->cafiletime.pElems[i];
  1270. osOut << endl;
  1271. }
  1272. break;
  1273. case (VT_CLSID|VT_VECTOR):
  1274. {
  1275. osOut << "VT_CLSID|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cauuid.cElems;
  1276. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cauuid.cElems; i++)
  1277. osOut << " " << ((PROPVARIANT*)pvarValue)->cauuid.pElems[i];
  1278. osOut << endl;
  1279. }
  1280. break;
  1281. case (VT_CF|VT_VECTOR):
  1282. {
  1283. osOut << "VT_CF|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->caclipdata.cElems;
  1284. // for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->caclipdata.cElems; i++)
  1285. // osOut << " " << ((PROPVARIANT*)pvarValue)->caclipdata.pElems[i];
  1286. osOut << endl;
  1287. }
  1288. break;
  1289. case (VT_BSTR|VT_VECTOR):
  1290. {
  1291. osOut << "VT_BSTR|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->cabstr.cElems;
  1292. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->cabstr.cElems; i++)
  1293. osOut << " " << ((PROPVARIANT*)pvarValue)->cabstr.pElems[i];
  1294. osOut << endl;
  1295. }
  1296. break;
  1297. case (VT_LPSTR|VT_VECTOR):
  1298. {
  1299. osOut << "VT_LPSTR|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->calpstr.cElems;
  1300. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->calpstr.cElems; i++)
  1301. osOut << " " << ((PROPVARIANT*)pvarValue)->calpstr.pElems[i];
  1302. osOut << endl;
  1303. }
  1304. break;
  1305. case (VT_LPWSTR|VT_VECTOR):
  1306. {
  1307. osOut << "VT_LPWSTR|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->calpwstr.cElems;
  1308. for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->calpwstr.cElems; i++)
  1309. osOut << " " << ((PROPVARIANT*)pvarValue)->calpwstr.pElems[i];
  1310. osOut << endl;
  1311. }
  1312. break;
  1313. case (VT_VARIANT|VT_VECTOR):
  1314. {
  1315. osOut << "VT_VARIANT|VT_VECTOR = " << ((PROPVARIANT*)pvarValue)->capropvar.cElems;
  1316. // for (ULONG i = 0; i<((PROPVARIANT*)pvarValue)->capropvar.cElems; i++)
  1317. // osOut << " " << ((PROPVARIANT*)pvarValue)->capropvar.pElems[i];
  1318. osOut << endl;
  1319. }
  1320. break;
  1321. default:
  1322. osOut << "type :" << pvarValue->vt << endl;
  1323. break;
  1324. }
  1325. return osOut;
  1326. }
  1327. //--------------------------------------------------------------------
  1328. // @func ostream& | operator shift-left |
  1329. // Dumps the given DBID node into the given ostream.
  1330. // @rdesc ostream
  1331. ostream & operator <<
  1332. (
  1333. ostream &osOut, //@parm INOUT | ostream in which node is to be placed.
  1334. DBID __RPC_FAR *pdbid //@parm IN | DBID node to dump.
  1335. )
  1336. {
  1337. osOut << endl;
  1338. switch (pdbid->eKind)
  1339. {
  1340. case DBKIND_NAME:
  1341. osOut << INDENTLINE << "\t\tpwszName: " << pdbid->uName.pwszName << endl;
  1342. break;
  1343. case DBKIND_GUID:
  1344. osOut << INDENTLINE << "\t\tguid: "<< pdbid->uGuid.guid << endl;
  1345. break;
  1346. case DBKIND_GUID_NAME:
  1347. osOut << INDENTLINE << "\t\tguid: "<< pdbid->uGuid.guid << endl;
  1348. osOut << INDENTLINE << "\t\tpwszName: " << pdbid->uName.pwszName << endl;
  1349. break;
  1350. case DBKIND_GUID_PROPID:
  1351. osOut << INDENTLINE << "\t\tguid: "<< pdbid->uGuid.guid << endl;
  1352. osOut << INDENTLINE << "\t\tulPropid: " << pdbid->uName.ulPropid << endl;
  1353. break;
  1354. case DBKIND_PGUID_NAME:
  1355. osOut << INDENTLINE << "\t\tpguid: "<< (void*)pdbid->uGuid.pguid << " " << *pdbid->uGuid.pguid << endl;
  1356. osOut << INDENTLINE << "\t\tpwszName: " << pdbid->uName.pwszName << endl;
  1357. break;
  1358. case DBKIND_PGUID_PROPID:
  1359. osOut << INDENTLINE << "\t\tpguid: "<< (void*)pdbid->uGuid.pguid << " " << *pdbid->uGuid.pguid << endl;
  1360. osOut << INDENTLINE << "\t\tulPropid: " << pdbid->uName.ulPropid << endl;
  1361. break;
  1362. default:
  1363. Assert(0);
  1364. }
  1365. return osOut;
  1366. }
  1367. //--------------------------------------------------------------------
  1368. // @func ostream& | operator shift-left |
  1369. // Dumps the given DBCONTENTVECTOR node into the given ostream.
  1370. // @rdesc ostream
  1371. ostream & operator <<
  1372. (
  1373. ostream &osOut, //@parm INOUT | ostream in which node is to be placed.
  1374. DBCONTENTVECTOR __RPC_FAR *pdbcntntvcValue //@parm IN | DBCONTENTVECTOR node to dump.
  1375. )
  1376. {
  1377. osOut << endl << INDENTLINE << "\t\tdwRankingMethod " << pdbcntntvcValue->dwRankingMethod;
  1378. switch(pdbcntntvcValue->dwRankingMethod)
  1379. {
  1380. case VECTOR_RANK_MIN:
  1381. osOut << " VECTOR_RANK_MIN" << endl;
  1382. break;
  1383. case VECTOR_RANK_MAX:
  1384. osOut << " VECTOR_RANK_MAX" << endl;
  1385. break;
  1386. case VECTOR_RANK_INNER:
  1387. osOut << " VECTOR_RANK_INNER" << endl;
  1388. break;
  1389. case VECTOR_RANK_DICE:
  1390. osOut << " VECTOR_RANK_DICE" << endl;
  1391. break;
  1392. case VECTOR_RANK_JACCARD:
  1393. osOut << " VECTOR_RANK_JACCARD" << endl;
  1394. break;
  1395. }
  1396. osOut << endl;
  1397. return osOut;
  1398. }
  1399. //--------------------------------------------------------------------
  1400. //@func:(DEBUG) ostream& | operator shift-left |
  1401. // Dumps the given DBCOMMANDTREE node into the given ostream.
  1402. //@rdesc ostream
  1403. //
  1404. ostream & operator <<
  1405. (
  1406. ostream &osOut, //@parm INOUT | ostream in which node is to be placed.
  1407. DBCOMMANDTREE &qt //@parm IN | OLE-DB node to dump.
  1408. )
  1409. {
  1410. DBCOMMANDTREE *pTableNodeT = NULL;
  1411. osOut << INDENTLINE << "Node" << &qt << endl;
  1412. osOut << INDENTLINE << "{" << endl;
  1413. osOut << INDENTLINE << "\tOP = " << mpoplpstr[qt.op] << " // Enum value: " << (USHORT) qt.op << endl;
  1414. // osOut << INDENTLINE << "\tError = " << qt.hrError << endl;
  1415. if (qt.pctFirstChild)
  1416. osOut << INDENTLINE << "\tpctFirstChild = " << qt.pctFirstChild << endl;
  1417. if (qt.pctNextSibling)
  1418. osOut << INDENTLINE << "\tpctNextSibling = " << qt.pctNextSibling << endl;
  1419. switch(qt.wKind)
  1420. {
  1421. case DBVALUEKIND_BYGUID:
  1422. osOut << INDENTLINE << "\twKind : BYGUID" << endl;
  1423. osOut << INDENTLINE << "\tcbInfo:" << qt.value.pdbbygdValue->cbInfo << endl;
  1424. osOut << INDENTLINE << "\tpbInfo:" << (VOID*)qt.value.pdbbygdValue->pbInfo << endl;
  1425. osOut << INDENTLINE << "\tguid:" << qt.value.pdbbygdValue->guid << endl;
  1426. break;
  1427. case DBVALUEKIND_ID:
  1428. osOut << INDENTLINE << "\twKind : ID " << qt.value.pdbidValue <<endl;
  1429. break;
  1430. case DBVALUEKIND_CONTENT:
  1431. osOut << INDENTLINE << "\twKind : CONTENT " << qt.value.pdbcntntValue <<endl;
  1432. osOut << INDENTLINE << "\t\tpwszPhrase \"" << qt.value.pdbcntntValue->pwszPhrase << "\"" << endl;
  1433. osOut << INDENTLINE << "\t\tdwGenerateMethod " << qt.value.pdbcntntValue->dwGenerateMethod;
  1434. switch(qt.value.pdbcntntValue->dwGenerateMethod)
  1435. {
  1436. case GENERATE_METHOD_EXACT:
  1437. osOut << " GENERATE_METHOD_EXACT" << endl;
  1438. break;
  1439. case GENERATE_METHOD_PREFIX:
  1440. osOut << " GENERATE_METHOD_PREFIX" << endl;
  1441. break;
  1442. case GENERATE_METHOD_INFLECT:
  1443. osOut << " GENERATE_METHOD_INFLECT" << endl;
  1444. break;
  1445. }
  1446. osOut << INDENTLINE << "\t\tlWeight " << qt.value.pdbcntntValue->lWeight << endl;
  1447. osOut << INDENTLINE << "\t\tlcid " << qt.value.pdbcntntValue->lcid << endl;
  1448. break;
  1449. case DBVALUEKIND_CONTENTSCOPE:
  1450. osOut << INDENTLINE << "\tdwFlags" << endl;
  1451. osOut << INDENTLINE << "\t\tInclude = " << (qt.value.pdbcntntscpValue->dwFlags & SCOPE_FLAG_INCLUDE) << endl;
  1452. osOut << INDENTLINE << "\t\tDeep = " << (qt.value.pdbcntntscpValue->dwFlags & SCOPE_FLAG_DEEP) << endl;
  1453. osOut << INDENTLINE << "\t\tType = " << (qt.value.pdbcntntscpValue->dwFlags & ~SCOPE_FLAG_MASK);
  1454. switch (qt.value.pdbcntntscpValue->dwFlags & ~(SCOPE_FLAG_MASK) )
  1455. {
  1456. case SCOPE_TYPE_WINPATH:
  1457. osOut << " SCOPE_TYPE_WINPATH" << endl;
  1458. break;
  1459. case SCOPE_TYPE_VPATH:
  1460. osOut << " SCOPE_TYPE_VPATH" << endl;
  1461. break;
  1462. default:
  1463. osOut << " Unknown type" << endl;
  1464. break;
  1465. }
  1466. osOut << INDENTLINE << "\tpwszElementValue = " << qt.value.pdbcntntscpValue->pwszElementValue << endl;
  1467. break;
  1468. case DBVALUEKIND_CONTENTTABLE:
  1469. osOut << INDENTLINE << "\tpwszMachine = " << qt.value.pdbcntnttblValue->pwszMachine << endl;
  1470. osOut << INDENTLINE << "\tpwszCatalog = " << qt.value.pdbcntnttblValue->pwszCatalog << endl;
  1471. break;
  1472. case DBVALUEKIND_LIKE:
  1473. osOut << INDENTLINE << "\twKind : LIKE " << qt.value.pdblikeValue << endl;
  1474. break;
  1475. case DBVALUEKIND_CONTENTPROXIMITY:
  1476. osOut << INDENTLINE << "\twKind : CONTENTPROXIMITY " << qt.value.pdbcntntproxValue << endl;
  1477. osOut << INDENTLINE << "\t\tProximityUnit: " << qt.value.pdbcntntproxValue->dwProximityUnit << endl;
  1478. osOut << INDENTLINE << "\t\tProximityDistance: " << qt.value.pdbcntntproxValue->ulProximityDistance << endl;
  1479. osOut << INDENTLINE << "\t\tlWeight: " << qt.value.pdbcntntproxValue->lWeight << endl;
  1480. break;
  1481. case DBVALUEKIND_CONTENTVECTOR:
  1482. osOut << INDENTLINE << "\twKind : CONTENTVECTOR " << qt.value.pdbcntntvcValue <<endl;
  1483. break;
  1484. case DBVALUEKIND_GROUPINFO:
  1485. osOut << INDENTLINE << "\twKind : GROUPINFO" << endl;
  1486. osOut << INDENTLINE << "\tlcid : " << (long)qt.value.pdbgrpinfValue->lcid << endl;
  1487. break;
  1488. case DBVALUEKIND_PROPERTY:
  1489. osOut << "\twKind : PROPERTY" << endl;
  1490. case DBVALUEKIND_SORTINFO:
  1491. osOut << INDENTLINE << "\twKind : sort info" << endl;
  1492. osOut << INDENTLINE << "\tlcid : " << (long)qt.value.pdbsrtinfValue->lcid << endl;
  1493. osOut << INDENTLINE << "\tsort direction : ";
  1494. if (TRUE == qt.value.pdbsrtinfValue->fDesc)
  1495. osOut << "Desc" << endl;
  1496. else
  1497. osOut << "Asc" << endl;
  1498. break;
  1499. case DBVALUEKIND_TEXT:
  1500. osOut << INDENTLINE << "//\twKind : TEXT" << endl;
  1501. osOut << INDENTLINE << "\t\t dialect guid: " << qt.value.pdbtxtValue->guidDialect << endl;
  1502. osOut << INDENTLINE << "\t\tpwszText : " << qt.value.pdbtxtValue->pwszText << endl;
  1503. break;
  1504. case DBVALUEKIND_COMMAND:
  1505. case DBVALUEKIND_MONIKER:
  1506. case DBVALUEKIND_ROWSET:
  1507. case DBVALUEKIND_IDISPATCH:
  1508. case DBVALUEKIND_IUNKNOWN:
  1509. assert(!"operator << for DBCOMMANDTREE: no COMMAND-UNKNOWN not implemented");
  1510. break;
  1511. case DBVALUEKIND_EMPTY:
  1512. osOut << INDENTLINE << "\twKind = empty" << endl;
  1513. break;
  1514. case DBVALUEKIND_NULL:
  1515. case DBVALUEKIND_I2:
  1516. osOut << INDENTLINE << "\twKind = I2" << endl;
  1517. osOut << INDENTLINE << "\t\t sValue = " << qt.value.sValue << endl;
  1518. break;
  1519. case DBVALUEKIND_I4:
  1520. osOut << INDENTLINE << "\twKind = I4" << endl;
  1521. osOut << INDENTLINE << "\t\t lValue = " << qt.value.lValue << endl;
  1522. break;
  1523. case DBVALUEKIND_R4:
  1524. osOut << INDENTLINE << "\twKind = R4" << endl;
  1525. osOut << INDENTLINE << "\t\t flValue = " << qt.value.flValue << endl;
  1526. break;
  1527. case DBVALUEKIND_R8:
  1528. osOut << INDENTLINE << "\twKind = R8" << endl;
  1529. osOut << INDENTLINE << "\t\t dblValue = " << qt.value.dblValue << endl;
  1530. break;
  1531. case DBVALUEKIND_CY:
  1532. osOut << INDENTLINE << "\twKind = CY" << endl;
  1533. assert(!"Printing Currency values not implemented");
  1534. // osOut << "\t\t cyValue = " << qt.value.cyValue << endl;
  1535. break;
  1536. case DBVALUEKIND_DATE:
  1537. osOut << INDENTLINE << "\twKind = DATE" << endl;
  1538. osOut << INDENTLINE << "\t\t dateValue = " << qt.value.dateValue << endl;
  1539. break;
  1540. case DBVALUEKIND_BSTR:
  1541. osOut << INDENTLINE << "\twKind = BSTR" << endl;
  1542. osOut << INDENTLINE << "\t\t pbstrValue = " << qt.value.pbstrValue << endl;
  1543. break;
  1544. case DBVALUEKIND_ERROR:
  1545. osOut << INDENTLINE << "\twKind = ERROR" << endl;
  1546. osOut << INDENTLINE << "\t\t scodeValue = " << qt.value.scodeValue << endl;
  1547. break;
  1548. case DBVALUEKIND_BOOL:
  1549. osOut << INDENTLINE << "\twKind = BOOL" << endl;
  1550. osOut << INDENTLINE << "\t\t fValue = " << qt.value.fValue << endl;
  1551. break;
  1552. case DBVALUEKIND_VARIANT:
  1553. osOut << INDENTLINE << "\twKind : VARIANT " << qt.value.pvarValue << endl;
  1554. break;
  1555. case DBVALUEKIND_VECTOR:
  1556. osOut << INDENTLINE << "\twKind = VECTOR" << endl;
  1557. osOut << INDENTLINE << "\t\t pdbvectorValue = " << qt.value.pdbvectorValue << endl;
  1558. break;
  1559. case DBVALUEKIND_ARRAY:
  1560. osOut << INDENTLINE << "\twKind = ARRAY" << endl;
  1561. osOut << "\t\t parrayValue = " << qt.value.parrayValue << endl;
  1562. break;
  1563. case DBVALUEKIND_BYREF:
  1564. osOut << INDENTLINE << "\twKind = BYREF" << endl;
  1565. osOut << INDENTLINE << "\t\t pvValue = " << qt.value.pvValue << endl;
  1566. break;
  1567. case DBVALUEKIND_I1:
  1568. osOut << INDENTLINE << "\twKind = I1" << endl;
  1569. osOut << INDENTLINE << "\t\t bValue = " << qt.value.schValue << endl;
  1570. break;
  1571. case DBVALUEKIND_UI1:
  1572. osOut << INDENTLINE << "\twKind = UI1" << endl;
  1573. osOut << INDENTLINE << "\t\t bValue = " << qt.value.uchValue << endl;
  1574. break;
  1575. case DBVALUEKIND_UI2:
  1576. osOut << INDENTLINE << "\twKind = UI2" << endl;
  1577. osOut << INDENTLINE << "\t\t sValue = " << qt.value.sValue << endl;
  1578. break;
  1579. case DBVALUEKIND_UI4:
  1580. osOut << INDENTLINE << "\twKind = UI4" << endl;
  1581. osOut << INDENTLINE << "\t\t ulValue = " << qt.value.ulValue << endl;
  1582. break;
  1583. case DBVALUEKIND_I8:
  1584. osOut << INDENTLINE << "\twKind = I8" << endl;
  1585. assert(!"llValue printing not supported");
  1586. break;
  1587. case DBVALUEKIND_UI8:
  1588. osOut << INDENTLINE << "\twKind = UI8" << endl;
  1589. assert(!"ullValue printing not supported");
  1590. break;
  1591. case DBVALUEKIND_GUID:
  1592. osOut << INDENTLINE << "\twKind = GUID" << endl;
  1593. osOut << INDENTLINE << "\t\t pGuid = " << qt.value.pGuid << endl;
  1594. break;
  1595. case DBVALUEKIND_BYTES:
  1596. osOut << INDENTLINE << "\twKind = BYTES" << endl;
  1597. osOut << INDENTLINE << "\t\t pbValue = " << qt.value.pbValue << endl;
  1598. break;
  1599. case DBVALUEKIND_WSTR:
  1600. osOut << INDENTLINE << "\twKind = WSTR" << endl;
  1601. osOut << INDENTLINE << "\t pwszValue = " << (void*) qt.value.pwszValue
  1602. << " : " << qt.value.pwszValue << endl;
  1603. break;
  1604. case DBVALUEKIND_NUMERIC:
  1605. osOut << INDENTLINE << "\twKind = NUMERIC" << endl;
  1606. osOut << INDENTLINE << "\t\t pdbnValue = " << qt.value.pdbnValue << endl;
  1607. break;
  1608. default :
  1609. osOut << INDENTLINE << "\twKind = UNKNOWN " << (UINT) qt.wKind << endl;
  1610. assert(FALSE);
  1611. break;
  1612. }
  1613. // short cnt;
  1614. // for (cnt = 0, pTableNodeT = qt.pctFirstChild; pTableNodeT != NULL; pTableNodeT = pTableNodeT->pctNextSibling, cnt++)
  1615. // {
  1616. // osOut << INDENTLINE << "\tinput[" << cnt << "]: " << endl;
  1617. // osOut << INDENTLINE << "\t\tchild = " << "Node" << pTableNodeT << endl;
  1618. // }
  1619. osOut << INDENTLINE << "}" << endl << endl;
  1620. indentLevel++;
  1621. for (pTableNodeT = qt.pctFirstChild; pTableNodeT != NULL; pTableNodeT = pTableNodeT->pctNextSibling)
  1622. osOut << *pTableNodeT;
  1623. indentLevel--;
  1624. return osOut;
  1625. }
  1626. #endif //DEBUG
  1627. /////////////////////////////////////////////////////////////////////////////////////////////////
  1628. //////////////////////////// DEBUG OUTPUT////////////////////////////////////////////////////////
  1629. /////////////////////////////////////////////////////////////////////////////////////////////////