Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 //Forward declarations
29 template <class T,class D> class TMatcher;
30 template <class T,class D> class TDesMatcher;
31 template <class T,class D> class TStreamMatcher;
32 template <class T,class D> class HMatcherPattern;
33 class CSqlCreateTableStatement;
34 class CSqlDropTableStatement;
35 class CSqlAlterTableStatement;
36 class CSqlCreateIndexStatement;
37 class CSqlDropIndexStatement;
74 #define KEYWORD(s) ESqlKeyword_##s
84 friend class TSqlLexer;
86 inline TBool operator==(TSqlTokenType aType) const;
87 inline TBool operator!=(TSqlTokenType aType) const;
89 inline void SetError(TInt aError);
90 inline TInt Error() const;
92 inline TSqlTokenType Type() const;
93 inline const RSqlLiteral& Literal() const;
94 inline RSqlLiteral& Literal();
96 inline TSqlTokenType operator=(TSqlTokenType aType);
108 TSqlLexer(const TDesC& aSql);
109 inline TSqlTokenType NextToken(TSqlToken& aToken);
110 static TSqlKeyword Keyword(const TSqlToken& aToken);
111 static inline TBool IsKeyword(TSqlKeyword aKeyword,const TSqlToken& aToken);
112 const TText* Next() const;
113 void Set(const TText* aNext);
115 TSqlTokenType GetIdentifier(TSqlToken& aToken);
116 TSqlTokenType GetString(TSqlToken& aToken);
117 TInt GetInteger(TInt64& aValue);
118 TSqlTokenType GetNumber(TSqlToken& aToken);
119 TSqlTokenType GetDate(TSqlToken& aToken);
120 TSqlTokenType GetNextToken(TSqlToken& aToken);
122 static inline TSqlTokenType SqlError(TInt aError=KErrArgument);
123 static TInt CompareKeyword(TInt aKeyword,const RSqlLiteral& aIdentifier);
134 friend class TSqlParser2;
136 TSqlParser(const TDesC& aSql);
138 CSqlQuery* QueryLC();
139 CSqlSearchCondition* SearchConditionLC();
140 CSqlDDLStatement* DDLStatementLC();
141 CSqlDMLStatement* DMLStatementLC();
142 Sql::TStatementType Type();
143 TInt PatternFilter(const TDesC& aPattern,const TChar aEscape, TText *aNewPatternBuffer );
145 TSqlTokenType NextToken();
146 CSqlSearchCondition* SqlError();
147 inline TInt Error() const;
148 static TSqlTokenType SqlErrorL();
150 TSqlTokenType Parse(TSqlKeyword aKeyword);
151 TSqlTokenType ParseL(TSqlTokenType aToken);
152 TSqlTokenType ParseL(TSqlKeyword aKeyword);
153 TSqlKeyword Keyword();
154 TSqlTokenType RightBracketL();
155 TSqlTokenType IdentifierL(TPtrC& aIdentifier);
159 TSqlTokenType ColumnNameL(RSqlColumnList& aList);
160 TSqlTokenType ColumnListL(RSqlColumnList& aList);
161 CSqlSearchCondition* SearchCondition(TInt aNot);
162 CSqlSearchCondition* BooleanTerm(TInt aNot);
163 CSqlSearchCondition* BooleanFactor(TInt aNot);
164 CSqlSearchCondition* BooleanPrimary(TInt aNot);
165 CSqlSearchCondition* Predicate(TInt aNot);
166 void SortSpecificationL(CDbKey& aKey);
167 CDbKey* SortSpecificationL();
168 void DoQueryL(CSqlQuery& aQuery);
169 CSqlSearchCondition* SearchConditionL();
171 TSqlTokenType AddColumnSpecL(TDbCol& aDef);
172 CSqlDDLStatement* CreateTableLC();
173 CSqlDDLStatement* DropTableLC();
174 CSqlDDLStatement* AlterTableLC();
175 CSqlDDLStatement* CreateIndexLC(TBool aUnique);
176 CSqlDDLStatement* DropIndexLC();
178 TSqlTokenType ColumnValueL(CSqlValues& aValues);
179 CSqlDMLStatement* InsertStatementLC();
180 CSqlDMLStatement* UpdateStatementLC();
181 CSqlDMLStatement* DeleteStatementLC();
189 LIKE evaluation support
192 enum TSegmentType {ENull,ESuccess,EStop,EBeginning,EEnd,EMiddle,ESkip,EEscape,EMask=0xf,EWild=0x80};
196 const TInt KPatternGranularity=0x20;
198 // If this value is changed class documentation must be updated.
199 // Namely, RDbDatabase and TDbQuery.
200 const TInt KMaxSegmentLength=0xff;
202 template <class T,class D>
203 class HMatcherPattern
208 friend class TMatcher<T,D>;
209 typedef HMatcherPattern<T,D> TThis;
211 static HMatcherPattern<T,D>* NewL(const D& aPattern,TBool aEscape = EFalse);
212 TInt MatchL(const D& aDes,const TTextOps& aTextOp) const;
213 TInt MatchL(MStreamBuf& aBuf,TInt aLength,const TTextOps& aTextOp) const;
215 static TInt Construct(HMatcherPattern<T,D>*& aCell,const D& aPattern,TBool aEscape = EFalse);
216 static inline HMatcherPattern<T,D>* Realloc(HMatcherPattern<T,D>* aThis,TInt aSize);
221 template <class T,class D>
228 TBool MatchL(const HMatcherPattern<T,D>& aPattern,const TTextOps& aTextOp);
230 virtual const T* UnderflowL(const T*& aEnd,TInt aRetain=0) =0;
233 template <class T,class D>
234 class TDesMatcher : public TMatcher<T,D>
240 inline TDesMatcher(const D& aDes);
242 const T* UnderflowL(const T*& aEnd,TInt aRetain=0);
248 template <class T,class D>
249 class TStreamMatcher : public TMatcher<T,D>
255 inline TStreamMatcher(MStreamBuf& aStreamBuf,TInt aLength);
257 const T* UnderflowL(const T*& aEnd,TInt aRetain=0);
259 enum {EBufSize=0x200};
267 NONSHARABLE_CLASS(CSqlCreateTableStatement) : public CSqlDDLStatement
274 CDbIncremental* ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aSteps);
280 NONSHARABLE_CLASS(CSqlDropTableStatement) : public CSqlDDLStatement
286 CDbIncremental* ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aSteps);
291 NONSHARABLE_CLASS(CSqlAlterTableStatement) : public CSqlDDLStatement
297 ~CSqlAlterTableStatement();
299 CDbIncremental* ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aSteps);
303 RSqlColumnList iDrop;
306 NONSHARABLE_CLASS(CSqlCreateIndexStatement) : public CSqlDDLStatement
312 CDbIncremental* ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aSteps);
319 NONSHARABLE_CLASS(CSqlDropIndexStatement) : public CSqlDDLStatement
325 CDbIncremental* ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aSteps);
331 #include "UQ_STD.INL"