os/persistentdata/persistentstorage/dbms/pcdbms/inc/D32SQL.INL
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __ASSERT
sl@0
    17
#define __ASSERT(a)
sl@0
    18
#endif
sl@0
    19
sl@0
    20
// Class RSqlLiteral
sl@0
    21
inline TBool RSqlLiteral::IsNull() const
sl@0
    22
	{return iType==ENull;}
sl@0
    23
inline TInt32 RSqlLiteral::Int32() const
sl@0
    24
	{__ASSERT(iType==EInt32);return iVal.iInt32;}
sl@0
    25
inline TUint32 RSqlLiteral::Uint32() const
sl@0
    26
	{__ASSERT(iType==EUint32);return iVal.iUint32;}
sl@0
    27
inline const TInt64& RSqlLiteral::Int64() const
sl@0
    28
	{__ASSERT(iType==EInt64);return iVal.iInt64;}
sl@0
    29
inline const TReal32& RSqlLiteral::Real32() const
sl@0
    30
	{__ASSERT(iType==EReal32);return iVal.iReal32;}
sl@0
    31
inline const TReal64& RSqlLiteral::Real64() const
sl@0
    32
	{__ASSERT(iType==EReal64);return iVal.iReal64;}
sl@0
    33
inline const TTime& RSqlLiteral::Time() const
sl@0
    34
	{__ASSERT(iType==ETime);return iVal.iTime;}
sl@0
    35
inline const TPtrC RSqlLiteral::DesC() const
sl@0
    36
	{__ASSERT(iType==EPtr);return TPtrC(iVal.iPtr.iPtr,iVal.iPtr.iEnd-iVal.iPtr.iPtr);}
sl@0
    37
inline const TText* RSqlLiteral::Ptr() const
sl@0
    38
	{__ASSERT(iType==EPtr);return iVal.iPtr.iPtr;}
sl@0
    39
inline const TText* RSqlLiteral::End() const
sl@0
    40
	{__ASSERT(iType==EPtr);return iVal.iPtr.iEnd;}
sl@0
    41
inline const HBufC8& RSqlLiteral::Text8() const
sl@0
    42
	{__ASSERT(iType==EBuf8);return *(const HBufC8*)iVal.iAlloc;}
sl@0
    43
inline const HBufC16& RSqlLiteral::Text16() const
sl@0
    44
	{__ASSERT(iType==EBuf16);return *(const HBufC16*)iVal.iAlloc;}
sl@0
    45
inline const HMatcherPattern8& RSqlLiteral::Pattern8() const
sl@0
    46
	{__ASSERT(iType==EPattern8);return *(const HMatcherPattern8*)iVal.iAlloc;}
sl@0
    47
inline const HMatcherPattern16& RSqlLiteral::Pattern16() const
sl@0
    48
	{__ASSERT(iType==EPattern16);return *(const HMatcherPattern16*)iVal.iAlloc;}
sl@0
    49
inline const HBufC8& RSqlLiteral::Blob() const
sl@0
    50
	{__ASSERT(iType==EBlob);return *(const HBufC8*)iVal.iAlloc;}
sl@0
    51
sl@0
    52
// Class RSqlColumnList
sl@0
    53
inline RSqlColumnList::RSqlColumnList()
sl@0
    54
	:RArray<TPtrC>(EGranularity)
sl@0
    55
	{}
sl@0
    56
sl@0
    57
// Class CSqlSearchCondition
sl@0
    58
inline CSqlSearchCondition::TType CSqlSearchCondition::NodeType() const
sl@0
    59
	{return iType;}
sl@0
    60
inline CSqlMultiNode* CSqlSearchCondition::MultiNode()
sl@0
    61
	{__ASSERT(iType==EAnd||iType==EOr);return STATIC_CAST(CSqlMultiNode*,this);}
sl@0
    62
inline CSqlNullPredicate* CSqlSearchCondition::NullPredicate()
sl@0
    63
	{__ASSERT(iType==EIsNull||iType==EIsNotNull);return STATIC_CAST(CSqlNullPredicate*,this);}
sl@0
    64
inline CSqlCompPredicate* CSqlSearchCondition::CompPredicate()
sl@0
    65
	{__ASSERT(iType==ELess||iType==ELessEqual||iType==EEqual||iType==EGreaterEqual||iType==EGreater||iType==ENotEqual);return STATIC_CAST(CSqlCompPredicate*,this);}
sl@0
    66
inline CSqlLikePredicate* CSqlSearchCondition::LikePredicate()
sl@0
    67
	{__ASSERT(iType==ELike||iType==ENotLike);return STATIC_CAST(CSqlLikePredicate*,this);}
sl@0
    68
sl@0
    69
// Class CSqlMultiNode
sl@0
    70
inline TInt CSqlMultiNode::Count() const
sl@0
    71
	{return iEnd-iLeaves;}
sl@0
    72
inline CSqlSearchCondition* CSqlMultiNode::SubNode(TInt aIndex) const
sl@0
    73
	{__ASSERT(TUint(aIndex)<TUint(Count()));return iLeaves[aIndex];}
sl@0
    74
