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.

89 lines
2.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // propbag.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file declares the classes PropertyValue, Property, and PropertyBag.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/20/1998 Original version.
  16. // 03/03/1998 Changed PropertyValue to a vector.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #ifndef _PROPBAG_H_
  20. #define _PROPBAG_H_
  21. #include <map>
  22. #include <vector>
  23. ///////////////////////////////////////////////////////////////////////////////
  24. //
  25. // CLASS
  26. //
  27. // PropertyValue
  28. //
  29. // DESCRIPTION
  30. //
  31. // This class encapsulates the value portion of a multi-valued property.
  32. //
  33. ///////////////////////////////////////////////////////////////////////////////
  34. class PropertyValue : public std::vector<_variant_t>
  35. {
  36. public:
  37. //////////
  38. // Various constructors.
  39. //////////
  40. PropertyValue() { }
  41. PropertyValue(const VARIANT* v);
  42. PropertyValue(const PropertyValue& val) : _Myt(val) { }
  43. // Append a new value to the existing values.
  44. void append(const VARIANT* v);
  45. // Get all the values.
  46. void get(VARIANT* v) const;
  47. // Replace all the values.
  48. void update(const VARIANT* v)
  49. {
  50. swap(PropertyValue(v));
  51. }
  52. };
  53. ///////////////////////////////////////////////////////////////////////////////
  54. //
  55. // CLASS
  56. //
  57. // PropertyBag
  58. //
  59. // DESCRIPTION
  60. //
  61. // This class implements a generic property bag consisting of (name, value)
  62. // pairs. It has a special feature in that it supports multi-valued
  63. // attributes. These are put/get as a SafeArray of VARIANT's.
  64. //
  65. ///////////////////////////////////////////////////////////////////////////////
  66. class PropertyBag : public std::map<_bstr_t, PropertyValue>
  67. {
  68. public:
  69. using _Myt::insert;
  70. void appendValue(const _bstr_t& name, const VARIANT* value);
  71. bool getValue(const _bstr_t& name, VARIANT* value) const;
  72. void updateValue(const _bstr_t& name, const VARIANT* value);
  73. };
  74. typedef PropertyBag::value_type Property;
  75. #endif // _PROPBAG_H_