|
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 #ifndef __ASSERT |
|
17 #define __ASSERT(a) |
|
18 #endif |
|
19 |
|
20 // Class RSqlLiteral |
|
21 inline TBool RSqlLiteral::IsNull() const |
|
22 {return iType==ENull;} |
|
23 inline TInt32 RSqlLiteral::Int32() const |
|
24 {__ASSERT(iType==EInt32);return iVal.iInt32;} |
|
25 inline TUint32 RSqlLiteral::Uint32() const |
|
26 {__ASSERT(iType==EUint32);return iVal.iUint32;} |
|
27 inline const TInt64& RSqlLiteral::Int64() const |
|
28 {__ASSERT(iType==EInt64);return iVal.iInt64;} |
|
29 inline const TReal32& RSqlLiteral::Real32() const |
|
30 {__ASSERT(iType==EReal32);return iVal.iReal32;} |
|
31 inline const TReal64& RSqlLiteral::Real64() const |
|
32 {__ASSERT(iType==EReal64);return iVal.iReal64;} |
|
33 inline const TTime& RSqlLiteral::Time() const |
|
34 {__ASSERT(iType==ETime);return iVal.iTime;} |
|
35 inline const TPtrC RSqlLiteral::DesC() const |
|
36 {__ASSERT(iType==EPtr);return TPtrC(iVal.iPtr.iPtr,iVal.iPtr.iEnd-iVal.iPtr.iPtr);} |
|
37 inline const TText* RSqlLiteral::Ptr() const |
|
38 {__ASSERT(iType==EPtr);return iVal.iPtr.iPtr;} |
|
39 inline const TText* RSqlLiteral::End() const |
|
40 {__ASSERT(iType==EPtr);return iVal.iPtr.iEnd;} |
|
41 inline const HBufC8& RSqlLiteral::Text8() const |
|
42 {__ASSERT(iType==EBuf8);return *(const HBufC8*)iVal.iAlloc;} |
|
43 inline const HBufC16& RSqlLiteral::Text16() const |
|
44 {__ASSERT(iType==EBuf16);return *(const HBufC16*)iVal.iAlloc;} |
|
45 inline const HMatcherPattern8& RSqlLiteral::Pattern8() const |
|
46 {__ASSERT(iType==EPattern8);return *(const HMatcherPattern8*)iVal.iAlloc;} |
|
47 inline const HMatcherPattern16& RSqlLiteral::Pattern16() const |
|
48 {__ASSERT(iType==EPattern16);return *(const HMatcherPattern16*)iVal.iAlloc;} |
|
49 inline const HBufC8& RSqlLiteral::Blob() const |
|
50 {__ASSERT(iType==EBlob);return *(const HBufC8*)iVal.iAlloc;} |
|
51 |
|
52 // Class RSqlColumnList |
|
53 inline RSqlColumnList::RSqlColumnList() |
|
54 :RArray<TPtrC>(EGranularity) |
|
55 {} |
|
56 |
|
57 // Class CSqlSearchCondition |
|
58 inline CSqlSearchCondition::TType CSqlSearchCondition::NodeType() const |
|
59 {return iType;} |
|
60 inline CSqlMultiNode* CSqlSearchCondition::MultiNode() |
|
61 {__ASSERT(iType==EAnd||iType==EOr);return STATIC_CAST(CSqlMultiNode*,this);} |
|
62 inline CSqlNullPredicate* CSqlSearchCondition::NullPredicate() |
|
63 {__ASSERT(iType==EIsNull||iType==EIsNotNull);return STATIC_CAST(CSqlNullPredicate*,this);} |
|
64 inline CSqlCompPredicate* CSqlSearchCondition::CompPredicate() |
|
65 {__ASSERT(iType==ELess||iType==ELessEqual||iType==EEqual||iType==EGreaterEqual||iType==EGreater||iType==ENotEqual);return STATIC_CAST(CSqlCompPredicate*,this);} |
|
66 inline CSqlLikePredicate* CSqlSearchCondition::LikePredicate() |
|
67 {__ASSERT(iType==ELike||iType==ENotLike);return STATIC_CAST(CSqlLikePredicate*,this);} |
|
68 |
|
69 // Class CSqlMultiNode |
|
70 inline TInt CSqlMultiNode::Count() const |
|
71 {return iEnd-iLeaves;} |
|
72 inline CSqlSearchCondition* CSqlMultiNode::SubNode(TInt aIndex) const |
|
73 {__ASSERT(TUint(aIndex)<TUint(Count()));return iLeaves[aIndex];} |
|
74 inline void CSqlMultiNode::SetSubNode(TInt aIndex,CSqlSearchCondition* aSearchCondition) |
|
75 {__ASSERT(TUint(aIndex)<TUint(Count()));iLeaves[aIndex]=aSearchCondition;} |
|
76 |
|
77 // Class CSqlBoundNode |
|
78 inline TBool CSqlBoundNode::IsBound() const |
|
79 {return iSource!=0;} |
|
80 inline TDbColNo CSqlBoundNode::ColNo() const |
|
81 {__ASSERT(IsBound());return iColumn.iBound.iNumber;} |
|
82 inline TDbColType CSqlBoundNode::ColType() const |
|
83 {return iColumn.iBound.iType;} |
|
84 |
|
85 // Class CSqlLiteralNode |
|
86 inline const RSqlLiteral& CSqlLiteralNode::Value() const |
|
87 {return iLiteral;} |
|
88 inline RSqlLiteral& CSqlLiteralNode::Value() |
|
89 {return iLiteral;} |
|
90 |
|
91 // Class CSqlQuery |
|
92 inline const TDesC& CSqlQuery::Table() const |
|
93 {return iTable;} |
|
94 inline TBool CSqlQuery::HasColumnList() const |
|
95 {return iColumns.Count()!=0;} |
|
96 inline const RSqlColumnList& CSqlQuery::ColumnList() const |
|
97 {return iColumns;} |
|
98 inline TBool CSqlQuery::HasSearchCondition() const |
|
99 {return iSearchCondition!=0;} |
|
100 inline CSqlSearchCondition& CSqlQuery::SearchCondition() |
|
101 {__ASSERT(HasSearchCondition());return *iSearchCondition;} |
|
102 inline CSqlSearchCondition* CSqlQuery::AdoptSearchCondition() |
|
103 {__ASSERT(HasSearchCondition());CSqlSearchCondition* rr=iSearchCondition;iSearchCondition=0;return rr;} |
|
104 inline TBool CSqlQuery::HasSortSpecification() const |
|
105 {return iSortSpecification!=0;} |
|
106 inline CDbKey& CSqlQuery::SortSpecification() |
|
107 {__ASSERT(HasSortSpecification());return *iSortSpecification;} |
|
108 |
|
109 // Class CSqlDMLStatement |
|
110 inline CSqlQuery& CSqlDMLStatement::Query() |
|
111 {return iQuery;} |
|
112 inline CSqlValues& CSqlDMLStatement::Values() |
|
113 {__ASSERT(iValues);return *iValues;} |
|
114 inline CSqlValues* CSqlDMLStatement::AdoptValues() |
|
115 {__ASSERT(iValues);CSqlValues* v=iValues;iValues=NULL;return v;} |
|
116 inline TBool CSqlDMLStatement::HasValues() const |
|
117 {return iValues!=NULL;} |
|
118 |
|
119 // Class CSqlModifyStatement |
|
120 inline TBool CSqlModifyStatement::IsUpdate() const |
|
121 {return HasValues();} |
|
122 |
|
123 //class TSqlParser2 |
|
124 |
|
125 inline Sql::TStatementType TSqlParser2::StatementType() const |
|
126 { |
|
127 return iStatementType; |
|
128 } |
|
129 |
|
130 inline const TDesC& TSqlParser2::TableName() const |
|
131 { |
|
132 return iTableName; |
|
133 } |
|
134 |
|
135 inline static void HexDecodeL(const TDesC& aHex, RBuf8& aOutput) |
|
136 { |
|
137 TUint len = (TUint)aHex.Length(); |
|
138 |
|
139 // allocate buffer for result |
|
140 aOutput.CreateL(len / 2); |
|
141 if (len<1) |
|
142 return; |
|
143 |
|
144 TLex extractor(aHex); |
|
145 TLex converter; |
|
146 TUint8 val; |
|
147 while (!extractor.Eos()) |
|
148 { |
|
149 // get next value |
|
150 extractor.Mark(); |
|
151 extractor.Inc(); |
|
152 if (extractor.Eos()) |
|
153 { |
|
154 User::Leave(KErrArgument); |
|
155 } |
|
156 extractor.Inc(); |
|
157 converter.Assign(extractor.MarkedToken()); |
|
158 TInt err = converter.Val(val, EHex); |
|
159 User::LeaveIfError(err); |
|
160 |
|
161 // add to result |
|
162 aOutput.Append(&val, 1); |
|
163 } |
|
164 } |