equal
deleted
inserted
replaced
345 return propCount; |
345 return propCount; |
346 } |
346 } |
347 |
347 |
348 EXPORT_C TInt CMdEObject::Property(const CMdEPropertyDef& aDef, CMdEProperty*& aProperty, TInt aStartAt) const |
348 EXPORT_C TInt CMdEObject::Property(const CMdEPropertyDef& aDef, CMdEProperty*& aProperty, TInt aStartAt) const |
349 { |
349 { |
350 if (aStartAt <= 0) |
350 const TInt count = iPropertyArray.Count(); |
|
351 |
|
352 if( aStartAt >= 0 ) |
351 { |
353 { |
352 const TInt i = iPropertyArray.FindInOrder(aDef, CMdEObject::CompareProperties ); |
354 TInt low( aStartAt ); |
353 if (i >= 0 && i < iPropertyArray.Count() && !iPropertyArray[i]->Removed()) |
355 TInt high( count ); |
|
356 |
|
357 while( low < high ) |
354 { |
358 { |
355 aProperty = iPropertyArray[i]; |
359 TInt mid( (low+high)>>1 ); |
356 return i; |
360 |
|
361 TInt compare( aDef.Compare( iPropertyArray[mid]->Def() ) ); |
|
362 if( compare == 0 ) |
|
363 { |
|
364 if( !iPropertyArray[mid]->Removed() ) |
|
365 { |
|
366 aProperty = iPropertyArray[mid]; |
|
367 return mid; |
|
368 } |
|
369 } |
|
370 else if( compare > 0 ) |
|
371 { |
|
372 low = mid + 1; |
|
373 } |
|
374 else |
|
375 { |
|
376 high = mid; |
|
377 } |
357 } |
378 } |
358 } |
379 } |
359 return KErrNotFound; |
380 return KErrNotFound; |
360 } |
381 } |
361 |
382 |
362 EXPORT_C CMdEProperty& CMdEObject::AddBoolPropertyL(CMdEPropertyDef& aDef, TBool aValue) |
383 EXPORT_C CMdEProperty& CMdEObject::AddBoolPropertyL(CMdEPropertyDef& aDef, TBool aValue) |
363 { |
384 { |
364 if( aDef.PropertyType() != EPropertyBool ) |
385 if( aDef.PropertyType() != EPropertyBool ) |
365 { |
386 { |
366 User::Leave( KErrArgument ); |
387 User::Leave( KErrArgument ); |
543 { |
564 { |
544 TInt err = iPropertyArray.InsertInOrder(&aProperty, |
565 TInt err = iPropertyArray.InsertInOrder(&aProperty, |
545 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
566 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
546 if (err == KErrAlreadyExists) |
567 if (err == KErrAlreadyExists) |
547 { |
568 { |
548 TInt f = iPropertyArray.FindInOrder(&aProperty, |
569 const TInt f = iPropertyArray.FindInOrder(&aProperty, |
549 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
570 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
550 |
571 |
551 // this must never happen |
572 // this must never happen |
552 __ASSERT_DEBUG( f >= KErrNone, User::Panic( _L("AddProperty find!"), KErrGeneral ) ); |
573 __ASSERT_DEBUG( f >= KErrNone, User::Panic( _L("AddProperty find!"), KErrGeneral ) ); |
553 |
574 |
702 |
723 |
703 // add all properties to this object, |
724 // add all properties to this object, |
704 // but don't remove yet from other object |
725 // but don't remove yet from other object |
705 for ( TInt i = 0; i < arraySize; ++i ) |
726 for ( TInt i = 0; i < arraySize; ++i ) |
706 { |
727 { |
707 TRAPD( err, iPropertyArray.AppendL( aObject.iPropertyArray[i] ) ); |
728 TInt err = iPropertyArray.InsertInOrder(aObject.iPropertyArray[i], |
708 if (err != KErrNone) |
729 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
709 { |
730 |
710 // restore this objects to original state |
731 if (err == KErrAlreadyExists) |
711 iPropertyArray.Reset(); |
732 { |
712 User::Leave( err ); |
733 const TInt f = iPropertyArray.FindInOrder(aObject.iPropertyArray[i], |
713 } |
734 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
|
735 |
|
736 if( !iPropertyArray[f]->Removed() ) |
|
737 { |
|
738 continue; |
|
739 } |
|
740 |
|
741 CMdEProperty* oldProperty = iPropertyArray[f]; |
|
742 iPropertyArray[f] = aObject.iPropertyArray[i]; |
|
743 delete oldProperty; |
|
744 } |
|
745 else if (err < KErrNone) |
|
746 { |
|
747 // restore this objects to original state |
|
748 iPropertyArray.Reset(); |
|
749 User::Leave(err); |
|
750 } |
714 } |
751 } |
715 |
752 |
716 // remove properties from other object |
753 // remove properties from other object |
717 aObject.iPropertyArray.Reset(); |
754 aObject.iPropertyArray.Reset(); |
718 |
755 |
998 { |
1035 { |
999 aBuffer.PositionL( serializedObject.iProperties.iPtr.iOffset |
1036 aBuffer.PositionL( serializedObject.iProperties.iPtr.iOffset |
1000 + i * sizeof(TMdCProperty) ); |
1037 + i * sizeof(TMdCProperty) ); |
1001 |
1038 |
1002 CMdEProperty* property = CMdEProperty::NewLC( *newObject, aBuffer ); |
1039 CMdEProperty* property = CMdEProperty::NewLC( *newObject, aBuffer ); |
1003 newObject->iPropertyArray.AppendL( property ); |
1040 TInt err = newObject->iPropertyArray.InsertInOrder(property, |
|
1041 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
|
1042 |
|
1043 if (err == KErrAlreadyExists) |
|
1044 { |
|
1045 const TInt f = newObject->iPropertyArray.FindInOrder(property, |
|
1046 TLinearOrder<CMdEProperty>(CMdEObject::CompareProperties)); |
|
1047 |
|
1048 if( !newObject->iPropertyArray[f]->Removed() ) |
|
1049 { |
|
1050 continue; |
|
1051 } |
|
1052 |
|
1053 CMdEProperty* oldProperty = newObject->iPropertyArray[f]; |
|
1054 newObject->iPropertyArray[f] = property; |
|
1055 delete oldProperty; |
|
1056 } |
|
1057 else if (err < KErrNone) |
|
1058 { |
|
1059 User::Leave(err); |
|
1060 } |
1004 CleanupStack::Pop( property ); |
1061 CleanupStack::Pop( property ); |
1005 } |
1062 } |
1006 } |
1063 } |
1007 |
1064 |
1008 // read freetext array |
1065 // read freetext array |
1026 TMdEInstanceType CMdEObject::InstanceType() const |
1083 TMdEInstanceType CMdEObject::InstanceType() const |
1027 { |
1084 { |
1028 return EMdETypeObject; |
1085 return EMdETypeObject; |
1029 } |
1086 } |
1030 |
1087 |
1031 TInt CMdEObject::CompareProperties(const CMdEPropertyDef* aPropertyDef, const CMdEProperty& aProperty) |
|
1032 { |
|
1033 return aPropertyDef->Compare( aProperty.Def() ); |
|
1034 } |
|
1035 |
|