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.

86 lines
1.7 KiB

  1. // Query.cpp: implementation of the CQuery class.
  2. //
  3. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  4. //
  5. //////////////////////////////////////////////////////////////////////
  6. #include "precomp.h"
  7. #include "ExtendQuery.h"
  8. /////////////////////////////////////////////////////////////////////////////////////////
  9. // query implementation
  10. /////////////////////////////////////////////////////////////////////////////////////////
  11. Query::Query ( DWORD dwSize ) : CStringExt ( dwSize )
  12. {
  13. }
  14. Query::Query ( LPCTSTR wsz ) : CStringExt ( wsz )
  15. {
  16. }
  17. Query::~Query ()
  18. {
  19. }
  20. /////////////////////////////////////////////////////////////////////////////////////////
  21. // query extend implementation
  22. /////////////////////////////////////////////////////////////////////////////////////////
  23. QueryExt::QueryExt ( LPCTSTR wsz, DWORD dwSize ) : CStringExt ( dwSize ),
  24. m_dwSizeConstant ( 0 ),
  25. m_wszStringConstant ( NULL )
  26. {
  27. if ( wsz )
  28. {
  29. try
  30. {
  31. DWORD dw = 0L;
  32. dw = lstrlen ( wsz );
  33. if SUCCEEDED ( Append ( 1, wsz ) )
  34. {
  35. m_dwSizeConstant = dw;
  36. m_wszStringConstant = wsz;
  37. }
  38. else
  39. {
  40. throw CHeap_Exception(CHeap_Exception::E_ALLOCATION_ERROR);
  41. }
  42. }
  43. catch ( ... )
  44. {
  45. m_dwSizeConstant = 0L;
  46. m_wszStringConstant = NULL;
  47. throw;
  48. }
  49. }
  50. }
  51. QueryExt::~QueryExt ()
  52. {
  53. m_dwSizeConstant = 0L;
  54. m_wszStringConstant = NULL;
  55. }
  56. HRESULT QueryExt::Append ( DWORD dwCount, ... )
  57. {
  58. HRESULT hr = E_FAIL;
  59. if ( dwCount )
  60. {
  61. va_list argList;
  62. va_start ( argList, dwCount );
  63. hr = AppendList ( m_dwSizeConstant, m_wszStringConstant, dwCount, argList );
  64. va_end ( argList );
  65. }
  66. else
  67. {
  68. hr = S_FALSE;
  69. }
  70. return hr;
  71. }