|
1 /** @file |
|
2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Content Directory |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "upnpmapbase.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CUpnpMapBase::CUpnpMapBase |
|
25 // C++ default constructor can NOT contain any code, that |
|
26 // might leave. |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 CUpnpMapBase::CUpnpMapBase() |
|
30 { |
|
31 } |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CUpnpMapBase::ConstructL |
|
34 // Symbian 2nd phase constructor can leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 void CUpnpMapBase::ConstructL() |
|
38 { |
|
39 } |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CUpnpMapBase::Get |
|
42 // (other items were commented in a header). |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 TAny* CUpnpMapBase::Get(const TDesC8& aKey) |
|
46 { |
|
47 CUpnpMapElement* mapElement = iFirst; |
|
48 TAny* buf = NULL; |
|
49 while(mapElement != 0) |
|
50 { |
|
51 if(mapElement->Key() == aKey) |
|
52 { |
|
53 buf = mapElement->Value(); |
|
54 break; |
|
55 } |
|
56 mapElement = mapElement->Next(); |
|
57 } |
|
58 return buf; |
|
59 } |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CUpnpMapBase::PutL |
|
62 // (other items were commented in a header). |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CUpnpMapBase::PutL(const TDesC8& aKey, TAny* aValue) |
|
66 { |
|
67 CUpnpMapElement* newEl = CUpnpMapElement::NewL(aKey, aValue); |
|
68 newEl->SetNext(iFirst); |
|
69 iFirst = newEl; |
|
70 } |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CUpnpMapBase::Remove |
|
73 // (other items were commented in a header). |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 TAny* CUpnpMapBase::Remove(const TDesC8& aKey) |
|
77 { |
|
78 if( !iFirst ) // empty map |
|
79 { |
|
80 return NULL; |
|
81 } |
|
82 |
|
83 TAny* removed = NULL; |
|
84 |
|
85 // if first element to be removed |
|
86 if( iFirst->Key() == aKey ) |
|
87 { |
|
88 // remove first element |
|
89 removed = iFirst->Value(); |
|
90 CUpnpMapElement* next = iFirst->Next(); |
|
91 delete iFirst; |
|
92 iFirst = next; |
|
93 } |
|
94 else |
|
95 { |
|
96 CUpnpMapElement* prevElement = iFirst; |
|
97 CUpnpMapElement* element = iFirst->Next(); |
|
98 while(element != 0) |
|
99 { |
|
100 if( element->Key() == aKey ) |
|
101 { |
|
102 prevElement->SetNext( element->Next() ); |
|
103 removed = element->Value(); |
|
104 delete element; |
|
105 break; |
|
106 } |
|
107 else |
|
108 { |
|
109 prevElement = element; |
|
110 element = element->Next(); |
|
111 } |
|
112 } |
|
113 } |
|
114 return removed; |
|
115 } |
|
116 |
|
117 // End of File |