metadataengine/client/src/mdeobjectdef.cpp
changeset 1 acef663c1218
parent 0 c53acadfccc6
child 3 6752808b2036
equal deleted inserted replaced
0:c53acadfccc6 1:acef663c1218
    57     iPropertyDefs.ReserveL( propertyCount );
    57     iPropertyDefs.ReserveL( propertyCount );
    58     for ( TUint32 i = 0; i < propertyCount; ++i )
    58     for ( TUint32 i = 0; i < propertyCount; ++i )
    59         {
    59         {
    60 		aSchemaBuffer.PositionL( propertyOffset + i * sizeof(TMdCPropertyDef) );
    60 		aSchemaBuffer.PositionL( propertyOffset + i * sizeof(TMdCPropertyDef) );
    61 		const TMdCPropertyDef& propertyDef = TMdCPropertyDef::GetFromBufferL(aSchemaBuffer);
    61 		const TMdCPropertyDef& propertyDef = TMdCPropertyDef::GetFromBufferL(aSchemaBuffer);
    62 		iPropertyDefs.AppendL( CMdEPropertyDef::NewL( propertyDef, aSchemaBuffer, *this ) );
    62 		CMdEPropertyDef* propertyDefImpl = CMdEPropertyDef::NewL( propertyDef, aSchemaBuffer, *this );
       
    63 		iPropertyDefs.InsertInOrder( propertyDefImpl, TLinearOrder<CMdEPropertyDef>(CMdEObjectDef::CompareProperties) );
    63         }
    64         }
    64     }
    65     }
    65 
    66 
    66 CMdEObjectDef::~CMdEObjectDef()
    67 CMdEObjectDef::~CMdEObjectDef()
    67     {
    68     {
   127 		}
   128 		}
   128 	return *propertyDef;
   129 	return *propertyDef;
   129 	}
   130 	}
   130 
   131 
   131 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL( const TDesC& aName, CMdEObjectDef* aChild )
   132 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL( const TDesC& aName, CMdEObjectDef* aChild )
   132     {
   133     {    
   133     const TInt propertyDefCount = iPropertyDefs.Count();
   134     const TInt propertyDefCount = iPropertyDefs.Count();
   134     for ( TInt i = 0; i < propertyDefCount; ++i )
   135     for ( TInt i = 0; i < propertyDefCount; ++i )
   135         {
   136         {
   136         if( aName.Compare( iPropertyDefs[i]->Name() ) == 0 )
   137         if( aName.Compare( iPropertyDefs[i]->Name() ) == 0 )
   137         	{
   138         	{
   154     return NULL;
   155     return NULL;
   155     }
   156     }
   156 
   157 
   157 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL(TDefId aId, CMdEObjectDef* aChild)
   158 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL(TDefId aId, CMdEObjectDef* aChild)
   158     {
   159     {
   159     const TInt count = iPropertyDefs.Count();
   160     const TInt i = iPropertyDefs.FindInOrder(aId, CMdEObjectDef::CompareProperties );
   160     
   161     
   161     for ( TInt i = 0; i < count; ++i )
   162     if (i >= 0 && i < iPropertyDefs.Count() && iPropertyDefs[i] )
   162         {
   163         {
   163         CMdEPropertyDef* propDef = iPropertyDefs[i];
   164         return iPropertyDefs[i];
   164         
       
   165         if( propDef && propDef->Id() == aId )
       
   166         	{
       
   167         	return propDef;
       
   168         	}
       
   169         }
   165         }
   170 
   166 
   171     CMdEObjectDef* parent = ParentL();
   167     CMdEObjectDef* parent = ParentL();
   172     if ( parent ) 
   168     if ( parent ) 
   173         {
   169         {
   190 	    User::Leave( KErrArgument );
   186 	    User::Leave( KErrArgument );
   191 	    }
   187 	    }
   192 
   188 
   193 	return iPropertyDefs[aIndex];
   189 	return iPropertyDefs[aIndex];
   194 	}
   190 	}
       
   191 
       
   192 TInt CMdEObjectDef::CompareProperties( const CMdEPropertyDef& aFirst, const CMdEPropertyDef& aSecond )
       
   193     {
       
   194     return aFirst.Id() - aSecond.Id();
       
   195     }
       
   196 
       
   197 TInt CMdEObjectDef::CompareProperties( const TDefId* aFirst, const CMdEPropertyDef& aSecond )
       
   198     {
       
   199     return *aFirst - aSecond.Id();
       
   200     }
       
   201