os/persistentdata/persistentstorage/dbms/pcdbms/inc/D32SQL.INL
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/inc/D32SQL.INL	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,164 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __ASSERT
    1.20 +#define __ASSERT(a)
    1.21 +#endif
    1.22 +
    1.23 +// Class RSqlLiteral
    1.24 +inline TBool RSqlLiteral::IsNull() const
    1.25 +	{return iType==ENull;}
    1.26 +inline TInt32 RSqlLiteral::Int32() const
    1.27 +	{__ASSERT(iType==EInt32);return iVal.iInt32;}
    1.28 +inline TUint32 RSqlLiteral::Uint32() const
    1.29 +	{__ASSERT(iType==EUint32);return iVal.iUint32;}
    1.30 +inline const TInt64& RSqlLiteral::Int64() const
    1.31 +	{__ASSERT(iType==EInt64);return iVal.iInt64;}
    1.32 +inline const TReal32& RSqlLiteral::Real32() const
    1.33 +	{__ASSERT(iType==EReal32);return iVal.iReal32;}
    1.34 +inline const TReal64& RSqlLiteral::Real64() const
    1.35 +	{__ASSERT(iType==EReal64);return iVal.iReal64;}
    1.36 +inline const TTime& RSqlLiteral::Time() const
    1.37 +	{__ASSERT(iType==ETime);return iVal.iTime;}
    1.38 +inline const TPtrC RSqlLiteral::DesC() const
    1.39 +	{__ASSERT(iType==EPtr);return TPtrC(iVal.iPtr.iPtr,iVal.iPtr.iEnd-iVal.iPtr.iPtr);}
    1.40 +inline const TText* RSqlLiteral::Ptr() const
    1.41 +	{__ASSERT(iType==EPtr);return iVal.iPtr.iPtr;}
    1.42 +inline const TText* RSqlLiteral::End() const
    1.43 +	{__ASSERT(iType==EPtr);return iVal.iPtr.iEnd;}
    1.44 +inline const HBufC8& RSqlLiteral::Text8() const
    1.45 +	{__ASSERT(iType==EBuf8);return *(const HBufC8*)iVal.iAlloc;}
    1.46 +inline const HBufC16& RSqlLiteral::Text16() const
    1.47 +	{__ASSERT(iType==EBuf16);return *(const HBufC16*)iVal.iAlloc;}
    1.48 +inline const HMatcherPattern8& RSqlLiteral::Pattern8() const
    1.49 +	{__ASSERT(iType==EPattern8);return *(const HMatcherPattern8*)iVal.iAlloc;}
    1.50 +inline const HMatcherPattern16& RSqlLiteral::Pattern16() const
    1.51 +	{__ASSERT(iType==EPattern16);return *(const HMatcherPattern16*)iVal.iAlloc;}
    1.52 +inline const HBufC8& RSqlLiteral::Blob() const
    1.53 +	{__ASSERT(iType==EBlob);return *(const HBufC8*)iVal.iAlloc;}
    1.54 +
    1.55 +// Class RSqlColumnList
    1.56 +inline RSqlColumnList::RSqlColumnList()
    1.57 +	:RArray<TPtrC>(EGranularity)
    1.58 +	{}
    1.59 +
    1.60 +// Class CSqlSearchCondition
    1.61 +inline CSqlSearchCondition::TType CSqlSearchCondition::NodeType() const
    1.62 +	{return iType;}
    1.63 +inline CSqlMultiNode* CSqlSearchCondition::MultiNode()
    1.64 +	{__ASSERT(iType==EAnd||iType==EOr);return STATIC_CAST(CSqlMultiNode*,this);}
    1.65 +inline CSqlNullPredicate* CSqlSearchCondition::NullPredicate()
    1.66 +	{__ASSERT(iType==EIsNull||iType==EIsNotNull);return STATIC_CAST(CSqlNullPredicate*,this);}
    1.67 +inline CSqlCompPredicate* CSqlSearchCondition::CompPredicate()
    1.68 +	{__ASSERT(iType==ELess||iType==ELessEqual||iType==EEqual||iType==EGreaterEqual||iType==EGreater||iType==ENotEqual);return STATIC_CAST(CSqlCompPredicate*,this);}
    1.69 +inline CSqlLikePredicate* CSqlSearchCondition::LikePredicate()
    1.70 +	{__ASSERT(iType==ELike||iType==ENotLike);return STATIC_CAST(CSqlLikePredicate*,this);}
    1.71 +
    1.72 +// Class CSqlMultiNode
    1.73 +inline TInt CSqlMultiNode::Count() const
    1.74 +	{return iEnd-iLeaves;}
    1.75 +inline CSqlSearchCondition* CSqlMultiNode::SubNode(TInt aIndex) const
    1.76 +	{__ASSERT(TUint(aIndex)<TUint(Count()));return iLeaves[aIndex];}
    1.77 +inline void CSqlMultiNode::SetSubNode(TInt aIndex,CSqlSearchCondition* aSearchCondition) 
    1.78 +	{__ASSERT(TUint(aIndex)<TUint(Count()));iLeaves[aIndex]=aSearchCondition;}
    1.79 +
    1.80 +// Class CSqlBoundNode
    1.81 +inline TBool CSqlBoundNode::IsBound() const
    1.82 +	{return iSource!=0;}
    1.83 +inline TDbColNo CSqlBoundNode::ColNo() const
    1.84 +	{__ASSERT(IsBound());return iColumn.iBound.iNumber;}
    1.85 +inline TDbColType CSqlBoundNode::ColType() const
    1.86 +	{return iColumn.iBound.iType;}
    1.87 +
    1.88 +// Class CSqlLiteralNode 
    1.89 +inline const RSqlLiteral& CSqlLiteralNode::Value() const
    1.90 +	{return iLiteral;}
    1.91 +inline RSqlLiteral& CSqlLiteralNode::Value()
    1.92 +	{return iLiteral;}
    1.93 +
    1.94 +// Class CSqlQuery
    1.95 +inline const TDesC& CSqlQuery::Table() const
    1.96 +	{return iTable;}
    1.97 +inline TBool CSqlQuery::HasColumnList() const
    1.98 +	{return iColumns.Count()!=0;}
    1.99 +inline const RSqlColumnList& CSqlQuery::ColumnList() const
   1.100 +	{return iColumns;}
   1.101 +inline TBool CSqlQuery::HasSearchCondition() const
   1.102 +	{return iSearchCondition!=0;}
   1.103 +inline CSqlSearchCondition& CSqlQuery::SearchCondition()
   1.104 +	{__ASSERT(HasSearchCondition());return *iSearchCondition;}
   1.105 +inline CSqlSearchCondition* CSqlQuery::AdoptSearchCondition()
   1.106 +	{__ASSERT(HasSearchCondition());CSqlSearchCondition* rr=iSearchCondition;iSearchCondition=0;return rr;}
   1.107 +inline TBool CSqlQuery::HasSortSpecification() const
   1.108 +	{return iSortSpecification!=0;}
   1.109 +inline CDbKey& CSqlQuery::SortSpecification()
   1.110 +	{__ASSERT(HasSortSpecification());return *iSortSpecification;}
   1.111 +
   1.112 +// Class CSqlDMLStatement
   1.113 +inline CSqlQuery& CSqlDMLStatement::Query()
   1.114 +	{return iQuery;}
   1.115 +inline CSqlValues& CSqlDMLStatement::Values()
   1.116 +	{__ASSERT(iValues);return *iValues;}
   1.117 +inline CSqlValues* CSqlDMLStatement::AdoptValues()
   1.118 +	{__ASSERT(iValues);CSqlValues* v=iValues;iValues=NULL;return v;}
   1.119 +inline TBool CSqlDMLStatement::HasValues() const
   1.120 +	{return iValues!=NULL;}
   1.121 +
   1.122 +// Class CSqlModifyStatement
   1.123 +inline TBool CSqlModifyStatement::IsUpdate() const
   1.124 +	{return HasValues();}
   1.125 +
   1.126 +//class TSqlParser2
   1.127 +
   1.128 +inline Sql::TStatementType TSqlParser2::StatementType() const
   1.129 +	{
   1.130 +	return iStatementType;
   1.131 +	}
   1.132 +
   1.133 +inline const TDesC& TSqlParser2::TableName() const
   1.134 +	{
   1.135 +	return iTableName;
   1.136 +	}
   1.137 +
   1.138 +inline static void HexDecodeL(const TDesC& aHex, RBuf8& aOutput)
   1.139 +	{
   1.140 +	TUint len = (TUint)aHex.Length();
   1.141 +
   1.142 +	// allocate buffer for result
   1.143 +	aOutput.CreateL(len / 2);
   1.144 +	if (len<1)
   1.145 +		return;
   1.146 +	
   1.147 +	TLex extractor(aHex);
   1.148 +	TLex converter;
   1.149 +	TUint8 val;
   1.150 +	while (!extractor.Eos())
   1.151 +		{
   1.152 +		// get next value
   1.153 +		extractor.Mark();
   1.154 +		extractor.Inc();
   1.155 +		if (extractor.Eos())
   1.156 +			{
   1.157 +			User::Leave(KErrArgument);
   1.158 +			}
   1.159 +		extractor.Inc();
   1.160 +		converter.Assign(extractor.MarkedToken());
   1.161 +		TInt err = converter.Val(val, EHex);
   1.162 +		User::LeaveIfError(err);
   1.163 +		
   1.164 +		// add to result
   1.165 +		aOutput.Append(&val, 1);
   1.166 +		}
   1.167 +	}