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.
16 #if !defined(__D32DBAS_H__)
18 #if !defined(__D32DBMS_H__)
22 // other classes referenced
34 class CDbRowConstraint;
38 class CDbSyncIncremental;
39 class CDbAsyncIncremental;
48 const TInt KDbMaxFormatName=32;
49 const TInt KDbMaxDatabaseName=KMaxFileName;
54 const TInt KDbMaxInlineBlobSize=255;
59 typedef TUint32 TDbBlobId;
64 const TDbBlobId KDbNullBlobId=0;
72 IMPORT_C static void Panic(const TDesC& aCategory,TInt aCode);
81 IMPORT_C static const TTextOps& Ops(TDbTextComparison aType=EDbCompareNormal);
83 inline TUint Fold(TUint aChar) const;
84 IMPORT_C TInt Compare(const TDesC8& aLeft,const TDesC8& aRight) const;
85 IMPORT_C TInt Compare(const TDesC16& aLeft,const TDesC16& aRight) const;
86 inline TInt Compare(const TText8* aLeftPtr,TInt aLeftLen,const TText8* aRightPtr,TInt aRightLen) const;
87 inline TInt Compare(const TText16* aLeftPtr,TInt aLeftLen,const TText16* aRightPtr,TInt aRightLen) const;
88 inline TInt Match(const TDesC8& aDes,const TDesC8& aPattern) const;
89 inline TInt Match(const TDesC16& aDes,const TDesC16& aPattern) const;
90 IMPORT_C TInt Match(const TText8* aPtr,TInt aLen,const TText8* aPatternPtr,TInt aPatternLen) const;
91 IMPORT_C TInt Match(const TText16* aPtr,TInt aLen,const TText16* aPatternPtr,TInt aPatternLen) const;
92 IMPORT_C TInt Find(const TDesC8& aDes,const TDesC8& aSub) const;
93 IMPORT_C TInt Find(const TDesC16& aDes,const TDesC16& aSub) const;
94 IMPORT_C TInt Find(const TText8* aPtr,TInt aLen,const TText8* aSubPtr,TInt aSubLen) const;
95 IMPORT_C TInt Find(const TText16* aPtr,TInt aLen,const TText16* aSubPtr,TInt aSubLen) const;
96 TInt Order(const TDesC16& aLeft, const TDesC16& aRight) const;
97 inline TInt Order(const TText16* aLeftPtr, TInt aLeftLen, const TText16* aRightPtr, TInt aRightLen) const;
99 TUint (*iFold)(TUint aChar);
100 TInt (*iCompare8)(const TText8*,TInt,const TText8*,TInt);
101 TInt (*iMatch8)(const TDesC8&,const TDesC8&);
102 TInt (*iFind8)(const TDesC8&,const TText8*,TInt);
103 TInt (*iCompare16)(const TText16*,TInt,const TText16*,TInt);
104 TInt (*iMatch16)(const TDesC16&,const TDesC16&);
105 TInt (*iFind16)(const TDesC16&,const TText16*,TInt);
106 TInt (*iOrder16)(const TText16*, TInt, const TText16*, TInt);
116 inline TDbBlob(TDbBlobId anId,TInt aSize=KDbUndefinedLength);
117 inline TDbBlob(const TUint8* aPtr,TInt aSize);
118 inline TUint8* InlineBuffer();
119 inline void SetId(TDbBlobId anId);
120 inline void SetSize(TInt aSize);
122 inline TBool IsInline() const;
123 inline TInt Size() const;
124 inline const TUint8* Data() const;
125 inline TPtrC8 PtrC8() const;
126 inline TPtrC16 PtrC16() const;
127 inline TDbBlobId Id() const;
129 inline TInt CellSize() const;
130 static inline TInt InlineSize(TInt aSize);
131 static inline TInt RefSize();
135 TUint8 iInline[KDbMaxInlineBlobSize];
144 static inline TInt Size(TInt aLength);
145 inline TInt Size() const; // total cell size
146 inline TDbCell* Next(); // pointer to next cell
147 inline const TDbCell* Next() const; // pointer to next cell
148 inline TInt Length() const; // data size
149 inline void SetLength(TInt aLength);
150 inline TAny* Data(); // data pointer
151 inline const TAny* Data() const; // data pointer
162 friend class TDbColumn;
164 inline TDbColumnC(const RDbRow& aRow,TDbColNo aCol);
165 inline TDbColumnC(const TDbColumn& aCol);
166 inline TInt Size() const;
167 inline TBool IsNull() const;
168 inline TInt8 Int8() const;
169 inline TInt16 Int16() const;
170 inline TInt32 Int32() const;
171 inline const TInt64& Int64() const;
172 inline TUint8 Uint8() const;
173 inline TUint16 Uint16() const;
174 inline TUint32 Uint32() const;
175 inline TReal32 Real32() const;
176 inline const TReal64& Real64() const;
177 inline TPtrC8 PtrC8() const;
178 inline TPtrC16 PtrC16() const;
179 inline const TTime& Time() const;
180 inline const TDbBlob& Blob() const;
182 const TDbCell* iCell;
190 friend class TDbColumnC;
193 inline TDbColumn(RDbRow& aRow,TDbColNo aCol);
194 inline void SetNull();
195 inline void SetL(TInt32 aValue);
196 IMPORT_C void SetL(TUint32 aValue);
197 IMPORT_C void SetL(TInt64 aValue);
198 IMPORT_C void SetL(TReal32 aValue) __SOFTFP;
199 IMPORT_C void SetL(TReal64 aValue) __SOFTFP;
200 IMPORT_C void SetL(const TDesC8& aValue);
201 IMPORT_C void SetL(const TDesC16& aValue);
202 inline void SetL(const TTime& aValue);
203 IMPORT_C void SetBlobL(TDbBlobId aBlobId,TInt aSize=KDbUndefinedLength);
204 IMPORT_C void SetBlobL(const TUint8* aData,TInt aSize);
206 IMPORT_C TDbBlob& InitBlobL();
207 IMPORT_C void CommitBlob(const TDbBlob& aBlob);
209 inline void SetL(const TDbCell* aCell);
210 inline void SetL(const TDbColumnC& aColumn);
212 inline RDbRow& Row() const;
213 IMPORT_C void SetL(const TAny* aPtr,TInt aSize);
224 friend class TDbColumn;
227 inline RDbRow(TAny* aBuf,TInt aMaxSize);
228 inline RDbRow(TAny* aBuf,TInt aSize,TInt aMaxSize);
229 inline void Open(TAny* aBuf,TInt aMaxSize);
230 IMPORT_C void Open(TAny* aBuf,TInt aSize,TInt aMaxSize);
231 IMPORT_C void CreateL(TInt aMaxSize);
233 IMPORT_C void Close();
236 inline TDbCell* First();
237 inline const TDbCell* First() const;
238 inline const TDbCell* Last() const;
239 inline const TDbCell* End() const;
240 IMPORT_C void SetSize(TInt aSize);
241 inline TInt Size() const;
242 inline TInt MaxSize() const;
243 IMPORT_C void GrowL(TInt aMaxSize);
244 // for use by data sources
245 static inline TInt Diff(const TDbCell* aBegin,const TDbCell* aEnd);
246 IMPORT_C const TDbCell* ColCell(TDbColNo aCol) const;
248 IMPORT_C TAny* SetColumnWidthL(TDbColNo aCol,TInt aWidth);
249 TDbCell* Column(TDbColNo aCol) const;
250 TInt ReallocL(TInt aMaxSize);
251 void ExtendL(TInt aAdjust); // change the row buffer length
253 inline TBool Owned() const;
254 inline TInt Column() const;
255 inline void SetCache(TDbCell* aCell,TInt aColumn);
257 enum {EOwned=0x80000000};
258 enum {EGranularity=0x100};
260 TDbCell* iFirst; // first column
261 TDbCell* iLast; // pointer past last cell
262 TDbCell* iEnd; // pointer past end of available buffer
263 TDbCell* iCell; // cached cell pointer
264 TUint iColumn; // cached column number/ownership flag
271 class CDbObject : public CBase
273 friend class CDbContext;
275 static void Destroy(CDbObject* aObject); // context-safe deletion
276 CDbObject* Attach(CDbObject* aObject);
277 inline const CDbContext* Context() const;
281 inline CDbObject() {}
283 CDbContext* iContext;
289 class CDbRowConstraint : public CDbObject
292 CDbRowConstraint() {}
298 class CDbCursor : public CDbObject
301 enum TInsert {EClear,ECopy};
306 virtual void Reset() =0;
307 virtual TBool EvaluateL()=0;
309 virtual void Evaluate(TRequestStatus& aStatus)=0;
310 virtual TBool Unevaluated()=0;
312 virtual void SetIndexL(const TDesC* anIndex)=0;
313 virtual TBool SeekL(const TDbLookupKey& aKey,RDbTable::TComparison aComparison) =0;
314 CDbRowConstraint* ConstraintL(const TDbQuery& aCriteria);
315 virtual TBool MatchL(CDbRowConstraint& aConstraint) =0;
316 IMPORT_C virtual TInt FindL(RDbRowSet::TDirection aDirection,const TDbQuery& aCriteria);
318 virtual TBool AtBeginning()=0;
319 virtual TBool AtEnd()=0;
320 virtual TBool AtRow()=0;
321 IMPORT_C virtual TInt CountL(RDbRowSet::TAccuracy aAccuracy);
322 virtual TBool GotoL(RDbRowSet::TPosition aPosition)=0;
323 virtual void Bookmark(TDbBookmark::TMark& aMark) =0;
324 virtual void GotoL(const TDbBookmark::TMark& aMark) =0;
325 virtual void GetL()=0;
326 virtual void InsertL(TInsert aClearRow)=0;
327 virtual void UpdateL()=0;
328 virtual void Cancel()=0;
329 virtual void PutL()=0;
330 virtual void DeleteL()=0;
332 virtual TInt ColumnCount()=0;
333 IMPORT_C virtual void ColumnsL(CDbColSet& aColSet);
334 virtual void ColumnDef(TDbCol& aCol,TDbColNo aColNo)=0;
335 virtual TDbColType ColumnType(TDbColNo aCol)=0;
337 virtual TDbColumnC ColumnC(TDbColNo aCol)=0; // non-writeable column
338 virtual TDbColumn Column(TDbColNo aCol)=0; // writeable column
339 virtual void SetNullL(TDbColNo aCol)=0;
340 virtual TInt ColumnSize(TDbColNo aCol)=0;
341 // Optimized whole row access for server
342 virtual RDbRow* RowBuffer() =0;
344 virtual MStreamBuf* ColumnSourceL(TDbColNo aCol)=0;
345 virtual MStreamBuf* ColumnSinkL(TDbColNo aCol)=0;
347 virtual CDbRowConstraint* OpenConstraintL(const TDbQuery& aCriteria) =0;
349 IMPORT_C virtual void Reserved_1();
350 IMPORT_C virtual void Reserved_2();
356 class CDbIncremental : public CDbObject
361 virtual TBool NextL(TInt& aStep) =0;
362 virtual void Next(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus) =0;
368 class CDbSyncIncremental : public CDbIncremental
371 CDbSyncIncremental() {}
373 IMPORT_C void Next(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus);
379 class CDbAsyncIncremental : public CDbIncremental
382 CDbAsyncIncremental() {}
384 IMPORT_C TBool NextL(TInt& aStep);
390 class CDbDatabase : public CDbObject
395 enum TUtility {EStats=1,ECompact,ERecover};
396 enum TProperty {EUpdateStats=-EStats,ECompactable=-ECompact,EIsDamaged=-ERecover,
397 EInTransaction=0,ESize,EUsage};
400 virtual TInt Destroy()=0;
401 virtual TInt Begin()=0;
402 virtual TInt Commit()=0;
403 virtual void Rollback()=0;
404 virtual TInt Property(TProperty aProperty) =0;
405 virtual void CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey)=0;
406 CDbNotifier* NotifierL();
407 CDbIncremental* UtilityL(TUtility aType,TInt& aStep);
408 CDbIncremental* DropTableL(const TDesC& aTable,TInt& aStep);
409 CDbIncremental* AlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep);
410 CDbIncremental* CreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep);
411 CDbIncremental* DropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep);
412 CDbIncremental* ExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit);
413 CDbCursor* ViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess anAccess);
414 CDbCursor* TableL(const TDesC& aName,RDbRowSet::TAccess anAccess);
415 virtual void TablesL(CDbTableNames& aNames)=0;
416 virtual void ColumnsL(CDbColSet& aColSet,const TDesC& aName)=0;
417 virtual void IndexesL(CDbIndexNames& aNames,const TDesC& aTable)=0;
418 virtual void KeysL(CDbKey& aKey,const TDesC& aName,const TDesC& aTable)=0;
420 virtual CDbNotifier* OpenNotifierL() =0;
421 virtual CDbIncremental* OpenUtilityL(TUtility aType,TInt& aStep) =0;
422 virtual CDbIncremental* OpenDropTableL(const TDesC& aTable,TInt& aStep) =0;
423 virtual CDbIncremental* OpenAlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep) =0;
424 virtual CDbIncremental* OpenCreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep) =0;
425 virtual CDbIncremental* OpenDropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep) =0;
426 virtual CDbCursor* PrepareViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess anAccess) =0;
427 virtual CDbCursor* OpenTableL(const TDesC& aName,RDbRowSet::TAccess anAccess) =0;
428 virtual CDbIncremental* OpenExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit) =0;
430 IMPORT_C virtual void Reserved_1();
431 IMPORT_C virtual void Reserved_2();
437 class CDbNotifier : public CDbObject
440 enum TType {EUnlock=-1,EChange=-2};
445 virtual void Notify(TType aEvent,TRequestStatus& aStatus) =0;
446 virtual void Cancel() =0;
451 CDbSource class declaration - SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version
454 class CDbSource : public CDbObject
461 CDbDatabase* OpenL();
462 virtual CDbDatabase* AuthenticateL() = 0;
463 CDbNotifier* NotifierL();
465 virtual CDbNotifier* OpenNotifierL() =0;
476 const TDbFormat* iFormats;
485 enum TCreate {ECreate,EReplace};
486 enum TOpen {EReadWrite,EReadOnly};
487 typedef CDbDatabase* (*FCreateL)(RFs& aFs, const TDesC& aName, TCreate aMode,
488 const TUidType& aType);
489 typedef CDbSource* (*FOpenL)(RFs& aFs,const TDesC& aName,TOpen aMode);
494 TInt32 iUid[KMaxCheckedUid];
500 #define KDbmsDriverUidValue KDbmsDriverUidValue16
501 #define KDbmsDriverUid KDbmsDriverUid16
506 const TInt32 KDbmsDriverUidValue8=0x10000EBC;
507 const TUid KDbmsDriverUid8={KDbmsDriverUidValue8};
508 const TInt32 KDbmsDriverUidValue16=0x10003B0F;
509 const TUid KDbmsDriverUid16={KDbmsDriverUidValue16};
511 #include "D32DBAS.INL"