|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "httpheaderiter.h" |
|
17 #include "cheaders.h" |
|
18 #include "cheaderfield.h" |
|
19 #include "httpclientutils.h" |
|
20 |
|
21 // This class needs to be optimized. |
|
22 EXPORT_C THttpHeaderParamIterator THttpHeaderParamIterator::operator++ (TInt) |
|
23 { |
|
24 THttpHeaderParamIterator it(iParameterArray, iPostIdx); |
|
25 if(iParameterArray && iPostIdx < iParameterArray->Count()) |
|
26 { |
|
27 ++iPostIdx; |
|
28 } |
|
29 return it; |
|
30 } |
|
31 |
|
32 EXPORT_C THttpHeaderParamIterator& THttpHeaderParamIterator::operator++ () |
|
33 { |
|
34 if(iParameterArray && iPostIdx < iParameterArray->Count()) |
|
35 { |
|
36 ++iPostIdx; |
|
37 } |
|
38 return *this; |
|
39 } |
|
40 |
|
41 EXPORT_C TBool THttpHeaderParamIterator::AtEnd() const |
|
42 { |
|
43 return (!iParameterArray || iPostIdx >= iParameterArray->Count()); |
|
44 } |
|
45 |
|
46 EXPORT_C const TDesC8& THttpHeaderParamIterator::Name() const |
|
47 { |
|
48 if(iParameterArray && iPostIdx < iParameterArray->Count()) |
|
49 { |
|
50 return (*iParameterArray)[iPostIdx]->Name().DesC(); |
|
51 } |
|
52 return KNullDesC8(); |
|
53 } |
|
54 |
|
55 EXPORT_C THttpHeaderValueVariant THttpHeaderParamIterator::Value() const |
|
56 { |
|
57 if(iParameterArray && iPostIdx < iParameterArray->Count()) |
|
58 { |
|
59 return HttpClientUtils::CopyHttpHdrVal((*iParameterArray)[iPostIdx]->Value()); |
|
60 } |
|
61 return THttpHeaderValueVariant(); |
|
62 } |
|
63 |
|
64 EXPORT_C THttpHeaderParamIterator::THttpHeaderParamIterator() |
|
65 : iParameterArray(NULL), |
|
66 iPostIdx(0) |
|
67 { |
|
68 } |
|
69 |
|
70 EXPORT_C THttpHeaderParamIterator::THttpHeaderParamIterator(const RPointerArray<CHeaderFieldParam>* aArray, TInt aIndex /* = 0 */) |
|
71 : iParameterArray(aArray), |
|
72 iPostIdx(aIndex) |
|
73 { |
|
74 |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 EXPORT_C THttpHeaderElementIterator THttpHeaderElementIterator::operator++ (TInt) |
|
79 { |
|
80 THttpHeaderElementIterator it(iElementArray, iPostIdx); |
|
81 if(iElementArray && iPostIdx < iElementArray->Count()) |
|
82 { |
|
83 ++iPostIdx; |
|
84 } |
|
85 return it; |
|
86 } |
|
87 |
|
88 EXPORT_C THttpHeaderElementIterator& THttpHeaderElementIterator::operator++ () |
|
89 { |
|
90 if(iElementArray && iPostIdx < iElementArray->Count()) |
|
91 { |
|
92 ++iPostIdx; |
|
93 } |
|
94 return *this; |
|
95 } |
|
96 |
|
97 EXPORT_C TBool THttpHeaderElementIterator::AtEnd() const |
|
98 { |
|
99 return (!iElementArray || iPostIdx >= iElementArray->Count()); |
|
100 } |
|
101 |
|
102 EXPORT_C THttpHeaderValueVariant THttpHeaderElementIterator::Value() const |
|
103 { |
|
104 if(iElementArray && iPostIdx < iElementArray->Count()) |
|
105 { |
|
106 return HttpClientUtils::CopyHttpHdrVal((*iElementArray)[iPostIdx]->Value()); |
|
107 } |
|
108 return THttpHeaderValueVariant(); |
|
109 } |
|
110 |
|
111 EXPORT_C THttpHeaderParamIterator THttpHeaderElementIterator::Parameter() const |
|
112 { |
|
113 if(iElementArray == NULL) |
|
114 return THttpHeaderParamIterator(); |
|
115 return THttpHeaderParamIterator(&(*iElementArray)[iPostIdx]->iParams); |
|
116 } |
|
117 |
|
118 EXPORT_C THttpHeaderElementIterator::THttpHeaderElementIterator() |
|
119 : iElementArray(NULL), |
|
120 iPostIdx(0) |
|
121 { |
|
122 |
|
123 } |
|
124 |
|
125 EXPORT_C THttpHeaderElementIterator::THttpHeaderElementIterator(const RPointerArray<CHeaderFieldPart>* aArray, TInt aIndex /* = 0 */) |
|
126 : iElementArray(aArray), |
|
127 iPostIdx(aIndex) |
|
128 { |
|
129 |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------- |
|
133 EXPORT_C THttpHeaderIterator THttpHeaderIterator::operator++ (TInt) |
|
134 { |
|
135 THttpHeaderIterator it(iHttpHeaders, iPostIdx); |
|
136 if(iHttpHeaders && iPostIdx < iHttpHeaders->iFields.Count()) |
|
137 { |
|
138 ++iPostIdx; |
|
139 } |
|
140 return it; |
|
141 } |
|
142 |
|
143 EXPORT_C THttpHeaderIterator& THttpHeaderIterator::operator++ () |
|
144 { |
|
145 if(iHttpHeaders && iPostIdx < iHttpHeaders->iFields.Count()) |
|
146 { |
|
147 ++iPostIdx; |
|
148 } |
|
149 return *this; |
|
150 } |
|
151 |
|
152 EXPORT_C TBool THttpHeaderIterator::AtEnd() const |
|
153 { |
|
154 return (!iHttpHeaders || iPostIdx >= iHttpHeaders->iFields.Count()); |
|
155 } |
|
156 |
|
157 EXPORT_C const TDesC8& THttpHeaderIterator::Name() const |
|
158 { |
|
159 if(iHttpHeaders && iPostIdx < iHttpHeaders->iFields.Count()) |
|
160 { |
|
161 return iHttpHeaders->iFields[iPostIdx].iFieldName.DesC(); |
|
162 } |
|
163 return KNullDesC8(); |
|
164 } |
|
165 |
|
166 EXPORT_C THttpHeaderElementIterator THttpHeaderIterator::Elements() const |
|
167 { |
|
168 if(iHttpHeaders) |
|
169 THttpHeaderElementIterator(); |
|
170 |
|
171 return THttpHeaderElementIterator(&iHttpHeaders->iFields[iPostIdx].iField->iElementArray); |
|
172 } |
|
173 |
|
174 EXPORT_C THttpHeaderParamIterator THttpHeaderIterator::Parameters() const |
|
175 { |
|
176 if(iHttpHeaders) |
|
177 THttpHeaderParamIterator(); |
|
178 |
|
179 return THttpHeaderParamIterator(&iHttpHeaders->iFields[iPostIdx].iField->iParameterArray); |
|
180 } |
|
181 |
|
182 EXPORT_C THttpHeaderIterator::THttpHeaderIterator() |
|
183 : iHttpHeaders(NULL), |
|
184 iPostIdx(0) |
|
185 { |
|
186 |
|
187 } |
|
188 |
|
189 EXPORT_C THttpHeaderIterator::THttpHeaderIterator(const CHeaders* aHeaders, TInt aIndex /* = 0 */) |
|
190 : iHttpHeaders(aHeaders), |
|
191 iPostIdx(aIndex) |
|
192 { |
|
193 |
|
194 } |
|
195 |