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.

119 lines
2.4 KiB

  1. /*
  2. *
  3. * NOTES:
  4. *
  5. * REVISIONS:
  6. * rct30Nov92 Added to system
  7. * pcy04Dec92: Tried to fix Bob's excellent code
  8. * ane11Dec92: Added copy constructor implementation
  9. * rct19Jan93: Modified constructor so it work with Pete's messed up notion
  10. * of a NULL TAttribute in the ConfigMgr...
  11. * mwh01Jun94: port for INTERACTIVE
  12. * mwh07Jun94: port for NCR
  13. * daf17May95: port for ALPHA/OSF
  14. * djs02Sep95: port for AIX 4.1
  15. */
  16. #define INCL_BASE
  17. #define INCL_NOPM
  18. #include "cdefine.h"
  19. extern "C" {
  20. #include <string.h>
  21. #if (C_OS & (C_INTERACTIVE | C_OS2 | C_ALPHAOSF)) || ((C_OS & C_AIX) && (C_AIX_VERSION & C_AIX4))
  22. # include <stdlib.h>
  23. #else
  24. # include <malloc.h>
  25. #endif
  26. }
  27. #include "tattrib.h"
  28. #if (C_OS & C_NCR)
  29. # include "incfix.h"
  30. #endif
  31. //-------------------------------------------------------------------
  32. // Constructor
  33. TAttribute::TAttribute( PCHAR anItem, PCHAR aValue)
  34. {
  35. if ( anItem != NULL )
  36. theItem = _strdup(anItem);
  37. else
  38. theItem = (PCHAR) NULL;
  39. if ( aValue != NULL )
  40. theValue = _strdup(aValue);
  41. else
  42. theValue = (PCHAR) NULL;
  43. }
  44. //-------------------------------------------------------------------
  45. // Copy Constructor
  46. TAttribute::TAttribute ( RTAttribute anAttr )
  47. {
  48. if (anAttr.theValue)
  49. theValue = _strdup (anAttr.theValue);
  50. else
  51. theValue = (PCHAR)NULL;
  52. if (anAttr.theItem)
  53. theItem = _strdup (anAttr.theItem);
  54. else
  55. theItem = (PCHAR)NULL;
  56. }
  57. //-------------------------------------------------------------------
  58. // Destructor
  59. TAttribute::~TAttribute()
  60. {
  61. if ( theItem != NULL )
  62. free(theItem);
  63. if ( theValue != NULL )
  64. free(theValue);
  65. }
  66. //-------------------------------------------------------------------
  67. // Set the value member
  68. VOID TAttribute::SetValue( PCHAR aValue )
  69. {
  70. if ( theValue != NULL )
  71. free(theValue);
  72. theValue = _strdup( aValue );
  73. }
  74. //-------------------------------------------------------------------
  75. // Comparison function
  76. INT TAttribute::Equal( RObj anObject ) const
  77. {
  78. if (!(anObject.IsA() == IsA()))
  79. return FALSE;
  80. return ( !strcmp(theItem, ((RTAttribute) anObject).GetItem()) ) &&
  81. ( !strcmp(theValue, ((RTAttribute) anObject).GetValue()) );
  82. }
  83. //-------------------------------------------------------------------
  84. INT TAttribute::ItemEqual( RObj anObject ) const
  85. {
  86. if (anObject.IsA() != IsA())
  87. return FALSE;
  88. return ( !strcmp(theItem, ((RTAttribute) anObject).GetItem()) );
  89. }