persistentstorage/dbms/inc/D32DBAS.INL
changeset 0 08ec8eefde2f
child 26 c6f14f20ccfd
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-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 // Class TTextOps
       
    17 inline TUint TTextOps::Fold(TUint aChar) const
       
    18 	{
       
    19     return iFold(aChar);
       
    20     }
       
    21 
       
    22 inline TInt TTextOps::Match(const TDesC8& aDes,const TDesC8& aPattern) const
       
    23 	{
       
    24     return iMatch8(aDes,aPattern);
       
    25     }
       
    26 
       
    27 inline TInt TTextOps::Compare(const TText8* aLeftPtr,
       
    28                               TInt aLeftLen,
       
    29                               const TText8* aRightPtr,
       
    30                               TInt aRightLen) const
       
    31 	{
       
    32     return iCompare8(aLeftPtr,aLeftLen,aRightPtr,aRightLen);
       
    33     }
       
    34 
       
    35 inline TInt TTextOps::Match(const TDesC16& aDes,const TDesC16& aPattern) const
       
    36 	{
       
    37     return iMatch16(aDes,aPattern);
       
    38     }
       
    39 
       
    40 inline TInt TTextOps::Compare(const TText16* aLeftPtr,
       
    41                               TInt aLeftLen,
       
    42                               const TText16* aRightPtr,
       
    43                               TInt aRightLen) const
       
    44 	{
       
    45     return iCompare16(aLeftPtr,aLeftLen,aRightPtr,aRightLen);
       
    46     }
       
    47 
       
    48 /**
       
    49 The method compares aLeftPtr and aRightPtr unicode strings.
       
    50 Collation level 3 will be used. 
       
    51 @param aLeftPtr Left string to compare.
       
    52 @param aLeftLen The length of left string.
       
    53 @param aRightPtr Right string to compare.
       
    54 @param aRightLen The length of right string.
       
    55 This method is used by sorting algorithms when the key field is a unciode string.
       
    56 @return Positive. if aLeftPtr is greater than aRightPtr.
       
    57         Negative. if aLeftPtr is less than aRightPtr.
       
    58         Zero, if aLeftPtr is equal to aRightPtr.
       
    59 */
       
    60 inline TInt TTextOps::Order(const TText16* aLeftPtr, TInt aLeftLen, const TText16* aRightPtr, TInt aRightLen) const
       
    61 	{
       
    62 	return iOrder16(aLeftPtr, aLeftLen, aRightPtr, aRightLen);
       
    63 	}
       
    64 
       
    65 // Class TDbBlob
       
    66 inline TDbBlob::TDbBlob() :
       
    67 	iId(KDbNullBlobId), 
       
    68     iSize(0)
       
    69 	{
       
    70     }
       
    71 
       
    72 inline TDbBlob::TDbBlob(TDbBlobId anId,TInt aSize) :
       
    73 	iId(anId), 
       
    74     iSize(aSize)
       
    75 	{
       
    76     }
       
    77 
       
    78 inline TDbBlob::TDbBlob(const TUint8* aPtr,TInt aSize) :
       
    79 	iId(KDbNullBlobId), 
       
    80     iSize(aSize)
       
    81 	{
       
    82 	__ASSERT_DEBUG(aSize>=0&&aSize<=KDbMaxInlineBlobSize,User::Invariant());
       
    83 	Mem::Copy(iInline,aPtr,aSize);
       
    84 	}
       
    85 
       
    86 inline TUint8* TDbBlob::InlineBuffer()
       
    87 	{
       
    88 	__ASSERT_DEBUG(IsInline(),User::Invariant());
       
    89 	return iInline;
       
    90 	}
       
    91 
       
    92 inline void TDbBlob::SetId(TDbBlobId anId)
       
    93 	{
       
    94     iId=anId;
       
    95     }
       
    96 
       
    97 inline void TDbBlob::SetSize(TInt aSize)
       
    98 	{
       
    99     iSize=aSize;
       
   100     }
       
   101 
       
   102 inline TBool TDbBlob::IsInline() const
       
   103 	{
       
   104     return iId==KDbNullBlobId;
       
   105     }
       
   106 
       
   107 inline TInt TDbBlob::Size() const
       
   108 	{
       
   109     return iSize;
       
   110     }
       
   111 
       
   112 inline const TUint8* TDbBlob::Data() const
       
   113 	{
       
   114 	__ASSERT_DEBUG(IsInline(),User::Invariant());
       
   115 	return iInline;
       
   116 	}
       
   117 
       
   118 inline TPtrC8 TDbBlob::PtrC8() const
       
   119 	{
       
   120 	__ASSERT_DEBUG(IsInline(),User::Invariant());
       
   121 	return TPtrC8(iInline,iSize);
       
   122 	}
       
   123 
       
   124 inline TPtrC16 TDbBlob::PtrC16() const
       
   125 	{
       
   126 	__ASSERT_DEBUG(IsInline(),User::Invariant());
       
   127 	return TPtrC16((const TUint16*)iInline,iSize>>1);
       
   128 	}
       
   129 
       
   130 inline TDbBlobId TDbBlob::Id() const
       
   131 	{
       
   132 	__ASSERT_DEBUG(!IsInline(),User::Invariant());
       
   133 	return iId;
       
   134 	}
       
   135 
       
   136 inline TInt TDbBlob::CellSize() const
       
   137 	{
       
   138     return _FOFF(TDbBlob,iInline[IsInline() ? Size() : 0]);
       
   139     }
       
   140 
       
   141 inline TInt TDbBlob::InlineSize(TInt aSize)
       
   142 	{
       
   143     return _FOFF(TDbBlob,iInline[aSize]);
       
   144     }
       
   145 
       
   146 inline TInt TDbBlob::RefSize()
       
   147 	{
       
   148     return _FOFF(TDbBlob,iInline[0]);
       
   149     }
       
   150 
       
   151 // CLass TDbCell
       
   152 inline TInt TDbCell::Size(TInt aLength)
       
   153 	{ 
       
   154     return Align4(aLength+sizeof(TInt)); 
       
   155     }
       
   156 
       
   157 inline TInt TDbCell::Size() const
       
   158 	{
       
   159     return Size(iLength);
       
   160     }
       
   161 
       
   162 inline TInt TDbCell::Length() const
       
   163 	{
       
   164     return iLength;
       
   165     }
       
   166 
       
   167 inline const TDbCell* TDbCell::Next() const
       
   168 	{
       
   169     return PtrAdd(this,Size());
       
   170     }
       
   171 
       
   172 inline TDbCell* TDbCell::Next()
       
   173 	{
       
   174     return PtrAdd(this,Size());
       
   175     }
       
   176 
       
   177 inline TAny* TDbCell::Data()
       
   178 	{
       
   179     return iBuf;
       
   180     }
       
   181 
       
   182 inline const TAny* TDbCell::Data() const
       
   183 	{
       
   184     return iBuf;
       
   185     }
       
   186 
       
   187 inline void TDbCell::SetLength(TInt aLength)
       
   188 	{
       
   189     iLength=aLength;
       
   190     }
       
   191 
       
   192 // Class TDbColumnC
       
   193 inline TDbColumnC::TDbColumnC(const RDbRow& aRow,TDbColNo aCol) :
       
   194 	iCell(aRow.ColCell(aCol))
       
   195 	{
       
   196     }
       
   197 
       
   198 inline TInt TDbColumnC::Size() const
       
   199 	{
       
   200     return iCell->Length();
       
   201     }
       
   202 
       
   203 inline TBool TDbColumnC::IsNull() const
       
   204 	{
       
   205     return Size()==0;
       
   206     }
       
   207 
       
   208 inline TInt8 TDbColumnC::Int8() const
       
   209 	{
       
   210     return TInt8(*(const TInt32*)iCell->Data());
       
   211     }
       
   212 
       
   213 inline TInt16 TDbColumnC::Int16() const
       
   214 	{
       
   215     return TInt16(*(const TInt32*)iCell->Data());
       
   216     }
       
   217 
       
   218 inline TInt32 TDbColumnC::Int32() const
       
   219 	{
       
   220     return *(const TInt32*)iCell->Data();
       
   221     }
       
   222 
       
   223 inline const TInt64& TDbColumnC::Int64() const
       
   224 	{
       
   225     return *(const TInt64*)iCell->Data();
       
   226     }
       
   227 
       
   228 inline TUint8 TDbColumnC::Uint8() const
       
   229 	{
       
   230     return TUint8(*(const TUint8*)iCell->Data());
       
   231     }
       
   232 
       
   233 inline TUint16 TDbColumnC::Uint16() const
       
   234 	{
       
   235     return TUint16(*(const TUint32*)iCell->Data());
       
   236     }
       
   237 
       
   238 inline TUint32 TDbColumnC::Uint32() const
       
   239 	{
       
   240     return *(const TUint32*)iCell->Data();
       
   241     }
       
   242 
       
   243 inline TReal32 TDbColumnC::Real32() const
       
   244 	{
       
   245     return *(const TReal32*)iCell->Data();
       
   246     }
       
   247 
       
   248 inline const TReal64& TDbColumnC::Real64() const
       
   249 	{
       
   250     return *(const TReal64*)iCell->Data();
       
   251     }
       
   252 
       
   253 inline TPtrC8 TDbColumnC::PtrC8() const
       
   254 	{
       
   255     return TPtrC8((const TUint8*)iCell->Data(),iCell->Length());
       
   256     }
       
   257 
       
   258 inline TPtrC16 TDbColumnC::PtrC16() const
       
   259 	{
       
   260     return TPtrC16((const TUint16*)iCell->Data(),iCell->Length()>>1);
       
   261     }
       
   262 
       
   263 inline const TTime& TDbColumnC::Time() const
       
   264 	{
       
   265     return *(const TTime*)iCell->Data();
       
   266     }
       
   267 
       
   268 inline const TDbBlob& TDbColumnC::Blob() const
       
   269 	{
       
   270     return *(const TDbBlob*)iCell->Data();
       
   271     }
       
   272 
       
   273 // Class TDbColumn
       
   274 inline TDbColumn::TDbColumn()
       
   275 #ifdef _DEBUG
       
   276 	: iRow(0)
       
   277 #endif
       
   278 	{
       
   279     }
       
   280 
       
   281 inline TDbColumn::TDbColumn(RDbRow& aRow,TDbColNo aCol) :
       
   282 	iRow(&aRow), 
       
   283     iColumn(aCol)
       
   284 	{
       
   285     }
       
   286 
       
   287 inline RDbRow& TDbColumn::Row() const
       
   288 	{
       
   289     __ASSERT_DEBUG(iRow,User::Invariant());
       
   290     return *iRow;
       
   291     }
       
   292 
       
   293 inline void TDbColumn::SetNull()
       
   294 	{
       
   295 	//SetColumnWidthL() can't leave when the second parameter value is 0 ("aWidth" parameter).
       
   296 	//TRAP_IGNORE() not used because makes the code heavier and SetNull() is a public, exported, inline method.
       
   297 	//coverity[naming_error]
       
   298     Row().SetColumnWidthL(iColumn,0);
       
   299     }
       
   300 
       
   301 inline void TDbColumn::SetL(TInt32 aValue)
       
   302 	{
       
   303     SetL(TUint32(aValue));
       
   304     }
       
   305 
       
   306 inline void TDbColumn::SetL(const TTime& aValue)
       
   307 	{
       
   308     SetL(aValue.Int64());
       
   309     }
       
   310 
       
   311 inline void TDbColumn::SetL(const TDbCell* aCell)
       
   312 	{
       
   313     SetL(aCell->Data(),aCell->Length());
       
   314     }
       
   315 
       
   316 inline void TDbColumn::SetL(const TDbColumnC& aColumn)
       
   317 	{
       
   318     SetL(aColumn.iCell);
       
   319     }
       
   320 
       
   321 // Class TDbColumnC
       
   322 inline TDbColumnC::TDbColumnC(const TDbColumn& aCol) :
       
   323 	iCell(aCol.Row().ColCell(aCol.iColumn))
       
   324 	{
       
   325     }
       
   326 
       
   327 // Class RDbRow
       
   328 inline RDbRow::RDbRow(TAny* aBuf,TInt aMaxSize)
       
   329 	{
       
   330     Open(aBuf,0,aMaxSize);
       
   331     }
       
   332 
       
   333 inline RDbRow::RDbRow(TAny* aBuf,TInt aSize,TInt aMaxSize)
       
   334 	{
       
   335     Open(aBuf,aSize,aMaxSize);
       
   336     }
       
   337 
       
   338 inline void RDbRow::Open(TAny* aBuf,TInt aMaxSize)
       
   339 	{
       
   340     Open(aBuf,0,aMaxSize);
       
   341     }
       
   342 
       
   343 inline void RDbRow::Reset()
       
   344 	{
       
   345     SetSize(0);
       
   346     }
       
   347 
       
   348 inline TDbCell* RDbRow::First()
       
   349 	{
       
   350     return iFirst;
       
   351     }
       
   352 
       
   353 inline const TDbCell* RDbRow::First() const
       
   354 	{
       
   355     return iFirst;
       
   356     }
       
   357 
       
   358 inline const TDbCell* RDbRow::Last() const
       
   359 	{
       
   360     return iLast;
       
   361     }
       
   362 
       
   363 inline const TDbCell* RDbRow::End() const
       
   364 	{
       
   365     return iEnd;
       
   366     }
       
   367 
       
   368 inline TInt RDbRow::Diff(const TDbCell* aLeft,const TDbCell* aRight)
       
   369 	{
       
   370     return (const TUint8*)aRight-(const TUint8*)aLeft;
       
   371     }
       
   372 
       
   373 inline TInt RDbRow::Size() const
       
   374 	{
       
   375     return Diff(iFirst,iLast);
       
   376     }
       
   377 
       
   378 inline TInt RDbRow::MaxSize() const
       
   379 	{
       
   380     return Diff(iFirst,iEnd);
       
   381     }
       
   382 
       
   383 // Class CDbObject
       
   384 inline const CDbContext* CDbObject::Context() const
       
   385 	{
       
   386     return iContext;
       
   387     }
       
   388 
       
   389 
       
   390 // Class RDbHandleBase
       
   391 inline void RDbHandleBase::Set(CDbObject* aObject)
       
   392 	{
       
   393     iObject=aObject;
       
   394     }
       
   395 
       
   396 // template Class RDbHandle
       
   397 template <class T>
       
   398 inline T*  RDbHandle<T>::operator=(T* aT)
       
   399 	{
       
   400     Set(aT);return aT;
       
   401     }
       
   402 
       
   403 template <class T>
       
   404 inline T* RDbHandle<T>::operator->() const
       
   405 	{
       
   406     return &STATIC_CAST(T&,Object());
       
   407     }
       
   408 
       
   409 template <class T>
       
   410 inline T& RDbHandle<T>::operator*() const
       
   411 	{
       
   412     return STATIC_CAST(T&,Object());
       
   413     }
       
   414 
       
   415 template <class T>
       
   416 inline T* RDbHandle<T>::operator()() const
       
   417 	{
       
   418     return STATIC_CAST(T*,iObject);
       
   419     }