blob: 0616db3f8968a2e307e9a69861923dddfd47ce00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
// ============================================================
//
// PropertyMap.hpp
//
//
// Defines the PropertyMap class
//
// ============================================================
#ifndef __BINDER__PROPERTY_HASH_TRAITS_HPP__
#define __BINDER__PROPERTY_HASH_TRAITS_HPP__
#include "bindertypes.hpp"
#include "sstring.h"
#include "shash.h"
namespace BINDER_SPACE
{
class PropertyEntry
{
public:
inline PropertyEntry()
{
m_pPropertyName = NULL;
m_pPropertyValue = NULL;
}
inline ~PropertyEntry()
{
SAFE_DELETE(m_pPropertyName);
SAFE_DELETE(m_pPropertyValue);
}
// Getters/Setters
inline SString *GetPropertyName()
{
return m_pPropertyName;
}
inline void SetPropertyName(SString *pPropertyName)
{
SAFE_DELETE(m_pPropertyName);
m_pPropertyName = pPropertyName;
}
inline SBuffer *GetPropertyValue()
{
return m_pPropertyValue;
}
inline void SetPropertyValue(SBuffer *pPropertyValue)
{
SAFE_DELETE(m_pPropertyValue);
m_pPropertyValue = pPropertyValue;
}
protected:
SString *m_pPropertyName;
SBuffer *m_pPropertyValue;
};
class PropertyHashTraits : public DefaultSHashTraits<PropertyEntry *>
{
public:
typedef SString* key_t;
// GetKey, Equals, and Hash can throw due to SString
static const bool s_NoThrow = false;
static key_t GetKey(element_t pPropertyEntry)
{
return pPropertyEntry->GetPropertyName();
}
static BOOL Equals(key_t pPropertyName1, key_t pPropertyName2)
{
return pPropertyName1->Equals(*pPropertyName2);
}
static count_t Hash(key_t pPropertyName)
{
return pPropertyName->Hash();
}
static const element_t Null()
{
return NULL;
}
static bool IsNull(const element_t &propertyEntry)
{
return (propertyEntry == NULL);
}
};
};
#endif
|