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// ============================================================
5//
6// PropertyMap.cpp
7//
8
9
10//
11// Implements the PropertyMap class
12//
13// ============================================================
14
15#include "propertymap.hpp"
16
17namespace BINDER_SPACE
18{
19 PropertyMap::PropertyMap() : SHash<PropertyHashTraits>::SHash() {
20 // Nothing to do here
21 }
22
23 PropertyMap::~PropertyMap() {
24 // Nothing to do here
25 }
26
27 HRESULT PropertyMap::Add(SString *pPropertyName,
28 SBuffer *pPropertyValue)
29 {
30 _ASSERTE(pPropertyName != NULL);
31 _ASSERTE(pPropertyValue != NULL);
32
33 HRESULT hr = S_OK;
34
35 NewHolder<PropertyEntry> pPropertyEntry;
36 SAFE_NEW(pPropertyEntry, PropertyEntry);
37
38 pPropertyEntry->SetPropertyName(pPropertyName);
39 pPropertyEntry->SetPropertyValue(pPropertyValue);
40
41 SHash<PropertyHashTraits>::Add(pPropertyEntry);
42 pPropertyEntry.SuppressRelease();
43
44 Exit:
45 return hr;
46 }
47
48 SBuffer *PropertyMap::Lookup(SString *pPropertyName)
49 {
50 _ASSERTE(pPropertyName != NULL);
51
52 SBuffer *pPropertyValue = NULL;
53 PropertyEntry *pPropertyEntry = SHash<PropertyHashTraits>::Lookup(pPropertyName);
54
55 if (pPropertyEntry != NULL)
56 {
57 pPropertyValue = pPropertyEntry->GetPropertyValue();
58 }
59
60 return pPropertyValue;
61 }
62};
63