persistentstorage/sql/SRC/Client/SqlStatementImpl.inl
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
    51 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    51 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    52 @panic SqlDb 7 There is no long column value with aColumnIndex index.
    52 @panic SqlDb 7 There is no long column value with aColumnIndex index.
    53 */
    53 */
    54 inline TPtrC RSqlLongColumnColl::Text(TInt aColumnIndex) const
    54 inline TPtrC RSqlLongColumnColl::Text(TInt aColumnIndex) const
    55 	{
    55 	{
    56 	__ASSERT_DEBUG(aColumnIndex >= 0, __SQLPANIC(ESqlPanicBadArgument));
    56 	__SQLASSERT(aColumnIndex >= 0, ESqlPanicBadArgument);
    57 	LONGCOL_INVARIANT();
    57 	LONGCOL_INVARIANT();
    58 	TInt rc = FindValue(aColumnIndex);
    58 	TInt rc = FindValue(aColumnIndex);
    59 	__ASSERT_ALWAYS(rc >= 0, __SQLPANIC(ESqlPanicInternalError));
    59 	__SQLASSERT_ALWAYS(rc >= 0, ESqlPanicInternalError);
    60 	TPtrC8 ptr(iValues[rc].iData->Des());
    60 	TPtrC8 ptr(iValues[rc].iData->Des());
    61 	return TPtrC(reinterpret_cast <const TUint16*> (ptr.Ptr()), ptr.Length() / sizeof(TUint16));
    61 	return TPtrC(reinterpret_cast <const TUint16*> (ptr.Ptr()), ptr.Length() / sizeof(TUint16));
    62 	}
    62 	}
    63 
    63 
    64 /**
    64 /**
    68 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    68 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    69 @panic SqlDb 7 There is no long column value with aColumnIndex index.
    69 @panic SqlDb 7 There is no long column value with aColumnIndex index.
    70 */
    70 */
    71 inline TPtrC8 RSqlLongColumnColl::Binary(TInt aColumnIndex) const
    71 inline TPtrC8 RSqlLongColumnColl::Binary(TInt aColumnIndex) const
    72 	{
    72 	{
    73 	__ASSERT_DEBUG(aColumnIndex >= 0, __SQLPANIC(ESqlPanicBadArgument));
    73 	__SQLASSERT(aColumnIndex >= 0, ESqlPanicBadArgument);
    74 	LONGCOL_INVARIANT();
    74 	LONGCOL_INVARIANT();
    75 	TInt rc = FindValue(aColumnIndex);
    75 	TInt rc = FindValue(aColumnIndex);
    76 	__ASSERT_ALWAYS(rc >= 0, __SQLPANIC(ESqlPanicInternalError));
    76 	__SQLASSERT_ALWAYS(rc >= 0, ESqlPanicInternalError);
    77 	return iValues[rc].iData->Des();
    77 	return iValues[rc].iData->Des();
    78 	}
    78 	}
    79 
    79 
    80 /**
    80 /**
    81 Returns true if there is a long column value in the collection, which index is aColumnIndex.
    81 Returns true if there is a long column value in the collection, which index is aColumnIndex.
    83 @return True if there is a long column value in the collection, which index is aColumnIndex.
    83 @return True if there is a long column value in the collection, which index is aColumnIndex.
    84 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    84 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    85 */
    85 */
    86 inline TBool RSqlLongColumnColl::IsPresent(TInt aColumnIndex) const
    86 inline TBool RSqlLongColumnColl::IsPresent(TInt aColumnIndex) const
    87 	{
    87 	{
    88 	__ASSERT_DEBUG(aColumnIndex >= 0, __SQLPANIC(ESqlPanicBadArgument));
    88 	__SQLASSERT(aColumnIndex >= 0, ESqlPanicBadArgument);
    89 	LONGCOL_INVARIANT();
    89 	LONGCOL_INVARIANT();
    90 	return FindValue(aColumnIndex) >= 0;
    90 	return FindValue(aColumnIndex) >= 0;
    91 	}
    91 	}
    92 
    92 
    93 /**
    93 /**
    97 		KErrNotFound otherwise.
    97 		KErrNotFound otherwise.
    98 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    98 @panic SqlDb 4 In _DEBUG mode, aColumnIndex value is negative.
    99 */
    99 */
   100 inline TInt RSqlLongColumnColl::FindValue(TInt aColumnIndex) const
   100 inline TInt RSqlLongColumnColl::FindValue(TInt aColumnIndex) const
   101 	{
   101 	{
   102 	__ASSERT_DEBUG(aColumnIndex >= 0, __SQLPANIC(ESqlPanicBadArgument));
   102 	__SQLASSERT(aColumnIndex >= 0, ESqlPanicBadArgument);
   103 	return iValues.Find(aColumnIndex, &RSqlLongColumnColl::TData::Compare);
   103 	return iValues.Find(aColumnIndex, &RSqlLongColumnColl::TData::Compare);
   104 	}
   104 	}
   105 
   105 
   106 /**
   106 /**
   107 Initializes the RSqlLongColumnColl::TData instance with the column index, and a pointer to the column data
   107 Initializes the RSqlLongColumnColl::TData instance with the column index, and a pointer to the column data
   111 */
   111 */
   112 inline RSqlLongColumnColl::TData::TData(TInt aIndex, HBufC8* aData) :
   112 inline RSqlLongColumnColl::TData::TData(TInt aIndex, HBufC8* aData) :
   113 	iIndex(aIndex),
   113 	iIndex(aIndex),
   114 	iData(aData)
   114 	iData(aData)
   115 	{
   115 	{
   116 	__ASSERT_DEBUG(aIndex >= 0, __SQLPANIC(ESqlPanicBadArgument));
   116 	__SQLASSERT(aIndex >= 0, ESqlPanicBadArgument);
   117 	__ASSERT_DEBUG(aData != NULL, __SQLPANIC(ESqlPanicBadArgument));
   117 	__SQLASSERT(aData != NULL, ESqlPanicBadArgument);
   118 	}
   118 	}
   119 
   119 
   120 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
   120 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
   121 //////////////////////////           CSqlStatementImpl           ////////////////////////////////////////////
   121 //////////////////////////           CSqlStatementImpl           ////////////////////////////////////////////
   122 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
   122 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
   143 	TInt err = iSqlStmtSession.Prepare(aDatabase.Session(), aSqlStmt, iColumnCnt, iParamCnt);
   143 	TInt err = iSqlStmtSession.Prepare(aDatabase.Session(), aSqlStmt, iColumnCnt, iParamCnt);
   144 	if(err != KErrNone)
   144 	if(err != KErrNone)
   145 		{
   145 		{
   146 		return err;	
   146 		return err;	
   147 		}
   147 		}
   148 	__ASSERT_DEBUG(iColumnCnt >= 0, __SQLPANIC(ESqlPanicInternalError));
   148     __SQLASSERT(iColumnCnt >= 0, ESqlPanicInternalError);
   149     err = iColumnValueBuf.SetCount(iColumnCnt);
   149     err = iColumnValueBuf.SetCount(iColumnCnt);
   150     if(err != KErrNone)
   150     if(err != KErrNone)
   151         {
   151         {
   152         return err;	
   152         return err;	
   153         }
   153         }
   340 
   340 
   341 @see RSqlColumnReadStream
   341 @see RSqlColumnReadStream
   342 */
   342 */
   343 inline MStreamBuf* CSqlStatementImpl::ColumnSourceL(TInt aColumnIndex)
   343 inline MStreamBuf* CSqlStatementImpl::ColumnSourceL(TInt aColumnIndex)
   344 	{
   344 	{
   345 	__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
   345 	__SQLASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, ESqlPanicBadColumnIndex);
   346 	__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
   346 	__SQLASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, ESqlPanicInvalidRow);
   347 	iColumnValBufIt.MoveTo(aColumnIndex);		
   347 	iColumnValBufIt.MoveTo(aColumnIndex);		
   348 	return iColumnValBufIt.IsPresent() ? iColumnValBufIt.StreamL() : iSqlStmtSession.ColumnSourceL(aColumnIndex);
   348 	return iColumnValBufIt.IsPresent() ? iColumnValBufIt.StreamL() : iSqlStmtSession.ColumnSourceL(aColumnIndex);
   349 	}
   349 	}
   350 
   350 
   351 /**
   351 /**
   367 
   367 
   368 @see RSqlParamWriteStream
   368 @see RSqlParamWriteStream
   369 */
   369 */
   370 inline MStreamBuf* CSqlStatementImpl::ParamSinkL(TSqlSrvFunction aFunction, TInt aParamIndex)
   370 inline MStreamBuf* CSqlStatementImpl::ParamSinkL(TSqlSrvFunction aFunction, TInt aParamIndex)
   371 	{
   371 	{
   372 	__ASSERT_ALWAYS((TUint)aParamIndex < (TUint)iParamCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
   372 	__SQLASSERT_ALWAYS((TUint)aParamIndex < (TUint)iParamCnt, ESqlPanicBadColumnIndex);
   373 	return iSqlStmtSession.ParamSinkL(aFunction, aParamIndex);
   373 	return iSqlStmtSession.ParamSinkL(aFunction, aParamIndex);
   374 	}
   374 	}
   375 
   375 
   376 /**
   376 /**
   377 Sets the internal state of CSqlStatementImpl instance to CSqlStatementImpl::EUnknown.
   377 Sets the internal state of CSqlStatementImpl instance to CSqlStatementImpl::EUnknown.