Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__D32DBMS_H__)
26 // other classes referenced
29 class CDbRowConstraint;
46 template<class T> class RDbHandle;
47 class RDbRowConstraint;
49 class RDbColReadStream;
50 class RDbColWriteStream;
53 template<class T> class TUnion;
56 template<TInt S> class TDbSeekMultiKey;
64 class RDbNamedDatabase;
65 class RDbStoreDatabase;
68 The maximum length for a DBMS name: 64 characters.
72 const TInt KDbMaxName=0x40;
75 The maximum length for a DBMS column name: 64 characters.
79 const TInt KDbMaxColName=KDbMaxName;
82 Represents a writable DBMS name. It maps to a modifiable buffer descriptor
83 with maximum size KDbMaxName.
87 A DBMS name must begin with an alphabetic character, after which any alphabetic,
88 numeric or the _ (underscore) character may be used. DBMS names are also limited
89 to 64 characters in length.
91 Table names must be unique within a database, and columns and indexes must
92 have unique names within the table to which they belong. For the purposes
93 of uniqueness and identification, the names are folded before comparison,
94 so two columns named column_one and Column_ONE are considered to have the
101 typedef TBuf<KDbMaxName> TDbName;
103 /** Represents a non-writeable DBMS name. It maps to a non modifiable buffer descriptor
104 with maximum size KDbMaxName.
108 A DBMS name must begin with an alphabetic character, after which any alphabetic,
109 numeric or the _ (underscore) character may be used. DBMS names are also limited
110 to 64 characters in length.
112 Table names must be unique within a database, and columns and indexes must
113 have unique names within the table to which they belong. For the purposes
114 of uniqueness and identification, the names are folded before comparison,
115 so two columns named column_one and Column_ONE are considered to have the
122 typedef TBufC<KDbMaxName> TDbNameC;
124 /** Represents a writable DBMS column name. It maps to a modifiable buffer descriptor
125 with maximum size KDbMaxColName.
129 A DBMS name must begin with an alphabetic character, after which any alphabetic,
130 numeric or the _ (underscore) character may be used. DBMS names are also limited
131 to 64 characters in length.
133 Table names must be unique within a database, and columns and indexes must
134 have unique names within the table to which they belong. For the purposes
135 of uniqueness and identification, the names are folded before comparison,
136 so two columns named column_one and Column_ONE are considered to have the
141 typedef TBuf<KDbMaxColName> TDbColName;
143 /** Represents a non-writable DBMS column name. It maps to a non-modifiable buffer
144 descriptor with maximum size KDbMaxColName.
148 A DBMS name must begin with an alphabetic character, after which any alphabetic,
149 numeric or the _ (underscore) character may be used. DBMS names are also limited
150 to 64 characters in length.
152 Table names must be unique within a database, and columns and indexes must
153 have unique names within the table to which they belong. For the purposes
154 of uniqueness and identification, the names are folded before comparison,
155 so two columns named column_one and Column_ONE are considered to have the
162 typedef TBufC<KDbMaxColName> TDbColNameC;
164 /** Specifies when DBMS objects require a column ordinal to identify a column in
165 a column set or in a rowset.
167 Note that KDbNullColNo is a special value of TDbColNo used to indicate that
168 no such column exists.
172 typedef TInt TDbColNo;
175 Indicates that a specified column does not exist.
179 const TDbColNo KDbNullColNo=0;
182 A value returned by RDbRowSet::Count() when the number of rows cannot be determined.
188 const TInt KDbUndefinedCount=-1;
191 The length of a column is undefined.
195 const TInt KDbUndefinedLength=-1;
198 The default text column length. This is equal to 50.
202 const TInt KDbDefaultTextColLength=50;
205 Represents every supported column type.
211 /** The column stores a single bit.
213 Representation range: 0 to 1
222 /** The column stores an 8-bit signed integer.
224 Representation range: -2^7 to 2^7 - 1
233 /** The column stores an 8-bit unsigned integer.
235 Representation range: 0 to 2^8-1
244 /** The column stores a 16-bit signed integer.
246 Representation range: -2^15 to 2^15 - 1
255 /** The column stores a 16-bit unsigned integer.
257 Representation range: 0 to 2^16-1
266 /** The column stores a 32-bit signed integer.
268 Representation range: -2^31 to 2^31 - 1
277 /** The column stores a 32-bit unsigned integer.
279 Representation range: 0 to 2^32-1
288 /** The column stores a 64-bit signed integer.
290 Representation range: -2^63 to 2^63 - 1
299 /** The column stores a 32-bit floating point value.
301 Representation range: 1.4 X 10^-45 to 3.40282 X 10^38
310 /** The column stores a 64-bit floating point value.
312 Representation range: 2.2 X 10^-308 to 1.79769 X 10^308
321 /** The column stores a date/time value.
323 Representation range: 1/1/0 to 31/12/9999
332 /** The column stores a (short) variable length of non-Unicode text data.
334 Representation range: 0 to 256 characters
336 Storage: 0 to 256 bytes
343 /** The column stores a (short) variable length of Unicode text data.
345 Representation range: 0 to 256 characters
347 Storage: 0 to 512 bytes
354 /** The column stores a (short) variable length of untyped data.
356 Representation range: 0 to 255 bytes
358 Storage: 0 to 256 bytes
365 /** The column stores a potentially large amount of non-Unicode text data.
367 Representation range: 0 to 2^31 characters
369 Storage: 0 to 2 Gbytes
373 Index key: Truncated */
376 /** The column stores a potentially large amount of Unicode text data.
378 Representation range: 0 to 2^30 characters
380 Storage: 0 to 2 Gbytes
384 Index key: Truncated */
387 /** The column stores a potentially large amount of untyped data.
389 Representation range: 0 to 2^31 bytes
391 Storage: 0 to 2 Gbytes
398 /** This is equivalent to EDbColText8 if the build is narrow, and
399 EDbColText16 if the build is Unicode. */
400 EDbColText=EDbColText16,
402 /** This is equivalent to EDbColLongText8 if the build is narrow, and
403 EDbColLongText16 if the build is Unicode. */
404 EDbColLongText=EDbColLongText16
408 Represents different ways of comparing Text and LongText columns.
410 This affects the ordering of indexes (see CDbKey), the evaluation of SQL
411 queries and matching row constraints (see TDbQuery).
415 enum TDbTextComparison
417 /** Use standard text comparison and ordering. */
419 /** Use folded text for comparison and ordering. */
421 /** Use collation for comparison and ordering. */
426 Defines a column in a table or rowset.
428 The data members are public because this is really a structure to group the
429 attributes of the column together.
431 Three non-default constructors are provided for convenience.
437 friend class CDbColSet;
439 enum {ENotNull=0x01,EAutoIncrement=0x02};
441 /** Constructs an uninitialised TDbCol. It is necessary because there are
442 also non-default constructors in this class. */
444 inline TDbCol(const TDbCol&);
445 inline TDbCol& operator=(const TDbCol&);
446 IMPORT_C TDbCol(const TDesC& aName,TDbColType aType);
447 IMPORT_C TDbCol(const TDesC& aName,TDbColType aType,TInt aMaxLength);
448 static inline TBool IsLong(TDbColType aType);
450 inline TDbCol(const TDesC& aName);
452 /** The column type. */
454 /** The maximum length of data that can be stored in a Text or Binary
457 /** A set of flags describing other column attributes. This must be one
458 of the anonymous enum values ENotNull or EAutoIncrement. */
460 /** The column name. */
464 /** Manages a set of column definitions which describe a table or rowset
465 structure. Column definitions can be added and removed. The set can be
466 iterated over, and ordinals for a column can be looked up.
468 The class is not intended for user derivation.
472 class CDbColSet : public CBase
474 friend class TDbColSetIter;
476 IMPORT_C CDbColSet();
477 IMPORT_C static CDbColSet* NewL();
478 IMPORT_C static CDbColSet* NewLC();
479 IMPORT_C ~CDbColSet();
480 inline const TDbCol& operator[](TDbColNo aCol) const;
481 IMPORT_C const TDbCol* Col(const TDesC& aColName) const;
482 IMPORT_C TDbColNo ColNo(const TDesC& aColName) const;
483 inline TInt Count() const;
485 IMPORT_C CDbColSet& AddL(const TDbCol& aCol);
486 IMPORT_C void Remove(const TDesC& aColName);
488 CArrayPakFlat<TDbCol> iColumns;
492 Provides a useful way to iterate over the contents of a column set.
499 IMPORT_C TDbColSetIter(const CDbColSet& aColSet);
500 inline operator TAny* () const;
501 inline const TDbCol& operator*() const;
502 inline const TDbCol* operator->() const;
503 IMPORT_C TDbColSetIter& operator++();
504 inline TDbColSetIter operator++(TInt);
505 inline TDbColNo Col() const;
507 const TDbCol* iColumn;
509 const CArrayPakFlat<TDbCol>* iArray;
512 /** Defines a key column in an index.
514 The data members are public as this is really a structure to group the
515 attributes of the key column together. Two non-default constructors are
516 provided for convenience.
523 /** Specifies whether a key column in an index should be sorted in
524 ascending or descending order. */
527 /** Use ascending order. */
529 /** Use descending order. */
533 /** Constructs an uninitialised object. Default constructor. It is necessary
534 because there are also non-default constructors in this class. */
535 inline TDbKeyCol() {}
536 inline TDbKeyCol(const TDbKeyCol&);
537 inline TDbKeyCol& operator=(const TDbKeyCol&);
538 IMPORT_C TDbKeyCol(const TDesC& aName,TOrder anOrder=EAsc);
539 IMPORT_C TDbKeyCol(const TDesC& aName,TInt aLength,TOrder anOrder=EAsc);
541 /** The ordering of the key. */
543 /** The maximum number of characters used to index Text or LongText
544 columns. If equal to KDbUndefinedLength (the default), all the characters
545 in the defined column will be used. */
547 /** The column name for the key. */
552 Represents the definition of an index. The key may be unique or primary, it
553 can specify the sort of comparison which is made for Text columns, and it
554 has a list of columns which make up the key. The class is used to construct
555 and interrogate index keys.
557 This class is not intended for user derivation.
561 class CDbKey : public CBase
564 enum {EUnique=0x01,EPrimary=0x02};
567 IMPORT_C static CDbKey* NewL();
568 IMPORT_C static CDbKey* NewLC();
570 IMPORT_C CDbKey& AddL(const TDbKeyCol& aKeyCol);
571 IMPORT_C void Remove(const TDesC& aColName);
572 IMPORT_C void Clear();
573 inline TInt Count() const;
574 inline const TDbKeyCol& operator[](TInt aCol) const;
575 inline void MakeUnique();
576 inline TBool IsUnique() const;
577 inline void SetComparison(TDbTextComparison aComparison);
578 inline TDbTextComparison Comparison() const;
579 inline void MakePrimary();
580 inline TBool IsPrimary() const;
582 CArrayPakFlat<TDbKeyCol> iKeys;
583 TDbTextComparison iComparison;
588 Saves the current location of a rowset, enabling rapid navigation back to a
589 previously visited row or position in the set.
591 Instances of this class are returned by RDbRowSet::Bookmark(), which can later
592 be passed to RDbRowSet::GotoL() to return to the row which was current at
593 the call to Bookmark().
595 @see RDbRowSet::Bookmark()
596 @see RDbRowSet::GotoL()
602 friend class RDbRowSet;
605 /** Stores a database bookmark. */
608 TUint32 iMark[ESize];
615 A wrapper for an SQL string combined with a text comparison mode.
617 An instance of the class is used as a parameter to RDbView::Prepare(),
618 RDbRowSet::FindL() and RDbRowConstraint::Open().
620 The evaluation of SQL queries or constraints depends on how Text columns are
621 compared so every SQL string is accompanied by a member of the TDbTextComparison
622 enumeration to indicate how comparison is done.
624 If the SQL string contains a LIKE clause with * (asterisks) wildcard then the
625 characters between them must be no longer than length 255.
626 If only one * exists then the length is taken from the start and to the end of
627 the clause. However, if the clause contains a ? (question mark) wildcard
628 within it then the characters between must be no longer than length 253.
630 @see TDbTextComparison
631 @see RDbView::Prepare()
632 @see RDbRowSet::FindL()
633 @see RDbRowConstraint::Open()
640 inline TDbQuery(const TDesC& aQuery,TDbTextComparison aComparison=EDbCompareNormal);
641 inline const TDesC& Query() const;
642 inline TDbTextComparison Comparison() const;
645 TDbTextComparison iComparison;
649 This class is internal and is not intended for use
656 inline RDbHandleBase();
659 inline void Set(CDbObject* aObject);
660 CDbObject& Object() const;
666 This class is internal and is not intended for use.
671 class RDbHandle : public RDbHandleBase
674 inline T* operator=(T* aT);
675 inline T* operator->() const;
676 inline T& operator*() const;
677 inline T* operator()() const;
681 Represents a pre-compiled SQL search-condition, which can be used to
682 test against the current row in a rowset.
684 The constraint is compiled against a specific rowset, and can only be matched
685 against the same rowset using the RDbRowSet::MatchL() function.
691 class RDbRowConstraint
693 friend class RDbRowSet;
695 IMPORT_C TInt Open(const RDbRowSet& aView,TDbQuery aCriteria);
696 IMPORT_C void Close();
698 RDbHandle<CDbRowConstraint> iConstraint;
702 An abstract base class that provides functionality which is shared between
703 SQL view objects and Table objects. This functionality includes most of the
704 cursor navigation, row retrieval and update behaviour of rowsets.
706 Rowset objects do not provide the data for the rowset on which they operate.
707 It is the responsibility of the derived classes RDbView and RDbTable to specify
710 This class is not intended for user derivation.
716 friend class RDbRowConstraint;
717 friend class RDbColReadStream;
718 friend class RDbColWriteStream;
720 /** Specifies where the rowset should navigate to in the GotoL() function.
721 Their use is encapsulated by the respective member functions FirstL(),
725 /** Move to the first row in the rowset. */
727 /** Move to the next row in the rowset. */
729 /** Move to the previous row in the rowset. */
731 /** Move to the last row in the rowset. */
733 /** Move to the position before the first row in the rowset. */
735 /** Move to the position after the last row in the rowset. */
739 /** Specifies which operations can be performed on a rowset. */
742 /** All operations can be performed on the rowset. */
744 /** Row navigation and reading are permitted. */
746 /** Inserting new rows is the only valid operation on the rowset. */
750 /** Specifies the direction to search through the rowset when using the
754 /** Search from the current row forwards through the set. */
756 /** Search from the current row backwards through the set. */
760 /** Specifies whether the CountL() function should ensure that it returns
761 the exact value which may be a non-trivial task. */
764 /** Take the time, if necessary, to return the exact value. */
766 /** Return any immediately available value. */
770 IMPORT_C void Close();
771 IMPORT_C void Reset();
773 IMPORT_C CDbColSet* ColSetL() const;
774 IMPORT_C TInt ColCount() const;
775 IMPORT_C TDbColType ColType(TDbColNo aCol) const;
776 IMPORT_C TDbCol ColDef(TDbColNo aCol) const;
778 IMPORT_C TBool AtRow() const;
779 IMPORT_C TBool AtBeginning() const;
780 IMPORT_C TBool AtEnd() const;
782 IMPORT_C TInt CountL(TAccuracy anAccuracy=EEnsure) const;
783 IMPORT_C TBool IsEmptyL() const;
785 IMPORT_C TBool GotoL(TPosition aPosition);
786 inline void BeginningL();
788 inline TBool FirstL();
789 inline TBool LastL();
790 inline TBool NextL();
791 inline TBool PreviousL();
793 IMPORT_C TDbBookmark Bookmark() const;
794 IMPORT_C void GotoL(const TDbBookmark& aMark);
796 IMPORT_C TBool MatchL(const RDbRowConstraint& aConstraint);
797 IMPORT_C TInt FindL(TDirection aDirection,TDbQuery aCriteria);
799 IMPORT_C void GetL();
800 IMPORT_C void InsertL();
801 IMPORT_C void InsertCopyL();
802 IMPORT_C void UpdateL();
803 IMPORT_C void PutL();
804 IMPORT_C void Cancel();
805 IMPORT_C void DeleteL();
807 inline TBool IsColNull(TDbColNo aCol) const;
808 IMPORT_C TInt ColSize(TDbColNo aCol) const;
809 IMPORT_C TInt ColLength(TDbColNo aCol) const;
811 IMPORT_C TInt8 ColInt8(TDbColNo aCol) const;
812 IMPORT_C TInt16 ColInt16(TDbColNo aCol) const;
813 IMPORT_C TInt32 ColInt32(TDbColNo aCol) const;
814 IMPORT_C TInt64 ColInt64(TDbColNo aCol) const;
815 inline TInt ColInt(TDbColNo aCol) const;
816 IMPORT_C TUint8 ColUint8(TDbColNo aCol) const;
817 IMPORT_C TUint16 ColUint16(TDbColNo aCol) const;
818 IMPORT_C TUint32 ColUint32(TDbColNo aCol) const;
819 inline TUint ColUint(TDbColNo aCol) const;
820 IMPORT_C TReal32 ColReal32(TDbColNo aCol) const __SOFTFP;
821 IMPORT_C TReal64 ColReal64(TDbColNo aCol) const __SOFTFP;
822 inline TReal ColReal(TDbColNo aCol) const;
823 IMPORT_C TTime ColTime(TDbColNo aCol) const;
824 IMPORT_C TPtrC8 ColDes8(TDbColNo aCol) const;
825 IMPORT_C TPtrC16 ColDes16(TDbColNo aCol) const;
826 IMPORT_C TPtrC ColDes(TDbColNo aCol) const;
828 IMPORT_C void SetColNullL(TDbColNo aCol);
829 inline void SetColL(TDbColNo aCol,TInt aValue);
830 IMPORT_C void SetColL(TDbColNo aCol,TInt32 aValue);
831 IMPORT_C void SetColL(TDbColNo aCol,TInt64 aValue);
832 inline void SetColL(TDbColNo aCol,TUint aValue);
833 IMPORT_C void SetColL(TDbColNo aCol,TUint32 aValue);
834 IMPORT_C void SetColL(TDbColNo aCol,TReal32 aValue) __SOFTFP;
835 IMPORT_C void SetColL(TDbColNo aCol,TReal64 aValue) __SOFTFP;
836 IMPORT_C void SetColL(TDbColNo aCol,TTime aValue);
837 IMPORT_C void SetColL(TDbColNo aCol,const TDesC8& aValue);
838 IMPORT_C void SetColL(TDbColNo aCol,const TDesC16& aValue);
840 inline MStreamBuf* ColSourceL(TDbColNo aCol) const;
841 inline MStreamBuf* ColSinkL(TDbColNo aCol);
842 CDbCursor& CheckCol(TDbColNo aCol) const;
843 TDbColumnC ColumnC(TDbColNo aCol,TDbColType aType) const;
844 TDbColumn Column(TDbColNo aCol,TDbColType aType);
846 RDbHandle<CDbCursor> iCursor;
850 Allows any column value to be read as stream data.
852 Note that this is the only way to extract the contents of a Long column from
855 Only one column in a rowset object can be opened for reading as a stream at
856 a time, and while it is open no column in the same rowset object may be set
857 using RDbColWriteStream.
859 Null columns result in a read stream with no data. Small numeric columns are
860 maintained in memory as 32-bit values; hence reading a Uint8 column as a stream
861 results in 4 bytes of stream data, not 1.
865 class RDbColReadStream : public RReadStream
868 IMPORT_C void OpenL(const RDbRowSet& aView,TDbColNo aCol);
869 IMPORT_C void OpenLC(const RDbRowSet& aView,TDbColNo aCol);
873 Writes Long columns when inserting or updating rows in a rowset.
875 Only one column in a rowset object can be opened for writing as a stream at
880 class RDbColWriteStream : public RWriteStream
883 /** Constructs this object by invoking the default constructor for
885 inline RDbColWriteStream() {}
886 inline RDbColWriteStream(const MExternalizer<TStreamRef> &anExternalizer);
887 IMPORT_C void OpenL(RDbRowSet& aView,TDbColNo aCol);
888 IMPORT_C void OpenLC(RDbRowSet& aView,TDbColNo aCol);
892 Describes the desired shape of a view's pre-evaluation window.
894 An instance of this class is passed to the RDbView object as part of the
895 Prepare() function. The different constructors for TDbWindow can specify a view:
897 without pre-evaluation
899 with full pre-evaluation
901 with limited pre-evaluation.
910 /** Denotes a full pre-evaluation window. */
913 /** No limit on how many rows may be in the window. */
919 inline TDbWindow(TUnlimited);
920 IMPORT_C TDbWindow(TInt aForeSlots,TInt aRearSlots);
921 inline TInt Size() const;
922 inline TInt PreferredPos() const;
927 #if defined(__NO_CLASS_CONSTS__)
931 #define KDbUnlimitedWindow TDbWindow(TDbWindow::EUnlimited)
937 const TDbWindow KDbUnlimitedWindow=TDbWindow(TDbWindow::EUnlimited);
941 Generates rowsets from an SQL query. The query is prepared and evaluated
942 using the interface to this class, while the rowset is manipulated using the
943 RDbRowset base class.
945 There are no special rules to consider when deriving from this class.
949 class RDbView : public RDbRowSet
952 IMPORT_C TInt Prepare(RDbDatabase& aDatabase,const TDbQuery& aQuery,TAccess anAccess=EUpdatable);
953 IMPORT_C TInt Prepare(RDbDatabase& aDatabase,const TDbQuery& aQuery,const TDbWindow& aWindow);
954 IMPORT_C TInt Prepare(RDbDatabase& aDatabase,const TDbQuery& aQuery,const TDbWindow& aWindow,TAccess anAccess);
955 IMPORT_C TInt EvaluateAll();
956 IMPORT_C TInt Evaluate();
957 IMPORT_C void Evaluate(TRequestStatus& aStatus);
958 IMPORT_C TBool Unevaluated() const;
962 This class is internal and is not intended for use.
970 inline operator const T&() const;
971 inline const T& operator()() const;
972 inline T& operator()();
973 inline void Set(const T& aT);
975 TUint8 iRep[sizeof(T)];
979 This class is internal and is not intended for use.
992 TUnion<TInt64> iInt64;
996 struct {const TText8* iPtr;TInt iLength;} iDes8;
997 struct {const TText16* iPtr;TInt iLength;} iDes16;
1002 inline TDbLookupKey();
1003 inline TInt Count() const;
1004 inline const SColumn* First() const;
1005 void Add(TInt aKey);
1006 void Add(TUint aKey);
1007 void Add(TInt64 aKey);
1008 void Add(TReal32 aKey) __SOFTFP;
1009 void Add(TReal64 aKey) __SOFTFP;
1010 void Add(TTime aKey);
1011 void Add(const TDesC8& aKey);
1012 void Add(const TDesC16& aKey);
1017 SColumn iKey[1]; // at least one
1023 The class encapsulates a key value which is passed to RDbTable::SeekL(), for
1024 lookup in the currently active index on that rowset.
1026 An instance of this class can store a key value of any type.
1028 Note that the class can only hold a single-column key. Use TDbSeekMultiKey
1029 for multi-column keys.
1031 @see TDbSeekMultiKey
1038 friend class RDbTable;
1040 inline TDbSeekKey();
1041 inline TDbSeekKey(TInt aKey);
1042 inline TDbSeekKey(TUint aKey);
1043 inline TDbSeekKey(TInt64 aKey);
1044 inline TDbSeekKey(TReal32 aKey);
1045 inline TDbSeekKey(TReal64 aKey);
1046 inline TDbSeekKey(TTime aKey);
1047 inline TDbSeekKey(const TDesC8& aKey);
1048 inline TDbSeekKey(const TDesC16& aKey);
1049 IMPORT_C TDbSeekKey& Add(TInt aKey);
1050 IMPORT_C TDbSeekKey& Add(TUint aKey);
1051 IMPORT_C TDbSeekKey& Add(TInt64 aKey);
1052 IMPORT_C TDbSeekKey& Add(TReal32 aKey) __SOFTFP;
1053 IMPORT_C TDbSeekKey& Add(TReal64 aKey) __SOFTFP;
1054 IMPORT_C TDbSeekKey& Add(TTime aKey);
1055 IMPORT_C TDbSeekKey& Add(const TDesC8& aKey);
1056 IMPORT_C TDbSeekKey& Add(const TDesC16& aKey);
1058 TDbLookupKey& Check();
1060 inline TDbSeekKey(TInt aKeys,TInt);
1067 Database multi-column key value.
1069 The class extends the behaviour of TDbSeekKey by allowing multi-column indexes
1070 to be searched using multi-column key values.
1072 The template parameter S specifies the maximum number of column values that
1073 can be added to the key value.
1075 Use the TDbSeekKey::Add() members to append the values for each column in
1081 class TDbSeekMultiKey : public TDbSeekKey
1084 inline TDbSeekMultiKey();
1086 TDbLookupKey::SColumn iExtraKeys[S-1];
1090 Provides access to table data as a rowset, allowing manipulation of a named
1091 table in the database. Additionally, a named index can be used to order the
1092 rowset, and to provide fast key-based row retrieval from the table.
1094 There are no special rules to consider when deriving from this class.
1098 class RDbTable : public RDbRowSet
1101 /** Database table seek comparison types. */
1104 /** Retrieve the last row which is strictly less than the key value. */
1106 /** Retrieve the last row which is equal to or less than the key
1109 /** Retrieve the first row which is equal to the key value. */
1111 /** Retrieve the first row which is equal to or greater than the key
1114 /** Retrieve the first row which is strictly greater than the key
1119 IMPORT_C TInt Open(RDbDatabase& aDatabase,const TDesC& aName,TAccess anAccess=EUpdatable);
1120 inline TInt SetIndex(const TDesC& anIndex);
1121 inline TInt SetNoIndex();
1122 IMPORT_C TBool SeekL(const TDbSeekKey& aKey,TComparison aComparison=EEqualTo);
1124 IMPORT_C TInt SetIndex(const TDesC* anIndex);
1131 class CDbNames : public CBase
1136 static CDbNames* NewLC();
1138 inline TInt Count() const;
1139 inline const TDesC& operator[](TInt anIndex) const;
1140 IMPORT_C void AddL(const TDesC& aName);
1142 CArrayPakFlat<TDbNameC> iList;
1148 typedef CDbNames CDbTableNames,CDbIndexNames,CDbDatabaseNames;
1151 The maximum length for a generic DBMS string, which might be transferred from DBMS server
1152 to the DBMS client using IPC.
1156 const TInt KDbMaxStrLen = 256;
1159 Represents a generic read-only DBMS string. It maps to a non-modifiable buffer descriptor
1160 with maximum size KDbMaxStrLen.
1166 typedef TBufC<KDbMaxStrLen> TDbStringC;
1169 CDbStrings encapsulates functionality used for transferring an array of strings from
1170 DBMS server to the DBMS client. The maximal length of each element of the array is
1171 KDbMaxStrLen characters.
1172 The typical usage pattern of CDbStrings class is:
1174 CDbStrings* strings = <a call of an exported DBMS method>;
1175 TInt cnt = strings.Count();
1176 for(TInt i=0;i<cnt;++i)
1178 const TDesC& str = (*strings)[i];
1179 <do something with "str" variable>;
1186 class CDbStrings : public CBase
1189 inline CDbStrings();
1191 static CDbStrings* NewLC();
1192 virtual ~CDbStrings();
1193 inline TInt Count() const;
1194 inline const TDesC& operator[](TInt aIndex) const;
1195 void AddL(const TDesC& aStr);
1197 CArrayPakFlat<TDbStringC> iList;
1201 Abstract class providing the functionality of a database.
1203 The source of the database and the implementation characteristics of a particular
1204 database are provided by a class derived from RDbDatabase.
1206 DBMS has one such implementation: the store database.
1208 This class is not intended for user derivation.
1210 Note: For functions (i.e. Execute) that take an Sql string, if the string
1211 contains a LIKE clause with * (asterisks) wildcard then the
1212 characters between them must be no longer than length 255.
1213 If only one * exists then the length is taken from the start and to the end of
1214 the clause. However, if the clause contains a ? (question mark) wildcard
1215 within it then the characters between must be no longer than length 253.
1222 friend class RDbView;
1223 friend class RDbTable;
1224 friend class RDbIncremental;
1225 friend class RDbUpdate;
1226 friend class RDbNotifier;
1228 struct TSize {TInt iSize;TInt iUsage;};
1230 IMPORT_C void Close();
1231 IMPORT_C TInt Destroy();
1233 IMPORT_C TBool IsDamaged() const;
1234 IMPORT_C TInt Recover();
1236 IMPORT_C TInt UpdateStats();
1237 IMPORT_C TSize Size() const;
1238 IMPORT_C TInt Compact();
1239 IMPORT_C TInt Begin();
1240 IMPORT_C TInt Commit();
1241 IMPORT_C void Rollback();
1242 IMPORT_C TBool InTransaction() const;
1244 inline TInt CreateTable(const TDesC& aName,const CDbColSet& aDef);
1245 inline TInt CreateTable(const TDesC& aName,const CDbColSet& aDef,const CDbKey& aPrimaryKey);
1246 IMPORT_C TInt DropTable(const TDesC& aName);
1247 IMPORT_C TInt AlterTable(const TDesC& aName,const CDbColSet& aNewDef);
1248 IMPORT_C TInt CreateIndex(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey);
1249 IMPORT_C TInt DropIndex(const TDesC& aName,const TDesC& aTable);
1251 IMPORT_C TInt Execute(const TDesC& aSql,TDbTextComparison aComparison=EDbCompareNormal);
1253 IMPORT_C CDbTableNames* TableNamesL() const;
1254 IMPORT_C CDbColSet* ColSetL(const TDesC& aName) const;
1255 IMPORT_C CDbIndexNames* IndexNamesL(const TDesC& aTable) const;
1256 IMPORT_C CDbKey* KeyL(const TDesC& aName,const TDesC& aTable) const;
1258 IMPORT_C TInt CreateTable(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey);
1260 RDbHandle<CDbDatabase> iDatabase;
1264 Provides the interface for performing long-running database operations in
1265 incremental steps, allowing application programs to remain responsive to other
1268 After an operation has begun, a standard interface is used to continue and
1269 complete all incremental operations. On successful return from one of the
1270 initiating functions, a step value is also returned. This gives the progress
1271 indication and is, initially, positive. This value should be passed into
1272 subsequent steps in the operation, each of which may decrement the value by
1273 some amount, although they are allowed to leave it unchanged. The value
1274 reaches zero, if, and only if the operation completes.
1276 While an incremental operation is in progress, the database cannot be used
1277 for any other operations such as opening tables or preparing views.
1279 Starting an incremental operation also requires that no rowsets are open on
1280 the database and that no commit is pending for data manipulation transactions.
1282 If no explicit transaction has been started by the database, then an automatic
1283 transaction is begun when any incremental operation is started and is committed
1284 when complete or rolled back if the operation either fails or is abandoned
1285 prior to completion.
1289 class RDbIncremental
1292 IMPORT_C void Close();
1293 IMPORT_C TInt Next(TInt& aStep);
1294 IMPORT_C void Next(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus);
1296 IMPORT_C TInt Recover(RDbDatabase& aDatabase,TInt& aStep);
1297 IMPORT_C TInt Compact(RDbDatabase& aDatabase,TInt& aStep);
1298 IMPORT_C TInt DropTable(RDbDatabase& aDatabase,const TDesC& aTable,TInt& aStep);
1299 IMPORT_C TInt AlterTable(RDbDatabase& aDatabase,const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep);
1300 IMPORT_C TInt CreateIndex(RDbDatabase& aDatabase,const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep);
1301 IMPORT_C TInt DropIndex(RDbDatabase& aDatabase,const TDesC& aName,const TDesC& aTable,TInt& aStep);
1302 inline TInt Execute(RDbDatabase& aDatabase,const TDesC& aSql,TInt& aStep);
1303 IMPORT_C TInt Execute(RDbDatabase& aDatabase,const TDesC& aSql,TDbTextComparison aComparison,TInt& aStep);
1304 IMPORT_C TInt UpdateStats(RDbDatabase& aDatabase,TInt& aStep);
1306 RDbHandle<CDbIncremental> iState;
1310 Provides an interface to allow incremental execution of a DML (SQL data
1313 This class offers similar behaviour to the RDbIncremental class, in that it
1314 allows an application to perform long running operations while remaining
1315 responsive to events. However, unlike that class, RDbUpdate is restricted to
1316 executing DML statements.
1325 IMPORT_C TInt Execute(RDbDatabase& aDatabase,const TDesC& aSql,TDbTextComparison aComparison=EDbCompareNormal);
1326 IMPORT_C void Close();
1328 IMPORT_C TInt Next();
1329 IMPORT_C void Next(TRequestStatus& aStatus);
1330 IMPORT_C TInt RowCount() const;
1332 RDbHandle<CDbIncremental> iUpdate;
1333 TPckgBuf<TInt> iRows;
1337 Provides notification of database changes to clients.
1339 This is useful for shared databases.
1346 /** Defines the events which may be reported by a DBMS change notifier
1347 through this RDbNotifier object.
1349 Each enumerator corresponds to a distinct event type.
1351 The changes are reported through a TRequestStatus object when an
1352 outstanding notification request completes.
1356 If further database events occur while a client is handling the completion
1357 of a previous event, the notifier remembers the most significant event. The
1358 order of importance is:
1360 ERecover > ERollback > ECommit
1362 where the symbol > means "is more important than" */
1365 /** The database has been closed. */
1367 /** All read locks have been removed. */
1369 /** A transaction has been committed. */
1371 /** A transaction has been rolled back */
1373 /** The database has been recovered */
1377 IMPORT_C TInt Open(RDbDatabase& aDatabase);
1378 IMPORT_C void Close();
1380 IMPORT_C void NotifyUnlock(TRequestStatus& aStatus);
1381 IMPORT_C void NotifyChange(TRequestStatus& aStatus);
1382 IMPORT_C void Cancel();
1384 RDbHandle<CDbNotifier> iNotifier;
1388 Client-server databases
1390 Represents a session with the DBMS server. A thread uses this class to set
1391 up a DBMS server session and this provides the basis for sharing databases
1396 class RDbs : public RSessionBase
1400 This enum is used in GetDatabasePolicy/GetTablePolicy/GetTablePolicies calls and specifies
1401 requested security policy type: read/write/schema.
1405 typedef enum {EReadPolicy, EWritePolicy, ESchemaPolicy} TPolicyType;
1408 IMPORT_C static TVersion Version();
1409 IMPORT_C TInt Connect();
1410 IMPORT_C CDbDatabaseNames* DatabaseNamesL(TDriveNumber aDrive, TUid aPolicyUid);
1411 IMPORT_C TInt CopyDatabase(const TDesC& aSrcDbName, const TDesC& aDestDbName, TUid aPolicyUid);
1412 IMPORT_C TInt DeleteDatabase(const TDesC& aDbName, TUid aPolicyUid);
1413 IMPORT_C TInt GetDatabasePolicy(TUid aPolicyUid, TPolicyType aPolicyType,
1414 TSecurityPolicy& aDbPolicy);
1415 IMPORT_C TInt GetTablePolicy(TUid aPolicyUid, const TDesC& aTableName,
1416 TPolicyType aPolicyType, TSecurityPolicy& aTablePolicy);
1417 IMPORT_C TInt GetTablePolicies(TUid aPolicyUid, const TDesC& aTableName,
1418 TPolicyType aPolicyType,
1419 TSecurityPolicy& aDbPolicy, TSecurityPolicy& aTablePolicy);
1421 IMPORT_C void ResourceMark();
1422 IMPORT_C void ResourceCheck();
1423 IMPORT_C TInt ResourceCount();
1424 IMPORT_C void SetHeapFailure(TInt aTAllocFail,TInt aRate);
1426 IMPORT_C TInt ReserveDriveSpace(TInt aDriveNo, TInt aSpace);
1427 IMPORT_C void FreeReservedSpace(TInt aDriveNo);
1428 IMPORT_C TInt GetReserveAccess(TInt aDriveNo);
1429 IMPORT_C TInt ReleaseReserveAccess(TInt aDriveNo);
1431 IMPORT_C TInt GetBackupPath(TSecureId aRequesterSid, const TDesC& aDbName,
1432 TUid aDbPolicyUid, TDes& aBackupPath);
1433 IMPORT_C CDbStrings* BackupPathsL(TSecureId aRequesterSid, TUid aDbPolicyUid);
1437 TInt SessionMessage(TInt aFunction);
1438 TInt GetPolicy(TUid aPolicyUid, const TDesC& aTableName,
1439 TUint aMask, TSecurityPolicy& aPolicy);
1443 Generic database implementation
1447 class RDbNamedDatabase : public RDbDatabase
1450 /** Specifies which operations can be performed on a rowset. */
1454 /** Row navigation and reading are permitted. */
1458 IMPORT_C TInt Create(RDbs& aDbs, const TDesC& aDatabase, const TDesC& aFormat);
1459 IMPORT_C TInt Create(RFs& aFs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC());
1460 IMPORT_C TInt Replace(RFs& aFs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC());
1461 IMPORT_C TInt Open(RFs& aFs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC(),TAccess aMode=EReadWrite);
1462 IMPORT_C TInt Open(RDbs& aDbs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC());
1468 const TInt KDbStoreMaxColumnLength=255;
1471 DBMS Store database implementation
1475 class RDbStoreDatabase : public RDbDatabase
1478 IMPORT_C TStreamId CreateL(CStreamStore* aStore);
1479 IMPORT_C void OpenL(CStreamStore* aStore,TStreamId anId);
1480 IMPORT_C static void CompressL(CStreamStore& aStore,TStreamId aId);
1481 IMPORT_C static void DecompressL(CStreamStore& aStore,TStreamId aId);
1484 #include <d32dbms.inl>