1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/inc/D32DBAS.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,512 @@
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 +#if !defined(__D32DBAS_H__)
1.20 +#define __D32DBAS_H__
1.21 +#if !defined(__D32DBMS_H__)
1.22 +#include <d32dbms.h>
1.23 +#endif
1.24 +
1.25 +// other classes referenced
1.26 +class RFs;
1.27 +class CDbContext;
1.28 +
1.29 +// classes defined
1.30 +class TTextOps;
1.31 +class TDbBlob;
1.32 +class TDbCell;
1.33 +class TDbColumnC;
1.34 +class TDbColumn;
1.35 +class RDbRow;
1.36 +class CDbObject;
1.37 +class CDbRowConstraint;
1.38 +class CDbCursor;
1.39 +class CDbNotifier;
1.40 +class CDbIncremental;
1.41 +class CDbSyncIncremental;
1.42 +class CDbAsyncIncremental;
1.43 +class CDbDatabase;
1.44 +class CDbSource;
1.45 +class TDbDriver;
1.46 +class TDbFormat;
1.47 +
1.48 +/**
1.49 +@internalComponent
1.50 +*/
1.51 +const TInt KDbMaxFormatName=32;
1.52 +const TInt KDbMaxDatabaseName=KMaxFileName;
1.53 +
1.54 +/**
1.55 +@internalComponent
1.56 +*/
1.57 +const TInt KDbMaxInlineBlobSize=255;
1.58 +
1.59 +/**
1.60 +@internalComponent
1.61 +*/
1.62 +typedef TUint32 TDbBlobId;
1.63 +
1.64 +/**
1.65 +@internalComponent
1.66 +*/
1.67 +const TDbBlobId KDbNullBlobId=0;
1.68 +
1.69 +/**
1.70 +@internalComponent
1.71 +*/
1.72 +class Dbms
1.73 + {
1.74 +public:
1.75 + IMPORT_C static void Panic(const TDesC& aCategory,TInt aCode);
1.76 + };
1.77 +
1.78 +/**
1.79 +@internalComponent
1.80 +*/
1.81 +class TTextOps
1.82 + {
1.83 +public:
1.84 + IMPORT_C static const TTextOps& Ops(TDbTextComparison aType=EDbCompareNormal);
1.85 +//
1.86 + inline TUint Fold(TUint aChar) const;
1.87 + IMPORT_C TInt Compare(const TDesC8& aLeft,const TDesC8& aRight) const;
1.88 + IMPORT_C TInt Compare(const TDesC16& aLeft,const TDesC16& aRight) const;
1.89 + inline TInt Compare(const TText8* aLeftPtr,TInt aLeftLen,const TText8* aRightPtr,TInt aRightLen) const;
1.90 + inline TInt Compare(const TText16* aLeftPtr,TInt aLeftLen,const TText16* aRightPtr,TInt aRightLen) const;
1.91 + inline TInt Match(const TDesC8& aDes,const TDesC8& aPattern) const;
1.92 + inline TInt Match(const TDesC16& aDes,const TDesC16& aPattern) const;
1.93 + IMPORT_C TInt Match(const TText8* aPtr,TInt aLen,const TText8* aPatternPtr,TInt aPatternLen) const;
1.94 + IMPORT_C TInt Match(const TText16* aPtr,TInt aLen,const TText16* aPatternPtr,TInt aPatternLen) const;
1.95 + IMPORT_C TInt Find(const TDesC8& aDes,const TDesC8& aSub) const;
1.96 + IMPORT_C TInt Find(const TDesC16& aDes,const TDesC16& aSub) const;
1.97 + IMPORT_C TInt Find(const TText8* aPtr,TInt aLen,const TText8* aSubPtr,TInt aSubLen) const;
1.98 + IMPORT_C TInt Find(const TText16* aPtr,TInt aLen,const TText16* aSubPtr,TInt aSubLen) const;
1.99 + TInt Order(const TDesC16& aLeft, const TDesC16& aRight) const;
1.100 + inline TInt Order(const TText16* aLeftPtr, TInt aLeftLen, const TText16* aRightPtr, TInt aRightLen) const;
1.101 +public:
1.102 + TUint (*iFold)(TUint aChar);
1.103 + TInt (*iCompare8)(const TText8*,TInt,const TText8*,TInt);
1.104 + TInt (*iMatch8)(const TDesC8&,const TDesC8&);
1.105 + TInt (*iFind8)(const TDesC8&,const TText8*,TInt);
1.106 + TInt (*iCompare16)(const TText16*,TInt,const TText16*,TInt);
1.107 + TInt (*iMatch16)(const TDesC16&,const TDesC16&);
1.108 + TInt (*iFind16)(const TDesC16&,const TText16*,TInt);
1.109 + TInt (*iOrder16)(const TText16*, TInt, const TText16*, TInt);
1.110 + };
1.111 +
1.112 +/**
1.113 +@internalComponent
1.114 +*/
1.115 +class TDbBlob
1.116 + {
1.117 +public:
1.118 + inline TDbBlob();
1.119 + inline TDbBlob(TDbBlobId anId,TInt aSize=KDbUndefinedLength);
1.120 + inline TDbBlob(const TUint8* aPtr,TInt aSize);
1.121 + inline TUint8* InlineBuffer();
1.122 + inline void SetId(TDbBlobId anId);
1.123 + inline void SetSize(TInt aSize);
1.124 +//
1.125 + inline TBool IsInline() const;
1.126 + inline TInt Size() const;
1.127 + inline const TUint8* Data() const;
1.128 + inline TPtrC8 PtrC8() const;
1.129 + inline TPtrC16 PtrC16() const;
1.130 + inline TDbBlobId Id() const;
1.131 +//
1.132 + inline TInt CellSize() const;
1.133 + static inline TInt InlineSize(TInt aSize);
1.134 + static inline TInt RefSize();
1.135 +private:
1.136 + TDbBlobId iId;
1.137 + TInt iSize;
1.138 + TUint8 iInline[KDbMaxInlineBlobSize];
1.139 + };
1.140 +
1.141 +/**
1.142 +@internalComponent
1.143 +*/
1.144 +class TDbCell
1.145 + {
1.146 +public:
1.147 + static inline TInt Size(TInt aLength);
1.148 + inline TInt Size() const; // total cell size
1.149 + inline TDbCell* Next(); // pointer to next cell
1.150 + inline const TDbCell* Next() const; // pointer to next cell
1.151 + inline TInt Length() const; // data size
1.152 + inline void SetLength(TInt aLength);
1.153 + inline TAny* Data(); // data pointer
1.154 + inline const TAny* Data() const; // data pointer
1.155 +private:
1.156 + TInt iLength;
1.157 + TUint8 iBuf[1];
1.158 + };
1.159 +
1.160 +/**
1.161 +@internalComponent
1.162 +*/
1.163 +class TDbColumnC
1.164 + {
1.165 + friend class TDbColumn;
1.166 +public:
1.167 + inline TDbColumnC(const RDbRow& aRow,TDbColNo aCol);
1.168 + inline TDbColumnC(const TDbColumn& aCol);
1.169 + inline TInt Size() const;
1.170 + inline TBool IsNull() const;
1.171 + inline TInt8 Int8() const;
1.172 + inline TInt16 Int16() const;
1.173 + inline TInt32 Int32() const;
1.174 + inline const TInt64& Int64() const;
1.175 + inline TUint8 Uint8() const;
1.176 + inline TUint16 Uint16() const;
1.177 + inline TUint32 Uint32() const;
1.178 + inline TReal32 Real32() const;
1.179 + inline const TReal64& Real64() const;
1.180 + inline TPtrC8 PtrC8() const;
1.181 + inline TPtrC16 PtrC16() const;
1.182 + inline const TTime& Time() const;
1.183 + inline const TDbBlob& Blob() const;
1.184 +private:
1.185 + const TDbCell* iCell;
1.186 + };
1.187 +
1.188 +/**
1.189 +@internalComponent
1.190 +*/
1.191 +class TDbColumn
1.192 + {
1.193 + friend class TDbColumnC;
1.194 +public:
1.195 + inline TDbColumn();
1.196 + inline TDbColumn(RDbRow& aRow,TDbColNo aCol);
1.197 + inline void SetNull();
1.198 + inline void SetL(TInt32 aValue);
1.199 + IMPORT_C void SetL(TUint32 aValue);
1.200 + IMPORT_C void SetL(TInt64 aValue);
1.201 + IMPORT_C void SetL(TReal32 aValue) __SOFTFP;
1.202 + IMPORT_C void SetL(TReal64 aValue) __SOFTFP;
1.203 + IMPORT_C void SetL(const TDesC8& aValue);
1.204 + IMPORT_C void SetL(const TDesC16& aValue);
1.205 + inline void SetL(const TTime& aValue);
1.206 + IMPORT_C void SetBlobL(TDbBlobId aBlobId,TInt aSize=KDbUndefinedLength);
1.207 + IMPORT_C void SetBlobL(const TUint8* aData,TInt aSize);
1.208 +//
1.209 + IMPORT_C TDbBlob& InitBlobL();
1.210 + IMPORT_C void CommitBlob(const TDbBlob& aBlob);
1.211 +//
1.212 + inline void SetL(const TDbCell* aCell);
1.213 + inline void SetL(const TDbColumnC& aColumn);
1.214 +private:
1.215 + inline RDbRow& Row() const;
1.216 + IMPORT_C void SetL(const TAny* aPtr,TInt aSize);
1.217 +private:
1.218 + RDbRow* iRow;
1.219 + TDbColNo iColumn;
1.220 + };
1.221 +
1.222 +/**
1.223 +@internalComponent
1.224 +*/
1.225 +class RDbRow
1.226 + {
1.227 + friend class TDbColumn;
1.228 +public:
1.229 + IMPORT_C RDbRow();
1.230 + inline RDbRow(TAny* aBuf,TInt aMaxSize);
1.231 + inline RDbRow(TAny* aBuf,TInt aSize,TInt aMaxSize);
1.232 + inline void Open(TAny* aBuf,TInt aMaxSize);
1.233 + IMPORT_C void Open(TAny* aBuf,TInt aSize,TInt aMaxSize);
1.234 + IMPORT_C void CreateL(TInt aMaxSize);
1.235 + void PushL();
1.236 + IMPORT_C void Close();
1.237 + inline void Reset();
1.238 +//
1.239 + inline TDbCell* First();
1.240 + inline const TDbCell* First() const;
1.241 + inline const TDbCell* Last() const;
1.242 + inline const TDbCell* End() const;
1.243 + IMPORT_C void SetSize(TInt aSize);
1.244 + inline TInt Size() const;
1.245 + inline TInt MaxSize() const;
1.246 + IMPORT_C void GrowL(TInt aMaxSize);
1.247 +// for use by data sources
1.248 + static inline TInt Diff(const TDbCell* aBegin,const TDbCell* aEnd);
1.249 + IMPORT_C const TDbCell* ColCell(TDbColNo aCol) const;
1.250 +private:
1.251 + IMPORT_C TAny* SetColumnWidthL(TDbColNo aCol,TInt aWidth);
1.252 + TDbCell* Column(TDbColNo aCol) const;
1.253 + TInt ReallocL(TInt aMaxSize);
1.254 + void ExtendL(TInt aAdjust); // change the row buffer length
1.255 +//
1.256 + inline TBool Owned() const;
1.257 + inline TInt Column() const;
1.258 + inline void SetCache(TDbCell* aCell,TInt aColumn);
1.259 +private:
1.260 + enum {EOwned=0x80000000};
1.261 + enum {EGranularity=0x100};
1.262 +private:
1.263 + TDbCell* iFirst; // first column
1.264 + TDbCell* iLast; // pointer past last cell
1.265 + TDbCell* iEnd; // pointer past end of available buffer
1.266 + TDbCell* iCell; // cached cell pointer
1.267 + TUint iColumn; // cached column number/ownership flag
1.268 + };
1.269 +
1.270 +
1.271 +/**
1.272 +@internalComponent
1.273 +*/
1.274 +class CDbObject : public CBase
1.275 + {
1.276 + friend class CDbContext;
1.277 +public:
1.278 + static void Destroy(CDbObject* aObject); // context-safe deletion
1.279 + CDbObject* Attach(CDbObject* aObject);
1.280 + inline const CDbContext* Context() const;
1.281 +//
1.282 + void PushL();
1.283 +protected:
1.284 + inline CDbObject() {}
1.285 +private:
1.286 + CDbContext* iContext;
1.287 + };
1.288 +
1.289 +/**
1.290 +@internalComponent
1.291 +*/
1.292 +class CDbRowConstraint : public CDbObject
1.293 + {
1.294 +protected:
1.295 + CDbRowConstraint() {}
1.296 + };
1.297 +
1.298 +/**
1.299 +@internalComponent
1.300 +*/
1.301 +class CDbCursor : public CDbObject
1.302 + {
1.303 +public:
1.304 + enum TInsert {EClear,ECopy};
1.305 +protected:
1.306 + CDbCursor() {}
1.307 +public:
1.308 +// Pure virtual
1.309 + virtual void Reset() =0;
1.310 + virtual TBool EvaluateL()=0;
1.311 + TInt Evaluate();
1.312 +// virtual void Evaluate(TRequestStatus& aStatus)=0;
1.313 + virtual TBool Unevaluated()=0;
1.314 +//
1.315 + virtual void SetIndexL(const TDesC* anIndex)=0;
1.316 + virtual TBool SeekL(const TDbLookupKey& aKey,RDbTable::TComparison aComparison) =0;
1.317 + CDbRowConstraint* ConstraintL(const TDbQuery& aCriteria);
1.318 + virtual TBool MatchL(CDbRowConstraint& aConstraint) =0;
1.319 + IMPORT_C virtual TInt FindL(RDbRowSet::TDirection aDirection,const TDbQuery& aCriteria);
1.320 +//
1.321 + virtual TBool AtBeginning()=0;
1.322 + virtual TBool AtEnd()=0;
1.323 + virtual TBool AtRow()=0;
1.324 + IMPORT_C virtual TInt CountL(RDbRowSet::TAccuracy aAccuracy);
1.325 + virtual TBool GotoL(RDbRowSet::TPosition aPosition)=0;
1.326 + virtual void Bookmark(TDbBookmark::TMark& aMark) =0;
1.327 + virtual void GotoL(const TDbBookmark::TMark& aMark) =0;
1.328 + virtual void GetL()=0;
1.329 + virtual void InsertL(TInsert aClearRow)=0;
1.330 + virtual void UpdateL()=0;
1.331 + virtual void Cancel()=0;
1.332 + virtual void PutL()=0;
1.333 + virtual void DeleteL()=0;
1.334 +// column validation
1.335 + virtual TInt ColumnCount()=0;
1.336 + IMPORT_C virtual void ColumnsL(CDbColSet& aColSet);
1.337 + virtual void ColumnDef(TDbCol& aCol,TDbColNo aColNo)=0;
1.338 + virtual TDbColType ColumnType(TDbColNo aCol)=0;
1.339 +// Column Accessors
1.340 + virtual TDbColumnC ColumnC(TDbColNo aCol)=0; // non-writeable column
1.341 + virtual TDbColumn Column(TDbColNo aCol)=0; // writeable column
1.342 + virtual void SetNullL(TDbColNo aCol)=0;
1.343 + virtual TInt ColumnSize(TDbColNo aCol)=0;
1.344 +// Optimized whole row access for server
1.345 + virtual RDbRow* RowBuffer() =0;
1.346 +// Blob functions
1.347 + virtual MStreamBuf* ColumnSourceL(TDbColNo aCol)=0;
1.348 + virtual MStreamBuf* ColumnSinkL(TDbColNo aCol)=0;
1.349 +private:
1.350 + virtual CDbRowConstraint* OpenConstraintL(const TDbQuery& aCriteria) =0;
1.351 +// Reserved virtuals
1.352 + IMPORT_C virtual void Reserved_1();
1.353 + IMPORT_C virtual void Reserved_2();
1.354 + };
1.355 +
1.356 +/**
1.357 +@internalComponent
1.358 +*/
1.359 +class CDbIncremental : public CDbObject
1.360 + {
1.361 +protected:
1.362 + CDbIncremental() {}
1.363 +public:
1.364 + virtual TBool NextL(TInt& aStep) =0;
1.365 +// virtual void Next(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus) =0;
1.366 + };
1.367 +
1.368 +/**
1.369 +@internalComponent
1.370 +*/
1.371 +class CDbSyncIncremental : public CDbIncremental
1.372 + {
1.373 +protected:
1.374 + CDbSyncIncremental() {}
1.375 +private:
1.376 +// IMPORT_C void Next(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus);
1.377 + };
1.378 +
1.379 +/**
1.380 +@internalComponent
1.381 +*/
1.382 +class CDbAsyncIncremental : public CDbIncremental
1.383 + {
1.384 +protected:
1.385 + CDbAsyncIncremental() {}
1.386 +private:
1.387 + IMPORT_C TBool NextL(TInt& aStep);
1.388 + };
1.389 +
1.390 +/**
1.391 +@internalComponent
1.392 +*/
1.393 +class CDbDatabase : public CDbObject
1.394 + {
1.395 +protected:
1.396 + CDbDatabase() {}
1.397 +public:
1.398 + enum TUtility {EStats=1,ECompact,ERecover};
1.399 + enum TProperty {EUpdateStats=-EStats,ECompactable=-ECompact,EIsDamaged=-ERecover,
1.400 + EInTransaction=0,ESize,EUsage};
1.401 +public:
1.402 +// Pure virtual
1.403 + virtual TInt Destroy()=0;
1.404 + virtual TInt Begin()=0;
1.405 + virtual TInt Commit()=0;
1.406 + virtual void Rollback()=0;
1.407 + virtual TInt Property(TProperty aProperty) =0;
1.408 + virtual void CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey)=0;
1.409 + CDbNotifier* NotifierL();
1.410 + CDbIncremental* UtilityL(TUtility aType,TInt& aStep);
1.411 + CDbIncremental* DropTableL(const TDesC& aTable,TInt& aStep);
1.412 + CDbIncremental* AlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep);
1.413 + CDbIncremental* CreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep);
1.414 + CDbIncremental* DropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep);
1.415 + CDbIncremental* ExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit);
1.416 + CDbCursor* ViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess anAccess);
1.417 + CDbCursor* TableL(const TDesC& aName,RDbRowSet::TAccess anAccess);
1.418 + virtual void TablesL(CDbTableNames& aNames)=0;
1.419 + virtual void ColumnsL(CDbColSet& aColSet,const TDesC& aName)=0;
1.420 + virtual void IndexesL(CDbIndexNames& aNames,const TDesC& aTable)=0;
1.421 + virtual void KeysL(CDbKey& aKey,const TDesC& aName,const TDesC& aTable)=0;
1.422 +private:
1.423 + virtual CDbNotifier* OpenNotifierL() =0;
1.424 + virtual CDbIncremental* OpenUtilityL(TUtility aType,TInt& aStep) =0;
1.425 + virtual CDbIncremental* OpenDropTableL(const TDesC& aTable,TInt& aStep) =0;
1.426 + virtual CDbIncremental* OpenAlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep) =0;
1.427 + virtual CDbIncremental* OpenCreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep) =0;
1.428 + virtual CDbIncremental* OpenDropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep) =0;
1.429 + virtual CDbCursor* PrepareViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess anAccess) =0;
1.430 + virtual CDbCursor* OpenTableL(const TDesC& aName,RDbRowSet::TAccess anAccess) =0;
1.431 + virtual CDbIncremental* OpenExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit) =0;
1.432 +// Reserved virtuals
1.433 + IMPORT_C virtual void Reserved_1();
1.434 + IMPORT_C virtual void Reserved_2();
1.435 + };
1.436 +
1.437 +/**
1.438 +@internalComponent
1.439 +*/
1.440 +class CDbNotifier : public CDbObject
1.441 + {
1.442 +public:
1.443 + enum TType {EUnlock=-1,EChange=-2};
1.444 +protected:
1.445 + CDbNotifier() {}
1.446 +public:
1.447 +// pure virtual
1.448 +// virtual void Notify(TType aEvent,TRequestStatus& aStatus) =0;
1.449 + virtual void Cancel() =0;
1.450 + };
1.451 +
1.452 +
1.453 +/**
1.454 +CDbSource class declaration - SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version
1.455 +@internalComponent
1.456 +*/
1.457 +class CDbSource : public CDbObject
1.458 + {
1.459 +protected:
1.460 + CDbSource()
1.461 + {
1.462 + }
1.463 +public:
1.464 + CDbDatabase* OpenL();
1.465 + virtual CDbDatabase* AuthenticateL() = 0;
1.466 + CDbNotifier* NotifierL();
1.467 +private:
1.468 + virtual CDbNotifier* OpenNotifierL() =0;
1.469 + };
1.470 +
1.471 +
1.472 +/**
1.473 +@internalComponent
1.474 +*/
1.475 +class TDbDriver
1.476 + {
1.477 +public:
1.478 + TInt iCount;
1.479 + const TDbFormat* iFormats;
1.480 + };
1.481 +
1.482 +/**
1.483 +@internalComponent
1.484 +*/
1.485 +class TDbFormat
1.486 + {
1.487 +public:
1.488 + enum TCreate {ECreate,EReplace};
1.489 + enum TOpen {EReadWrite,EReadOnly};
1.490 + typedef CDbDatabase* (*FCreateL)(RFs& aFs, const TDesC& aName, TCreate aMode,
1.491 + const TUidType& aType);
1.492 + typedef CDbSource* (*FOpenL)(RFs& aFs,const TDesC& aName,TOpen aMode);
1.493 +public:
1.494 + const TText* iName;
1.495 + FCreateL CreateL;
1.496 + FOpenL OpenL;
1.497 + TInt32 iUid[KMaxCheckedUid];
1.498 + };
1.499 +
1.500 +/**
1.501 +@internalComponent
1.502 +*/
1.503 +#define KDbmsDriverUidValue KDbmsDriverUidValue16
1.504 +#define KDbmsDriverUid KDbmsDriverUid16
1.505 +
1.506 +/**
1.507 +@internalComponent
1.508 +*/
1.509 +const TInt32 KDbmsDriverUidValue8=0x10000EBC;
1.510 +const TUid KDbmsDriverUid8={KDbmsDriverUidValue8};
1.511 +const TInt32 KDbmsDriverUidValue16=0x10003B0F;
1.512 +const TUid KDbmsDriverUid16={KDbmsDriverUidValue16};
1.513 +
1.514 +#include "D32DBAS.INL"
1.515 +#endif