1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 // ============================================================
11 // Defines the PropertyMap class
13 // ============================================================
15 #ifndef __BINDER__PROPERTY_HASH_TRAITS_HPP__
16 #define __BINDER__PROPERTY_HASH_TRAITS_HPP__
18 #include "bindertypes.hpp"
22 namespace BINDER_SPACE
27 inline PropertyEntry()
29 m_pPropertyName = NULL;
30 m_pPropertyValue = NULL;
32 inline ~PropertyEntry()
34 SAFE_DELETE(m_pPropertyName);
35 SAFE_DELETE(m_pPropertyValue);
39 inline SString *GetPropertyName()
41 return m_pPropertyName;
43 inline void SetPropertyName(SString *pPropertyName)
45 SAFE_DELETE(m_pPropertyName);
46 m_pPropertyName = pPropertyName;
48 inline SBuffer *GetPropertyValue()
50 return m_pPropertyValue;
52 inline void SetPropertyValue(SBuffer *pPropertyValue)
54 SAFE_DELETE(m_pPropertyValue);
55 m_pPropertyValue = pPropertyValue;
59 SString *m_pPropertyName;
60 SBuffer *m_pPropertyValue;
63 class PropertyHashTraits : public DefaultSHashTraits<PropertyEntry *>
66 typedef SString* key_t;
68 // GetKey, Equals, and Hash can throw due to SString
69 static const bool s_NoThrow = false;
71 static key_t GetKey(element_t pPropertyEntry)
73 return pPropertyEntry->GetPropertyName();
75 static BOOL Equals(key_t pPropertyName1, key_t pPropertyName2)
77 return pPropertyName1->Equals(*pPropertyName2);
79 static count_t Hash(key_t pPropertyName)
81 return pPropertyName->Hash();
83 static element_t Null()
87 static bool IsNull(const element_t &propertyEntry)
89 return (propertyEntry == NULL);