inline void CSqlMultiNode::SetSubNode(TInt aIndex,CSqlSearchCondition* aSearchCondition) 
sl@0
    75
	{__ASSERT(TUint(aIndex)<TUint(Count()));iLeaves[aIndex]=aSearchCondition;}
sl@0
    76
sl@0
    77
// Class CSqlBoundNode
sl@0
    78
inline TBool CSqlBoundNode::IsBound() const
sl@0
    79
	{return iSource!=0;}
sl@0
    80
inline TDbColNo CSqlBoundNode::ColNo() const
sl@0
    81
	{__ASSERT(IsBound());return iColumn.iBound.iNumber;}
sl@0
    82
inline TDbColType CSqlBoundNode::ColType() const
sl@0
    83
	{return iColumn.iBound.iType;}
sl@0
    84
sl@0
    85
// Class CSqlLiteralNode 
sl@0
    86
inline const RSqlLiteral& CSqlLiteralNode::Value() const
sl@0
    87
	{return iLiteral;}
sl@0
    88
inline RSqlLiteral& CSqlLiteralNode::Value()
sl@0
    89
	{return iLiteral;}
sl@0
    90
sl@0
    91
// Class CSqlQuery
sl@0
    92
inline const TDesC& CSqlQuery::Table() const
sl@0
    93
	{return iTable;}
sl@0
    94
inline TBool CSqlQuery::HasColumnList() const
sl@0
    95
	{return iColumns.Count()!=0;}
sl@0
    96
inline const RSqlColumnList& CSqlQuery::ColumnList() const
sl@0
    97
	{return iColumns;}
sl@0
    98
inline TBool CSqlQuery::HasSearchCondition() const
sl@0
    99
	{return iSearchCondition!=0;}
sl@0
   100
inline CSqlSearchCondition& CSqlQuery::SearchCondition()
sl@0
   101
	{__ASSERT(HasSearchCondition());return *iSearchCondition;}
sl@0
   102
inline CSqlSearchCondition* CSqlQuery::AdoptSearchCondition()
sl@0
   103
	{__ASSERT(HasSearchCondition());CSqlSearchCondition* rr=iSearchCondition;iSearchCondition=0;return rr;}
sl@0
   104
inline TBool CSqlQuery::HasSortSpecification() const
sl@0
   105
	{return iSortSpecification!=0;}
sl@0
   106
inline CDbKey& CSqlQuery::SortSpecification()
sl@0
   107
	{__ASSERT(HasSortSpecification());return *iSortSpecification;}
sl@0
   108
sl@0
   109
// Class CSqlDMLStatement
sl@0
   110
inline CSqlQuery& CSqlDMLStatement::Query()
sl@0
   111
	{return iQuery;}
sl@0
   112
inline CSqlValues& CSqlDMLStatement::Values()
sl@0
   113
	{__ASSERT(iValues);return *iValues;}
sl@0
   114
inline CSqlValues* CSqlDMLStatement::AdoptValues()
sl@0
   115
	{__ASSERT(iValues);CSqlValues* v=iValues;iValues=NULL;return v;}
sl@0
   116
inline TBool CSqlDMLStatement::HasValues() const
sl@0
   117
	{return iValues!=NULL;}
sl@0
   118
sl@0
   119
// Class CSqlModifyStatement
sl@0
   120
inline TBool CSqlModifyStatement::IsUpdate() const
sl@0
   121
	{return HasValues();}
sl@0
   122
sl@0
   123
//class TSqlParser2
sl@0
   124
sl@0
   125
inline Sql::TStatementType TSqlParser2::StatementType() const
sl@0
   126
	{
sl@0
   127
	return iStatementType;
sl@0
   128
	}
sl@0
   129
sl@0
   130
inline const TDesC& TSqlParser2::TableName() const
sl@0
   131
	{
sl@0
   132
	return iTableName;
sl@0
   133
	}
sl@0
   134
sl@0
   135
inline static void HexDecodeL(const TDesC& aHex, RBuf8& aOutput)
sl@0
   136
	{
sl@0
   137
	TUint len = (TUint)aHex.Length();
sl@0
   138
sl@0
   139
	// allocate buffer for result
sl@0
   140
	aOutput.CreateL(len / 2);
sl@0
   141
	if (len<1)
sl@0
   142
		return;
sl@0
   143
	
sl@0
   144
	TLex extractor(aHex);
sl@0
   145
	TLex converter;
sl@0
   146
	TUint8 val;
sl@0
   147
	while (!extractor.Eos())
sl@0
   148
		{
sl@0
   149
		// get next value
sl@0
   150
		extractor.Mark();
sl@0
   151
		extractor.Inc();
sl@0
   152
		if (extractor.Eos())
sl@0
   153
			{
sl@0
   154
			User::Leave(KErrArgument);
sl@0
   155
			}
sl@0
   156
		extractor.Inc();
sl@0
   157
		converter.Assign(extractor.MarkedToken());
sl@0
   158
		TInt err = converter.Val(val, EHex);
sl@0
   159
		User::LeaveIfError(err);
sl@0
   160
		
sl@0
   161
		// add to result
sl@0
   162
		aOutput.Append(&val, 1);
sl@0
   163
		}
sl@0
   164
	}