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.

137 lines
3.5 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. WMIParser_InstanceNameItem.cpp
  5. Abstract:
  6. This file contains the implementation of the WMIParser::InstanceNameItem class,
  7. which is used to hold the data of a key inside a CIM schema.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 10/03/99
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. WMIParser::InstanceNameItem::InstanceNameItem()
  14. {
  15. __HCP_FUNC_ENTRY( "WMIParser::InstanceNameItem::InstanceNameItem" );
  16. // MPC::wstring m_szValue;
  17. m_wmipvrValue = NULL; // ValueReference* m_wmipvrValue;
  18. }
  19. WMIParser::InstanceNameItem::InstanceNameItem( /*[in]*/ const InstanceNameItem& wmipini )
  20. {
  21. __HCP_FUNC_ENTRY( "WMIParser::InstanceNameItem::InstanceNameItem" );
  22. m_szValue = wmipini.m_szValue; // MPC::wstring m_szValue;
  23. m_wmipvrValue = wmipini.m_wmipvrValue; // ValueReference* m_wmipvrValue;
  24. //
  25. // The copy constructor actually transfers ownership of the ValueReference object!!!
  26. //
  27. InstanceNameItem* wmipini2 = const_cast<InstanceNameItem*>(&wmipini);
  28. wmipini2->m_wmipvrValue = NULL;
  29. }
  30. WMIParser::InstanceNameItem::~InstanceNameItem()
  31. {
  32. __HCP_FUNC_ENTRY( "WMIParser::InstanceNameItem::~InstanceNameItem" );
  33. delete m_wmipvrValue; m_wmipvrValue = NULL;
  34. }
  35. WMIParser::InstanceNameItem& WMIParser::InstanceNameItem::operator=( /*[in]*/ const InstanceNameItem& wmipini )
  36. {
  37. __HCP_FUNC_ENTRY( "WMIParser::InstanceNameItem::InstanceNameItem" );
  38. if(m_wmipvrValue)
  39. {
  40. delete m_wmipvrValue;
  41. }
  42. m_szValue = wmipini.m_szValue; // MPC::wstring m_szValue;
  43. m_wmipvrValue = wmipini.m_wmipvrValue; // ValueReference* m_wmipvrValue;
  44. //
  45. // The assignment actually transfers ownership of the ValueReference object!!!
  46. //
  47. InstanceNameItem* wmipini2 = const_cast<InstanceNameItem*>(&wmipini);
  48. wmipini2->m_wmipvrValue = NULL;
  49. return *this;
  50. }
  51. bool WMIParser::InstanceNameItem::operator==( /*[in]*/ InstanceNameItem const &wmipini ) const
  52. {
  53. __HCP_FUNC_ENTRY( "WMIParser::InstanceNameItem::operator==" );
  54. MPC::NocaseCompare cmp;
  55. bool fRes = false;
  56. if(cmp( m_szValue, wmipini.m_szValue ) == true)
  57. {
  58. bool leftBinary = ( m_wmipvrValue != NULL);
  59. bool rightBinary = (wmipini.m_wmipvrValue != NULL);
  60. // If the two values are of the same kind of data, then they are comparable.
  61. if(leftBinary == rightBinary)
  62. {
  63. if(leftBinary)
  64. {
  65. fRes = ((*m_wmipvrValue) == (*wmipini.m_wmipvrValue));
  66. }
  67. else
  68. {
  69. fRes = true;
  70. }
  71. }
  72. }
  73. __HCP_FUNC_EXIT(fRes);
  74. }
  75. bool WMIParser::InstanceNameItem::operator<( /*[in]*/ InstanceNameItem const &wmipini ) const
  76. {
  77. __HCP_FUNC_ENTRY( "WMIParser::InstanceNameItem::operator<" );
  78. MPC::NocaseLess less;
  79. bool fRes = false;
  80. if(less( m_szValue, wmipini.m_szValue ) == true)
  81. {
  82. fRes = true;
  83. }
  84. else if(less( wmipini.m_szValue, m_szValue ) == false) // It means that the two szValue are the same...
  85. {
  86. bool leftBinary = ( m_wmipvrValue != NULL);
  87. bool rightBinary = (wmipini.m_wmipvrValue != NULL);
  88. if(leftBinary != rightBinary)
  89. {
  90. // Different kind of data, assume that NULL is less NOT NULL
  91. fRes = rightBinary;
  92. }
  93. else
  94. {
  95. if(leftBinary)
  96. {
  97. fRes = (*m_wmipvrValue) < (*wmipini.m_wmipvrValue);
  98. }
  99. }
  100. }
  101. __HCP_FUNC_EXIT(fRes);
  102. }