188 CleanupStack::PopAndDestroy( &variant ); |
188 CleanupStack::PopAndDestroy( &variant ); |
189 return count; |
189 return count; |
190 } |
190 } |
191 |
191 |
192 // --------------------------------------------------------------------------- |
192 // --------------------------------------------------------------------------- |
193 // |
193 // |
194 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |
195 // |
195 // |
196 EXPORT_C TInt HnLiwUtils::GetStringL( |
196 EXPORT_C TInt HnLiwUtils::GetStringL( |
197 const CLiwGenericParamList& aParam, |
197 const CLiwGenericParamList& aParam, |
198 const TDesC8& aPath, |
198 const TDesC8& aPath, |
199 RBuf& aRet ) |
199 RBuf& aRet ) |
200 { |
200 { |
201 TInt ret( KErrNone ); |
201 TInt ret( KErrNone ); |
202 TLiwVariant value; |
202 TLiwVariant value; |
203 value.PushL(); |
203 value.PushL(); |
204 |
204 |
205 ret = GetVariantL( aParam, aPath, value ); |
205 ret = GetVariantL( aParam, aPath, value ); |
206 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
206 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
207 { |
207 { |
208 ret = KErrBadDescriptor; |
208 ret = KErrBadDescriptor; |
209 } |
209 } |
210 |
210 |
211 CleanupStack::PopAndDestroy( &value ); |
211 CleanupStack::PopAndDestroy( &value ); |
212 return ret; |
212 return ret; |
213 } |
213 } |
214 |
214 |
215 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
216 // |
216 // |
217 // --------------------------------------------------------------------------- |
217 // --------------------------------------------------------------------------- |
218 // |
218 // |
219 EXPORT_C TInt HnLiwUtils::GetStringL( |
219 EXPORT_C TInt HnLiwUtils::GetStringL( |
220 const CLiwGenericParamList& aParam, |
220 const CLiwGenericParamList& aParam, |
221 const TDesC8& aPath, |
221 const TDesC8& aPath, |
222 RBuf8& aRet ) |
222 RBuf8& aRet ) |
223 { |
223 { |
224 TInt ret( KErrNone ); |
224 TInt ret( KErrNone ); |
225 TLiwVariant value; |
225 TLiwVariant value; |
226 value.PushL(); |
226 value.PushL(); |
227 |
227 |
228 ret = GetVariantL( aParam, aPath, value ); |
228 ret = GetVariantL( aParam, aPath, value ); |
229 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
229 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
230 { |
230 { |
231 ret = KErrBadDescriptor; |
231 ret = KErrBadDescriptor; |
232 } |
232 } |
233 |
233 |
234 CleanupStack::PopAndDestroy( &value ); |
234 CleanupStack::PopAndDestroy( &value ); |
235 return ret; |
235 return ret; |
236 } |
236 } |
237 |
237 |
238 // --------------------------------------------------------------------------- |
238 // --------------------------------------------------------------------------- |
239 // |
239 // |
240 // --------------------------------------------------------------------------- |
240 // --------------------------------------------------------------------------- |
241 // |
241 // |
242 EXPORT_C TInt HnLiwUtils::GetStringL( const CLiwGenericParamList& aParam, |
242 EXPORT_C TInt HnLiwUtils::GetStringL( const CLiwGenericParamList& aParam, |
243 const TDesC8& aPath, TInt aPos, RBuf& aRet ) |
243 const TDesC8& aPath, TInt aPos, RBuf& aRet ) |
244 { |
244 { |
245 TInt ret( KErrNone ); |
245 TInt ret( KErrNone ); |
246 TLiwVariant value; |
246 TLiwVariant value; |
247 value.PushL(); |
247 value.PushL(); |
248 |
248 |
249 ret = GetVariantL( aParam, aPath, aPos, value ); |
249 ret = GetVariantL( aParam, aPath, aPos, value ); |
250 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
250 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
251 { |
251 { |
252 ret = KErrBadDescriptor; |
252 ret = KErrBadDescriptor; |
253 } |
253 } |
254 |
254 |
255 CleanupStack::PopAndDestroy( &value ); |
255 CleanupStack::PopAndDestroy( &value ); |
256 return ret; |
256 return ret; |
257 } |
257 } |
258 |
258 |
259 // --------------------------------------------------------------------------- |
259 // --------------------------------------------------------------------------- |
260 // |
260 // |
261 // --------------------------------------------------------------------------- |
261 // --------------------------------------------------------------------------- |
262 // |
262 // |
263 EXPORT_C TInt HnLiwUtils::GetStringL( const CLiwGenericParamList& aParam, |
263 EXPORT_C TInt HnLiwUtils::GetStringL( const CLiwGenericParamList& aParam, |
264 const TDesC8& aPath, TInt aPos, RBuf8& aRet ) |
264 const TDesC8& aPath, TInt aPos, RBuf8& aRet ) |
265 { |
265 { |
266 TInt ret( KErrNone ); |
266 TInt ret( KErrNone ); |
267 TLiwVariant value; |
267 TLiwVariant value; |
268 value.PushL(); |
268 value.PushL(); |
269 |
269 |
270 ret = GetVariantL( aParam, aPath, aPos, value ); |
270 ret = GetVariantL( aParam, aPath, aPos, value ); |
271 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
271 if ( ret == KErrNone && !VariantToStringL( value, aRet ) ) |
272 { |
272 { |
273 ret = KErrBadDescriptor; |
273 ret = KErrBadDescriptor; |
274 } |
274 } |
275 |
275 |
276 CleanupStack::PopAndDestroy( &value ); |
276 CleanupStack::PopAndDestroy( &value ); |
277 return ret; |
277 return ret; |
278 } |
278 } |
279 |
279 |
280 // --------------------------------------------------------------------------- |
280 // --------------------------------------------------------------------------- |
281 // |
281 // |
282 // --------------------------------------------------------------------------- |
282 // --------------------------------------------------------------------------- |
283 // |
283 // |
284 EXPORT_C TInt HnLiwUtils::GetInt64L( const CLiwGenericParamList& aParam, |
284 EXPORT_C TInt HnLiwUtils::GetInt64L( const CLiwGenericParamList& aParam, |
285 const TDesC8& aPath, TInt aPos, TInt64& aRet ) |
285 const TDesC8& aPath, TInt aPos, TInt64& aRet ) |
286 { |
286 { |
287 RBuf8 buf; |
287 RBuf8 buf; |
288 TInt err = HnLiwUtils::GetStringL( aParam, aPath, aPos, buf ); |
288 TInt err = HnLiwUtils::GetStringL( aParam, aPath, aPos, buf ); |
289 |
289 |
290 if ( KErrNone == err ) |
290 if ( KErrNone == err ) |
291 { |
291 { |
292 TInt64 value( KErrNotFound ); |
292 TInt64 value( KErrNotFound ); |
293 TLex8 lex( buf ); |
293 TLex8 lex( buf ); |
294 |
294 |
295 if ( KErrNone == lex.Val( value ) ) |
295 if ( KErrNone == lex.Val( value ) ) |
296 { |
296 { |
297 aRet = value; |
297 aRet = value; |
298 err = KErrNone; |
298 err = KErrNone; |
299 } |
299 } |
300 } |
300 } |
301 |
301 |
302 buf.Close(); |
302 buf.Close(); |
303 |
303 |
304 return err; |
304 return err; |
305 } |
305 } |
306 |
306 |
307 // --------------------------------------------------------------------------- |
307 // --------------------------------------------------------------------------- |
308 // |
308 // |
309 // --------------------------------------------------------------------------- |
309 // --------------------------------------------------------------------------- |
310 // |
310 // |
311 EXPORT_C TInt HnLiwUtils::GetVariantL( |
311 EXPORT_C TInt HnLiwUtils::GetVariantL( |
312 const CLiwGenericParamList& aParam, |
312 const CLiwGenericParamList& aParam, |
313 const TDesC8& aPath, |
313 const TDesC8& aPath, |
351 CleanupStack::PopAndDestroy( &path ); |
351 CleanupStack::PopAndDestroy( &path ); |
352 return ret; |
352 return ret; |
353 } |
353 } |
354 |
354 |
355 // --------------------------------------------------------------------------- |
355 // --------------------------------------------------------------------------- |
356 // |
356 // |
357 // --------------------------------------------------------------------------- |
357 // --------------------------------------------------------------------------- |
358 // |
358 // |
359 TInt HnLiwUtils::ExtractNameSpaceL( |
359 TInt HnLiwUtils::ExtractNameSpaceL( |
360 const CLiwGenericParamList& aParam, |
360 const CLiwGenericParamList& aParam, |
361 const TDesC8& aNameSpace, |
361 const TDesC8& aNameSpace, |
362 TLiwVariant& aRet ) |
362 TLiwVariant& aRet ) |
363 { |
363 { |
364 TInt pos( 0 ); |
364 TInt pos( 0 ); |
365 const TLiwGenericParam* param; |
365 const TLiwGenericParam* param; |
366 |
366 |
367 if ( &aParam != NULL ) |
367 if ( &aParam != NULL ) |
368 { |
368 { |
369 param = aParam.FindFirst( pos, aNameSpace ); |
369 param = aParam.FindFirst( pos, aNameSpace ); |
370 if ( pos >= 0 ) |
370 if ( pos >= 0 ) |
371 { |
371 { |
372 aRet.SetL( param->Value() ); |
372 aRet.SetL( param->Value() ); |
373 } |
373 } |
374 } |
374 } |
375 else |
375 else |
376 { |
376 { |
377 pos = KErrNotFound; |
377 pos = KErrNotFound; |
378 } |
378 } |
379 |
379 |
380 return pos; |
380 return pos; |
381 } |
381 } |
382 |
382 |
383 |
383 |
384 // --------------------------------------------------------------------------- |
384 // --------------------------------------------------------------------------- |
385 // |
385 // |
386 // --------------------------------------------------------------------------- |
386 // --------------------------------------------------------------------------- |
387 // |
387 // |
388 EXPORT_C TInt HnLiwUtils::GetVariantL( |
388 EXPORT_C TInt HnLiwUtils::GetVariantL( |
389 const CLiwGenericParamList& aParam, |
389 const CLiwGenericParamList& aParam, |
390 const TDesC8& aPath, |
390 const TDesC8& aPath, |
409 for ( TInt i( 1 ); i < path.Count() && found; i++ ) |
409 for ( TInt i( 1 ); i < path.Count() && found; i++ ) |
410 { |
410 { |
411 TPtrC8 name = path[ i ]; |
411 TPtrC8 name = path[ i ]; |
412 LIW::TVariantTypeId typeId = lastVariant.TypeId(); |
412 LIW::TVariantTypeId typeId = lastVariant.TypeId(); |
413 // LIW::Type ID 7 |
413 // LIW::Type ID 7 |
414 if ( typeId == LIW::EVariantTypeList ) |
414 if ( typeId == LIW::EVariantTypeList ) |
415 { |
415 { |
416 TInt pos( GetPosition( name ) ); |
416 TInt pos( GetPosition( name ) ); |
417 found = (pos != KErrNotFound) ? lastVariant.AsList()->AtL( pos, variant ) : EFalse; |
417 found = (pos != KErrNotFound) ? lastVariant.AsList()->AtL( pos, variant ) : EFalse; |
418 } |
418 } |
419 // LIW::Type ID 8 |
419 // LIW::Type ID 8 |
420 else if ( typeId == LIW::EVariantTypeMap ) |
420 else if ( typeId == LIW::EVariantTypeMap ) |
421 { |
421 { |
422 found = lastVariant.AsMap()->FindL( name, variant ); |
422 found = lastVariant.AsMap()->FindL( name, variant ); |
423 } |
423 } |
424 // LIW::Type ID 9 |
424 // LIW::Type ID 9 |
425 else if ( typeId == LIW::EVariantTypeIterable ) |
425 else if ( typeId == LIW::EVariantTypeIterable ) |
426 { |
426 { |
427 TInt pos( GetPosition( name ) ); |
427 TInt pos( GetPosition( name ) ); |
428 found = GetIterableByPositionL( *lastVariant.AsIterable(), pos, variant ); |
428 found = GetIterableByPositionL( *lastVariant.AsIterable(), pos, variant ); |
429 } |
429 } |
430 lastVariant.SetL( variant ); |
430 lastVariant.SetL( variant ); |
431 } |
431 } |
432 ret = found ? KErrNone : KErrNotFound; |
432 ret = found ? KErrNone : KErrNotFound; |
433 //aRet.SetL( ( ret != KErrNotFound ) ? variant : TLiwVariant( aPath ) ); |
433 //aRet.SetL( ( ret != KErrNotFound ) ? variant : TLiwVariant( aPath ) ); |
434 if ( found == 0 ) |
434 if ( found == 0 ) |
435 { |
435 { |
436 aRet.SetL( TLiwVariant( KNullDesC8 ) ); |
436 aRet.SetL( TLiwVariant( KNullDesC8 ) ); |
437 } |
437 } |
438 else |
438 else |
439 { |
439 { |
440 aRet.SetL( variant ); |
440 aRet.SetL( variant ); |
441 } |
441 } |
442 } |
442 } |
443 |
443 |
444 CleanupStack::PopAndDestroy( &lastVariant ); |
444 CleanupStack::PopAndDestroy( &lastVariant ); |
445 CleanupStack::PopAndDestroy( &variant ); |
445 CleanupStack::PopAndDestroy( &variant ); |
446 CleanupStack::PopAndDestroy( &path ); |
446 CleanupStack::PopAndDestroy( &path ); |
447 return ret; |
447 return ret; |
448 } |
448 } |
449 |
449 |
450 // --------------------------------------------------------------------------- |
450 // --------------------------------------------------------------------------- |
451 // |
451 // |
452 // --------------------------------------------------------------------------- |
452 // --------------------------------------------------------------------------- |
453 // |
453 // |
454 void HnLiwUtils::ParsePathL( |
454 void HnLiwUtils::ParsePathL( |
455 const TDesC8& aPath, |
455 const TDesC8& aPath, |
456 RArray< TPtrC8 >& aPathParts ) |
456 RArray< TPtrC8 >& aPathParts ) |
457 { |
457 { |
458 TChar ch; // token separator |
458 TChar ch; // token separator |
459 |
|
460 TInt colonPos = aPath.Find( KColon8 ); |
459 TInt colonPos = aPath.Find( KColon8 ); |
461 |
460 |
462 if ( colonPos > 0 ) |
461 if ( colonPos > 0 ) |
463 { |
462 { |
464 TLex8 lex( aPath ); |
463 TLex8 lex( aPath ); |