epoc32/include/d32dbms.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#if !defined(__D32DBMS_H__)
williamr@2
    17
#define __D32DBMS_H__
williamr@2
    18
williamr@2
    19
#ifndef __S32STD_H__
williamr@2
    20
#include <s32std.h>
williamr@2
    21
#endif
williamr@2
    22
#ifndef __F32FILE_H__
williamr@2
    23
#include <f32file.h>
williamr@2
    24
#endif
williamr@2
    25
williamr@2
    26
// other classes referenced
williamr@2
    27
class RFs;
williamr@2
    28
class CDbObject;
williamr@2
    29
class CDbRowConstraint;
williamr@2
    30
class CDbCursor;
williamr@2
    31
class CDbDatabase;
williamr@2
    32
class CDbIncremental;
williamr@2
    33
class CDbNotifier;
williamr@2
    34
class TDbColumn;
williamr@2
    35
class TDbColumnC;
williamr@2
    36
williamr@2
    37
// classes defined
williamr@2
    38
class TDbCol;
williamr@2
    39
class CDbColSet;
williamr@2
    40
class TDbColSetIter;
williamr@2
    41
class TDbKeyCol;
williamr@2
    42
class CDbKey;
williamr@2
    43
class TDbBookmark;
williamr@2
    44
class TDbQuery;
williamr@2
    45
class RDbHandleBase;
williamr@2
    46
template<class T> class RDbHandle;
williamr@2
    47
class RDbRowConstraint;
williamr@2
    48
class RDbRowSet;
williamr@2
    49
class RDbColReadStream;
williamr@2
    50
class RDbColWriteStream;
williamr@2
    51
class TDbWindow;
williamr@2
    52
class RDbView;
williamr@2
    53
template<class T> class TUnion;
williamr@2
    54
class TDbLookupKey;
williamr@2
    55
class TDbSeekKey;
williamr@2
    56
template<TInt S> class TDbSeekMultiKey;
williamr@2
    57
class RDbTable;
williamr@2
    58
class CDbNames;
williamr@2
    59
class RDbDatabase;
williamr@2
    60
class RDbIncremental;
williamr@2
    61
class RDbUpdate;
williamr@2
    62
class RDbNotifier;
williamr@2
    63
class RDbs;
williamr@2
    64
class RDbNamedDatabase;
williamr@2
    65
class RDbStoreDatabase;
williamr@2
    66
williamr@2
    67
/**
williamr@2
    68
The maximum length for a DBMS name: 64 characters.
williamr@2
    69
@publishedAll
williamr@2
    70
@released
williamr@2
    71
*/
williamr@2
    72
const TInt KDbMaxName=0x40;
williamr@2
    73
williamr@2
    74
/**
williamr@2
    75
The maximum length for a DBMS column name: 64 characters.
williamr@2
    76
@publishedAll
williamr@2
    77
@released
williamr@2
    78
*/
williamr@2
    79
const TInt KDbMaxColName=KDbMaxName;
williamr@2
    80
williamr@2
    81
/** 
williamr@2
    82
Represents a writable DBMS name. It maps to a modifiable buffer descriptor 
williamr@2
    83
with maximum size KDbMaxName.
williamr@2
    84
williamr@2
    85
Notes:
williamr@2
    86
williamr@2
    87
A DBMS name must begin with an alphabetic character, after which any alphabetic, 
williamr@2
    88
numeric or the _ (underscore) character may be used. DBMS names are also limited 
williamr@2
    89
to 64 characters in length.
williamr@2
    90
williamr@2
    91
Table names must be unique within a database, and columns and indexes must 
williamr@2
    92
have unique names within the table to which they belong. For the purposes 
williamr@2
    93
of uniqueness and identification, the names are folded before comparison, 
williamr@2
    94
so two columns named column_one and Column_ONE are considered to have the 
williamr@2
    95
same name.
williamr@2
    96
williamr@2
    97
@see TBuf 
williamr@2
    98
@publishedAll
williamr@2
    99
@released
williamr@2
   100
*/
williamr@2
   101
typedef TBuf<KDbMaxName> TDbName;
williamr@2
   102
williamr@2
   103
/** Represents a non-writeable DBMS name. It maps to a non modifiable buffer descriptor 
williamr@2
   104
with maximum size KDbMaxName.
williamr@2
   105
williamr@2
   106
Notes:
williamr@2
   107
williamr@2
   108
A DBMS name must begin with an alphabetic character, after which any alphabetic, 
williamr@2
   109
numeric or the _ (underscore) character may be used. DBMS names are also limited 
williamr@2
   110
to 64 characters in length.
williamr@2
   111
williamr@2
   112
Table names must be unique within a database, and columns and indexes must 
williamr@2
   113
have unique names within the table to which they belong. For the purposes 
williamr@2
   114
of uniqueness and identification, the names are folded before comparison, 
williamr@2
   115
so two columns named column_one and Column_ONE are considered to have the 
williamr@2
   116
same name.
williamr@2
   117
williamr@2
   118
@see TBufC 
williamr@2
   119
@publishedAll
williamr@2
   120
@released
williamr@2
   121
*/
williamr@2
   122
typedef TBufC<KDbMaxName> TDbNameC;
williamr@2
   123
williamr@2
   124
/** Represents a writable DBMS column name. It maps to a modifiable buffer descriptor 
williamr@2
   125
with maximum size KDbMaxColName.
williamr@2
   126
williamr@2
   127
Notes:
williamr@2
   128
williamr@2
   129
A DBMS name must begin with an alphabetic character, after which any alphabetic, 
williamr@2
   130
numeric or the _ (underscore) character may be used. DBMS names are also limited 
williamr@2
   131
to 64 characters in length.
williamr@2
   132
williamr@2
   133
Table names must be unique within a database, and columns and indexes must 
williamr@2
   134
have unique names within the table to which they belong. For the purposes 
williamr@2
   135
of uniqueness and identification, the names are folded before comparison, 
williamr@2
   136
so two columns named column_one and Column_ONE are considered to have the 
williamr@2
   137
same name. 
williamr@2
   138
@publishedAll
williamr@2
   139
@released
williamr@2
   140
*/
williamr@2
   141
typedef TBuf<KDbMaxColName> TDbColName;
williamr@2
   142
williamr@2
   143
/** Represents a non-writable DBMS column name. It maps to a non-modifiable buffer 
williamr@2
   144
descriptor with maximum size KDbMaxColName.
williamr@2
   145
williamr@2
   146
Notes:
williamr@2
   147
williamr@2
   148
A DBMS name must begin with an alphabetic character, after which any alphabetic, 
williamr@2
   149
numeric or the _ (underscore) character may be used. DBMS names are also limited 
williamr@2
   150
to 64 characters in length.
williamr@2
   151
williamr@2
   152
Table names must be unique within a database, and columns and indexes must 
williamr@2
   153
have unique names within the table to which they belong. For the purposes 
williamr@2
   154
of uniqueness and identification, the names are folded before comparison, 
williamr@2
   155
so two columns named column_one and Column_ONE are considered to have the 
williamr@2
   156
same name.
williamr@2
   157
williamr@2
   158
@see TBufC 
williamr@2
   159
@publishedAll
williamr@2
   160
@released
williamr@2
   161
*/
williamr@2
   162
typedef TBufC<KDbMaxColName> TDbColNameC;
williamr@2
   163
williamr@2
   164
/** Specifies when DBMS objects require a column ordinal to identify a column in 
williamr@2
   165
a column set or in a rowset.
williamr@2
   166
williamr@2
   167
Note that KDbNullColNo is a special value of TDbColNo used to indicate that 
williamr@2
   168
no such column exists. 
williamr@2
   169
@publishedAll
williamr@2
   170
@released
williamr@2
   171
*/
williamr@2
   172
typedef TInt TDbColNo;
williamr@2
   173
williamr@2
   174
/** 
williamr@2
   175
Indicates that a specified column does not exist. 
williamr@2
   176
@publishedAll
williamr@2
   177
@released
williamr@2
   178
*/
williamr@2
   179
const TDbColNo KDbNullColNo=0;
williamr@2
   180
williamr@2
   181
/** 
williamr@2
   182
A value returned by RDbRowSet::Count() when the number of rows cannot be determined.
williamr@2
   183
williamr@2
   184
@see RDbRowSet 
williamr@2
   185
@publishedAll
williamr@2
   186
@released
williamr@2
   187
*/
williamr@2
   188
const TInt KDbUndefinedCount=-1;
williamr@2
   189
williamr@2
   190
/** 
williamr@2
   191
The length of a column is undefined. 
williamr@2
   192
@publishedAll
williamr@2
   193
@released
williamr@2
   194
*/
williamr@2
   195
const TInt KDbUndefinedLength=-1;
williamr@2
   196
williamr@2
   197
/** 
williamr@2
   198
The default text column length. This is equal to 50. 
williamr@2
   199
@publishedAll
williamr@2
   200
@released
williamr@2
   201
*/
williamr@2
   202
const TInt KDbDefaultTextColLength=50;
williamr@2
   203
williamr@2
   204
/** 
williamr@2
   205
Represents every supported column type. 
williamr@2
   206
@publishedAll
williamr@2
   207
@released
williamr@2
   208
*/
williamr@2
   209
enum TDbColType
williamr@2
   210
	{
williamr@2
   211
	/** The column stores a single bit.
williamr@2
   212
	
williamr@2
   213
	Representation range: 0 to 1
williamr@2
   214
	
williamr@2
   215
	Storage: 1 bit
williamr@2
   216
	
williamr@2
   217
	Auto-increment: Yes
williamr@2
   218
	
williamr@2
   219
	Index key: Yes */
williamr@2
   220
	EDbColBit,
williamr@2
   221
williamr@2
   222
	/** The column stores an 8-bit signed integer.
williamr@2
   223
	
williamr@2
   224
	Representation range: -2^7 to 2^7 - 1
williamr@2
   225
	
williamr@2
   226
	Storage: 1 byte
williamr@2
   227
	
williamr@2
   228
	Auto-increment: Yes
williamr@2
   229
	
williamr@2
   230
	Index key: Yes */
williamr@2
   231
	EDbColInt8,
williamr@2
   232
williamr@2
   233
	/** The column stores an 8-bit unsigned integer.
williamr@2
   234
	
williamr@2
   235
	Representation range: 0 to 2^8-1
williamr@2
   236
	
williamr@2
   237
	Storage: 1 byte
williamr@2
   238
	
williamr@2
   239
	Auto-increment: Yes
williamr@2
   240
	
williamr@2
   241
	Index key: Yes */
williamr@2
   242
	EDbColUint8,
williamr@2
   243
williamr@2
   244
	/** The column stores a 16-bit signed integer.
williamr@2
   245
	
williamr@2
   246
	Representation range: -2^15 to 2^15 - 1
williamr@2
   247
	
williamr@2
   248
	Storage: 2 bytes
williamr@2
   249
	
williamr@2
   250
	Auto-increment: Yes
williamr@2
   251
	
williamr@2
   252
	Index key: Yes */
williamr@2
   253
	EDbColInt16,
williamr@2
   254
williamr@2
   255
	/** The column stores a 16-bit unsigned integer.
williamr@2
   256
	
williamr@2
   257
	Representation range: 0 to 2^16-1
williamr@2
   258
	
williamr@2
   259
	Storage: 2 bytes
williamr@2
   260
	
williamr@2
   261
	Auto-increment: Yes
williamr@2
   262
	
williamr@2
   263
	Index key: Yes */
williamr@2
   264
	EDbColUint16,
williamr@2
   265
williamr@2
   266
	/** The column stores a 32-bit signed integer.
williamr@2
   267
	
williamr@2
   268
	Representation range: -2^31 to 2^31 - 1
williamr@2
   269
	
williamr@2
   270
	Storage: 4 bytes
williamr@2
   271
	
williamr@2
   272
	Auto-increment: Yes
williamr@2
   273
	
williamr@2
   274
	Index key: Yes */
williamr@2
   275
	EDbColInt32,
williamr@2
   276
williamr@2
   277
	/** The column stores a 32-bit unsigned integer.
williamr@2
   278
	
williamr@2
   279
	Representation range: 0 to 2^32-1
williamr@2
   280
	
williamr@2
   281
	Storage: 4 bytes
williamr@2
   282
	
williamr@2
   283
	Auto-increment: Yes
williamr@2
   284
	
williamr@2
   285
	Index key: Yes */
williamr@2
   286
	EDbColUint32,
williamr@2
   287
williamr@2
   288
	/** The column stores a 64-bit signed integer.
williamr@2
   289
	
williamr@2
   290
	Representation range: -2^63 to 2^63 - 1
williamr@2
   291
	
williamr@2
   292
	Storage: 8 bytes
williamr@2
   293
	
williamr@2
   294
	Auto-increment: No
williamr@2
   295
	
williamr@2
   296
	Index key: Yes */
williamr@2
   297
	EDbColInt64,
williamr@2
   298
williamr@2
   299
	/** The column stores a 32-bit floating point value.
williamr@2
   300
	
williamr@2
   301
	Representation range: 1.4 X 10^-45 to 3.40282 X 10^38
williamr@2
   302
	
williamr@2
   303
	Storage: 4 bytes
williamr@2
   304
	
williamr@2
   305
	Auto-increment: No
williamr@2
   306
	
williamr@2
   307
	Index key: Yes */
williamr@2
   308
	EDbColReal32,
williamr@2
   309
williamr@2
   310
	/** The column stores a 64-bit floating point value.
williamr@2
   311
	
williamr@2
   312
	Representation range: 2.2 X 10^-308 to 1.79769 X 10^308
williamr@2
   313
	
williamr@2
   314
	Storage: 8 bytes
williamr@2
   315
	
williamr@2
   316
	Auto-increment: No
williamr@2
   317
	
williamr@2
   318
	Index key: Yes */
williamr@2
   319
	EDbColReal64,
williamr@2
   320
williamr@2
   321
	/** The column stores a date/time value.
williamr@2
   322
	
williamr@2
   323
	Representation range: 1/1/0 to 31/12/9999
williamr@2
   324
	
williamr@2
   325
	Storage: 8 bytes
williamr@2
   326
	
williamr@2
   327
	Auto-increment: No
williamr@2
   328
	
williamr@2
   329
	Index key: Yes */
williamr@2
   330
	EDbColDateTime,
williamr@2
   331
williamr@2
   332
	/** The column stores a (short) variable length of non-Unicode text data.
williamr@2
   333
	
williamr@2
   334
	Representation range: 0 to 256 characters
williamr@2
   335
	
williamr@2
   336
	Storage: 0 to 256 bytes
williamr@2
   337
	
williamr@2
   338
	Auto-increment: No
williamr@2
   339
	
williamr@2
   340
	Index key: Yes */
williamr@2
   341
	EDbColText8,
williamr@2
   342
williamr@2
   343
	/** The column stores a (short) variable length of Unicode text data.
williamr@2
   344
	
williamr@2
   345
	Representation range: 0 to 256 characters
williamr@2
   346
	
williamr@2
   347
	Storage: 0 to 512 bytes
williamr@2
   348
	
williamr@2
   349
	Auto-increment: No
williamr@2
   350
	
williamr@2
   351
	Index key: Yes */
williamr@2
   352
	EDbColText16,
williamr@2
   353
williamr@2
   354
	/** The column stores a (short) variable length of untyped data.
williamr@2
   355
	
williamr@2
   356
	Representation range: 0 to 255 bytes
williamr@2
   357
	
williamr@2
   358
	Storage: 0 to 256 bytes
williamr@2
   359
	
williamr@2
   360
	Auto-increment: No
williamr@2
   361
	
williamr@2
   362
	Index key: No */
williamr@2
   363
	EDbColBinary,
williamr@2
   364
williamr@2
   365
	/** The column stores a potentially large amount of non-Unicode text data.
williamr@2
   366
	
williamr@2
   367
	Representation range: 0 to 2^31 characters
williamr@2
   368
	
williamr@2
   369
	Storage: 0 to 2 Gbytes
williamr@2
   370
	
williamr@2
   371
	Auto-increment: No
williamr@2
   372
	
williamr@2
   373
	Index key: Truncated */
williamr@2
   374
	EDbColLongText8,
williamr@2
   375
williamr@2
   376
	/** The column stores a potentially large amount of Unicode text data.
williamr@2
   377
	
williamr@2
   378
	Representation range: 0 to 2^30 characters
williamr@2
   379
	
williamr@2
   380
	Storage: 0 to 2 Gbytes
williamr@2
   381
	
williamr@2
   382
	Auto-increment: No
williamr@2
   383
	
williamr@2
   384
	Index key: Truncated */
williamr@2
   385
	EDbColLongText16,
williamr@2
   386
williamr@2
   387
	/** The column stores a potentially large amount of untyped data.
williamr@2
   388
	
williamr@2
   389
	Representation range: 0 to 2^31 bytes
williamr@2
   390
	
williamr@2
   391
	Storage: 0 to 2 Gbytes
williamr@2
   392
	
williamr@2
   393
	Auto-increment: No
williamr@2
   394
	
williamr@2
   395
	Index key: No */
williamr@2
   396
	EDbColLongBinary,
williamr@2
   397
williamr@2
   398
	/** This is equivalent to EDbColText8 if the build is narrow, and 
williamr@2
   399
	EDbColText16 if the build is Unicode. */
williamr@2
   400
	EDbColText=EDbColText16,
williamr@2
   401
williamr@2
   402
	/** This is equivalent to EDbColLongText8 if the build is narrow, and 
williamr@2
   403
	EDbColLongText16 if the build is Unicode. */
williamr@2
   404
	EDbColLongText=EDbColLongText16
williamr@2
   405
	};
williamr@2
   406
williamr@2
   407
/** 
williamr@2
   408
Represents different ways of comparing Text and LongText columns.
williamr@2
   409
williamr@2
   410
This affects the ordering of indexes (see CDbKey), the evaluation of SQL 
williamr@2
   411
queries and matching row constraints (see TDbQuery). 
williamr@2
   412
@publishedAll
williamr@2
   413
@released
williamr@2
   414
*/
williamr@2
   415
enum TDbTextComparison 
williamr@2
   416
	{
williamr@2
   417
	/** Use standard text comparison and ordering. */
williamr@2
   418
	EDbCompareNormal,
williamr@2
   419
	/** Use folded text for comparison and ordering. */
williamr@2
   420
	EDbCompareFolded,
williamr@2
   421
	/** Use collation for comparison and ordering. */
williamr@2
   422
	EDbCompareCollated
williamr@2
   423
	};
williamr@2
   424
williamr@2
   425
/** 
williamr@2
   426
Defines a column in a table or rowset. 
williamr@2
   427
williamr@2
   428
The data members are public because this is really a structure to group the 
williamr@2
   429
attributes of the column together. 
williamr@2
   430
williamr@2
   431
Three non-default constructors are provided for convenience. 
williamr@2
   432
@publishedAll
williamr@2
   433
@released
williamr@2
   434
*/
williamr@2
   435
class TDbCol
williamr@2
   436
	{
williamr@2
   437
	friend class CDbColSet;
williamr@2
   438
public:
williamr@2
   439
	enum {ENotNull=0x01,EAutoIncrement=0x02};
williamr@2
   440
public:
williamr@2
   441
	/** Constructs an uninitialised TDbCol. It is necessary because there are 
williamr@2
   442
	also non-default constructors in this class. */
williamr@2
   443
	inline TDbCol() {}
williamr@2
   444
	inline TDbCol(const TDbCol&);
williamr@2
   445
	inline TDbCol& operator=(const TDbCol&);
williamr@2
   446
	IMPORT_C TDbCol(const TDesC& aName,TDbColType aType);
williamr@2
   447
	IMPORT_C TDbCol(const TDesC& aName,TDbColType aType,TInt aMaxLength);
williamr@2
   448
	static inline TBool IsLong(TDbColType aType);
williamr@2
   449
private:
williamr@2
   450
	inline TDbCol(const TDesC& aName);
williamr@2
   451
public:
williamr@2
   452
	/** The column type. */
williamr@2
   453
	TDbColType iType;
williamr@2
   454
	/** The maximum length of data that can be stored in a Text or Binary 
williamr@2
   455
	column. */
williamr@2
   456
	TInt iMaxLength;
williamr@2
   457
	/** A set of flags describing other column attributes. This must be one 
williamr@2
   458
	of the anonymous enum values ENotNull or EAutoIncrement. */
williamr@2
   459
	TUint iAttributes;
williamr@2
   460
	/** The column name. */
williamr@2
   461
	TDbColNameC iName;
williamr@2
   462
	};
williamr@2
   463
williamr@2
   464
/** Manages a set of column definitions which describe a table or rowset 
williamr@2
   465
structure. Column definitions can be added and removed. The set can be 
williamr@2
   466
iterated over, and ordinals for a column can be looked up.
williamr@2
   467
williamr@2
   468
The class is not intended for user derivation. 
williamr@2
   469
@publishedAll
williamr@2
   470
@released
williamr@2
   471
*/
williamr@2
   472
class CDbColSet : public CBase
williamr@2
   473
	{
williamr@2
   474
	friend class TDbColSetIter;
williamr@2
   475
public:
williamr@2
   476
	IMPORT_C CDbColSet();
williamr@2
   477
	IMPORT_C static CDbColSet* NewL();
williamr@2
   478
	IMPORT_C static CDbColSet* NewLC();
williamr@2
   479
	IMPORT_C ~CDbColSet();
williamr@2
   480
	inline const TDbCol& operator[](TDbColNo aCol) const;
williamr@2
   481
	IMPORT_C const TDbCol* Col(const TDesC& aColName) const;
williamr@2
   482
	IMPORT_C TDbColNo ColNo(const TDesC& aColName) const;
williamr@2
   483
	inline TInt Count() const;
williamr@2
   484
	inline void Clear();
williamr@2
   485
	IMPORT_C CDbColSet& AddL(const TDbCol& aCol);
williamr@2
   486
	IMPORT_C void Remove(const TDesC& aColName);
williamr@2
   487
private:
williamr@2
   488
	CArrayPakFlat<TDbCol> iColumns;
williamr@2
   489
	};
williamr@2
   490
williamr@2
   491
/** 
williamr@2
   492
Provides a useful way to iterate over the contents of a column set. 
williamr@2
   493
@publishedAll
williamr@2
   494
@released
williamr@2
   495
*/
williamr@2
   496
class TDbColSetIter
williamr@2
   497
	{
williamr@2
   498
public:
williamr@2
   499
	IMPORT_C TDbColSetIter(const CDbColSet& aColSet);
williamr@2
   500
	inline operator TAny* () const;
williamr@2
   501
	inline const TDbCol& operator*() const;
williamr@2
   502
	inline const TDbCol* operator->() const;
williamr@2
   503
	IMPORT_C TDbColSetIter& operator++();
williamr@2
   504
	inline TDbColSetIter operator++(TInt);
williamr@2
   505
	inline TDbColNo Col() const;
williamr@2
   506
private:
williamr@2
   507
	const TDbCol* iColumn;
williamr@2
   508
	TInt iIndex;
williamr@2
   509
	const CArrayPakFlat<TDbCol>* iArray;
williamr@2
   510
	};
williamr@2
   511
williamr@2
   512
/** Defines a key column in an index.
williamr@2
   513
williamr@2
   514
The data members are public as this is really a structure to group the 
williamr@2
   515
attributes of the key column together. Two non-default constructors are 
williamr@2
   516
provided for convenience. 
williamr@2
   517
@publishedAll
williamr@2
   518
@released
williamr@2
   519
*/
williamr@2
   520
class TDbKeyCol
williamr@2
   521
	{
williamr@2
   522
public:
williamr@2
   523
	/** Specifies whether a key column in an index should be sorted in 
williamr@2
   524
	ascending or descending order. */
williamr@2
   525
	enum TOrder 
williamr@2
   526
		{
williamr@2
   527
		/** Use ascending order. */
williamr@2
   528
		EAsc,
williamr@2
   529
		/** Use descending order. */
williamr@2
   530
		EDesc
williamr@2
   531
		};
williamr@2
   532
public:
williamr@2
   533
	/** Constructs an uninitialised object. Default constructor. It is necessary 
williamr@2
   534
	because there are also non-default constructors in this class. */
williamr@2
   535
	inline TDbKeyCol() {}
williamr@2
   536
	inline TDbKeyCol(const TDbKeyCol&);
williamr@2
   537
	inline TDbKeyCol& operator=(const TDbKeyCol&);
williamr@2
   538
	IMPORT_C TDbKeyCol(const TDesC& aName,TOrder anOrder=EAsc);
williamr@2
   539
	IMPORT_C TDbKeyCol(const TDesC& aName,TInt aLength,TOrder anOrder=EAsc);
williamr@2
   540
public:
williamr@2
   541
	/** The ordering of the key. */
williamr@2
   542
	TOrder iOrder;
williamr@2
   543
	/** The maximum number of characters used to index Text or LongText 
williamr@2
   544
	columns. If equal to KDbUndefinedLength (the default), all the characters 
williamr@2
   545
	in the defined column will be used. */
williamr@2
   546
	TInt iLength;
williamr@2
   547
	/** The column name for the key. */
williamr@2
   548
	TDbColNameC iName;
williamr@2
   549
	};
williamr@2
   550
williamr@2
   551
/** 
williamr@2
   552
Represents the definition of an index. The key may be unique or primary, it 
williamr@2
   553
can specify the sort of comparison which is made for Text columns, and it 
williamr@2
   554
has a list of columns which make up the key. The class is used to construct 
williamr@2
   555
and interrogate index keys.
williamr@2
   556
williamr@2
   557
This class is not intended for user derivation. 
williamr@2
   558
@publishedAll
williamr@2
   559
@released
williamr@2
   560
*/
williamr@2
   561
class CDbKey : public CBase
williamr@2
   562
	{
williamr@2
   563
public:
williamr@2
   564
	enum {EUnique=0x01,EPrimary=0x02};
williamr@2
   565
public:
williamr@2
   566
	IMPORT_C CDbKey();
williamr@2
   567
	IMPORT_C static CDbKey* NewL();
williamr@2
   568
	IMPORT_C static CDbKey* NewLC();
williamr@2
   569
	IMPORT_C ~CDbKey();
williamr@2
   570
	IMPORT_C CDbKey& AddL(const TDbKeyCol& aKeyCol);
williamr@2
   571
	IMPORT_C void Remove(const TDesC& aColName);
williamr@2
   572
	IMPORT_C void Clear();
williamr@2
   573
	inline TInt Count() const;
williamr@2
   574
	inline const TDbKeyCol& operator[](TInt aCol) const;
williamr@2
   575
	inline void MakeUnique();
williamr@2
   576
	inline TBool IsUnique() const;
williamr@2
   577
	inline void SetComparison(TDbTextComparison aComparison);
williamr@2
   578
	inline TDbTextComparison Comparison() const;
williamr@2
   579
	inline void MakePrimary();
williamr@2
   580
	inline TBool IsPrimary() const;
williamr@2
   581
private:
williamr@2
   582
	CArrayPakFlat<TDbKeyCol> iKeys;
williamr@2
   583
	TDbTextComparison iComparison;
williamr@2
   584
	TInt iAttributes;
williamr@2
   585
	};
williamr@2
   586
williamr@2
   587
/** 
williamr@2
   588
Saves the current location of a rowset, enabling rapid navigation back to a 
williamr@2
   589
previously visited row or position in the set.
williamr@2
   590
williamr@2
   591
Instances of this class are returned by RDbRowSet::Bookmark(), which can later 
williamr@2
   592
be passed to RDbRowSet::GotoL() to return to the row which was current at 
williamr@2
   593
the call to Bookmark().
williamr@2
   594
williamr@2
   595
@see RDbRowSet::Bookmark()
williamr@2
   596
@see RDbRowSet::GotoL() 
williamr@2
   597
@publishedAll
williamr@2
   598
@released
williamr@2
   599
*/
williamr@2
   600
class TDbBookmark
williamr@2
   601
	{
williamr@2
   602
	friend class RDbRowSet;
williamr@2
   603
public:
williamr@2
   604
	struct TMark
williamr@2
   605
	/** Stores a database bookmark. */
williamr@2
   606
		{
williamr@2
   607
		enum {ESize=8};
williamr@2
   608
		TUint32 iMark[ESize];
williamr@2
   609
		};
williamr@2
   610
private:
williamr@2
   611
	TMark iMark;
williamr@2
   612
	};
williamr@2
   613
williamr@2
   614
/** 
williamr@2
   615
A wrapper for an SQL string combined with a text comparison mode.
williamr@2
   616
williamr@2
   617
An instance of the class is used as a parameter to RDbView::Prepare(), 
williamr@2
   618
RDbRowSet::FindL() and RDbRowConstraint::Open().
williamr@2
   619
williamr@2
   620
The evaluation of SQL queries or constraints depends on how Text columns are 
williamr@2
   621
compared so every SQL string is accompanied by a member of the TDbTextComparison 
williamr@2
   622
enumeration to indicate how comparison is done.
williamr@2
   623
williamr@2
   624
If the SQL string contains a LIKE clause with * (asterisks) wildcard then the 
williamr@2
   625
characters between them must be no longer than length 255.
williamr@2
   626
If only one * exists then the length is taken from the start and to the end of
williamr@2
   627
the clause. However, if the clause contains a ? (question mark) wildcard
williamr@2
   628
within it then the characters between must be no longer than length 253. 
williamr@2
   629
williamr@2
   630
@see TDbTextComparison
williamr@2
   631
@see RDbView::Prepare()
williamr@2
   632
@see RDbRowSet::FindL()
williamr@2
   633
@see RDbRowConstraint::Open() 
williamr@2
   634
@publishedAll
williamr@2
   635
@released
williamr@2
   636
*/
williamr@2
   637
class TDbQuery
williamr@2
   638
	{
williamr@2
   639
public:
williamr@2
   640
	inline TDbQuery(const TDesC& aQuery,TDbTextComparison aComparison=EDbCompareNormal);
williamr@2
   641
	inline const TDesC& Query() const;
williamr@2
   642
	inline TDbTextComparison Comparison() const;
williamr@2
   643
private:
williamr@2
   644
	const TDesC& iQuery;
williamr@2
   645
	TDbTextComparison iComparison;
williamr@2
   646
	};
williamr@2
   647
williamr@2
   648
/** 
williamr@2
   649
This class is internal and is not intended for use 
williamr@2
   650
@publishedAll
williamr@2
   651
@released
williamr@2
   652
*/
williamr@2
   653
class RDbHandleBase
williamr@2
   654
	{
williamr@2
   655
public:
williamr@2
   656
	inline RDbHandleBase();
williamr@2
   657
	void Close();
williamr@2
   658
protected:
williamr@2
   659
	inline void Set(CDbObject* aObject);
williamr@2
   660
	CDbObject& Object() const;
williamr@2
   661
protected:
williamr@2
   662
	CDbObject* iObject;
williamr@2
   663
	};
williamr@2
   664
williamr@2
   665
/** 
williamr@2
   666
This class is internal and is not intended for use. 
williamr@2
   667
@publishedAll
williamr@2
   668
@released
williamr@2
   669
*/
williamr@2
   670
template <class T>
williamr@2
   671
class RDbHandle : public RDbHandleBase
williamr@2
   672
	{
williamr@2
   673
public:
williamr@2
   674
	inline T* operator=(T* aT);
williamr@2
   675
	inline T* operator->() const;
williamr@2
   676
	inline T& operator*() const;
williamr@2
   677
	inline T* operator()() const;
williamr@2
   678
	};
williamr@2
   679
williamr@2
   680
/** 
williamr@2
   681
Represents a pre-compiled SQL search-condition, which can be used to 
williamr@2
   682
test against the current row in a rowset.
williamr@2
   683
williamr@2
   684
The constraint is compiled against a specific rowset, and can only be matched 
williamr@2
   685
against the same rowset using the RDbRowSet::MatchL() function.
williamr@2
   686
williamr@2
   687
@see RDbRowSet 
williamr@2
   688
@publishedAll
williamr@2
   689
@released
williamr@2
   690
*/
williamr@2
   691
class RDbRowConstraint
williamr@2
   692
	{
williamr@2
   693
	friend class RDbRowSet;
williamr@2
   694
public:
williamr@2
   695
	IMPORT_C TInt Open(const RDbRowSet& aView,TDbQuery aCriteria);
williamr@2
   696
	IMPORT_C void Close();
williamr@2
   697
private:
williamr@2
   698
	RDbHandle<CDbRowConstraint> iConstraint;
williamr@2
   699
	};
williamr@2
   700
williamr@2
   701
/** 
williamr@2
   702
An abstract base class that provides functionality which is shared between 
williamr@2
   703
SQL view objects and Table objects. This functionality includes most of the 
williamr@2
   704
cursor navigation, row retrieval and update behaviour of rowsets.
williamr@2
   705
williamr@2
   706
Rowset objects do not provide the data for the rowset on which they operate. 
williamr@2
   707
It is the responsibility of the derived classes RDbView and RDbTable to specify 
williamr@2
   708
the data source.
williamr@2
   709
williamr@2
   710
This class is not intended for user derivation. 
williamr@2
   711
@publishedAll
williamr@2
   712
@released
williamr@2
   713
*/
williamr@2
   714
class RDbRowSet
williamr@2
   715
	{
williamr@2
   716
	friend class RDbRowConstraint;
williamr@2
   717
	friend class RDbColReadStream;
williamr@2
   718
	friend class RDbColWriteStream;
williamr@2
   719
public:
williamr@2
   720
	/** Specifies where the rowset should navigate to in the GotoL() function. 
williamr@2
   721
	Their use is encapsulated by the respective member functions FirstL(), 
williamr@2
   722
	NextL() etc. */
williamr@2
   723
	enum TPosition 
williamr@2
   724
		{
williamr@2
   725
		/** Move to the first row in the rowset. */
williamr@2
   726
		EFirst,
williamr@2
   727
		/** Move to the next row in the rowset. */
williamr@2
   728
		ENext,
williamr@2
   729
		/** Move to the previous row in the rowset. */
williamr@2
   730
		EPrevious,
williamr@2
   731
		/** Move to the last row in the rowset. */
williamr@2
   732
		ELast,
williamr@2
   733
		/** Move to the position before the first row in the rowset. */
williamr@2
   734
		EBeginning,
williamr@2
   735
		/** Move to the position after the last row in the rowset. */
williamr@2
   736
		EEnd
williamr@2
   737
		};
williamr@2
   738
williamr@2
   739
	/** Specifies which operations can be performed on a rowset. */
williamr@2
   740
	enum TAccess 
williamr@2
   741
		{
williamr@2
   742
		/** All operations can be performed on the rowset. */
williamr@2
   743
		EUpdatable,
williamr@2
   744
		/** Row navigation and reading are permitted. */
williamr@2
   745
		EReadOnly,
williamr@2
   746
		/** Inserting new rows is the only valid operation on the rowset. */
williamr@2
   747
		EInsertOnly
williamr@2
   748
		};
williamr@2
   749
williamr@2
   750
	/** Specifies the direction to search through the rowset when using the 
williamr@2
   751
	FindL() function. */
williamr@2
   752
	enum TDirection 
williamr@2
   753
		{
williamr@2
   754
		/** Search from the current row forwards through the set. */
williamr@2
   755
		EForwards,
williamr@2
   756
		/** Search from the current row backwards through the set. */
williamr@2
   757
		EBackwards
williamr@2
   758
		};
williamr@2
   759
williamr@2
   760
	/** Specifies whether the CountL() function should ensure that it returns 
williamr@2
   761
	the exact value which may be a non-trivial task. */
williamr@2
   762
	enum TAccuracy 
williamr@2
   763
		{
williamr@2
   764
		/** Take the time, if necessary, to return the exact value. */
williamr@2
   765
		EEnsure,
williamr@2
   766
		/** Return any immediately available value. */
williamr@2
   767
		EQuick
williamr@2
   768
		};
williamr@2
   769
public:
williamr@2
   770
	IMPORT_C void Close();
williamr@2
   771
	IMPORT_C void Reset();
williamr@2
   772
//
williamr@2
   773
	IMPORT_C CDbColSet* ColSetL() const;
williamr@2
   774
	IMPORT_C TInt ColCount() const;
williamr@2
   775
	IMPORT_C TDbColType ColType(TDbColNo aCol) const;
williamr@2
   776
	IMPORT_C TDbCol ColDef(TDbColNo aCol) const;
williamr@2
   777
//
williamr@2
   778
	IMPORT_C TBool AtRow() const;
williamr@2
   779
	IMPORT_C TBool AtBeginning() const;
williamr@2
   780
	IMPORT_C TBool AtEnd() const;
williamr@2
   781
//
williamr@2
   782
	IMPORT_C TInt CountL(TAccuracy anAccuracy=EEnsure) const;
williamr@2
   783
	IMPORT_C TBool IsEmptyL() const;
williamr@2
   784
//
williamr@2
   785
	IMPORT_C TBool GotoL(TPosition aPosition);
williamr@2
   786
	inline void BeginningL();
williamr@2
   787
	inline void EndL();
williamr@2
   788
	inline TBool FirstL();
williamr@2
   789
	inline TBool LastL();
williamr@2
   790
	inline TBool NextL();
williamr@2
   791
	inline TBool PreviousL();
williamr@2
   792
//
williamr@2
   793
	IMPORT_C TDbBookmark Bookmark() const;
williamr@2
   794
	IMPORT_C void GotoL(const TDbBookmark& aMark);
williamr@2
   795
//
williamr@2
   796
	IMPORT_C TBool MatchL(const RDbRowConstraint& aConstraint);
williamr@2
   797
	IMPORT_C TInt FindL(TDirection aDirection,TDbQuery aCriteria);
williamr@2
   798
//
williamr@2
   799
	IMPORT_C void GetL();
williamr@2
   800
	IMPORT_C void InsertL();
williamr@2
   801
	IMPORT_C void InsertCopyL();
williamr@2
   802
	IMPORT_C void UpdateL();
williamr@2
   803
	IMPORT_C void PutL();
williamr@2
   804
	IMPORT_C void Cancel();
williamr@2
   805
	IMPORT_C void DeleteL();
williamr@2
   806
//
williamr@2
   807
	inline TBool IsColNull(TDbColNo aCol) const;
williamr@2
   808
	IMPORT_C TInt ColSize(TDbColNo aCol) const;
williamr@2
   809
	IMPORT_C TInt ColLength(TDbColNo aCol) const;
williamr@2
   810
//
williamr@2
   811
	IMPORT_C TInt8 ColInt8(TDbColNo aCol) const;
williamr@2
   812
	IMPORT_C TInt16 ColInt16(TDbColNo aCol) const;
williamr@2
   813
	IMPORT_C TInt32 ColInt32(TDbColNo aCol) const;
williamr@2
   814
	IMPORT_C TInt64 ColInt64(TDbColNo aCol) const;
williamr@2
   815
	inline TInt ColInt(TDbColNo aCol) const;
williamr@2
   816
	IMPORT_C TUint8 ColUint8(TDbColNo aCol) const;
williamr@2
   817
	IMPORT_C TUint16 ColUint16(TDbColNo aCol) const;
williamr@2
   818
	IMPORT_C TUint32 ColUint32(TDbColNo aCol) const;
williamr@2
   819
	inline TUint ColUint(TDbColNo aCol) const;
williamr@2
   820
	IMPORT_C TReal32 ColReal32(TDbColNo aCol) const __SOFTFP;
williamr@2
   821
	IMPORT_C TReal64 ColReal64(TDbColNo aCol) const __SOFTFP;
williamr@2
   822
	inline TReal ColReal(TDbColNo aCol) const;
williamr@2
   823
	IMPORT_C TTime ColTime(TDbColNo aCol) const;
williamr@2
   824
	IMPORT_C TPtrC8 ColDes8(TDbColNo aCol) const;
williamr@2
   825
	IMPORT_C TPtrC16 ColDes16(TDbColNo aCol) const;
williamr@2
   826
	IMPORT_C TPtrC ColDes(TDbColNo aCol) const;
williamr@2
   827
//
williamr@2
   828
	IMPORT_C void SetColNullL(TDbColNo aCol);
williamr@2
   829
	inline void SetColL(TDbColNo aCol,TInt aValue);
williamr@2
   830
	IMPORT_C void SetColL(TDbColNo aCol,TInt32 aValue);
williamr@2
   831
	IMPORT_C void SetColL(TDbColNo aCol,TInt64 aValue);
williamr@2
   832
	inline void SetColL(TDbColNo aCol,TUint aValue);
williamr@2
   833
	IMPORT_C void SetColL(TDbColNo aCol,TUint32 aValue);
williamr@2
   834
	IMPORT_C void SetColL(TDbColNo aCol,TReal32 aValue) __SOFTFP;
williamr@2
   835
	IMPORT_C void SetColL(TDbColNo aCol,TReal64 aValue) __SOFTFP;
williamr@2
   836
	IMPORT_C void SetColL(TDbColNo aCol,TTime aValue);
williamr@2
   837
	IMPORT_C void SetColL(TDbColNo aCol,const TDesC8& aValue);
williamr@2
   838
	IMPORT_C void SetColL(TDbColNo aCol,const TDesC16& aValue);
williamr@2
   839
private:
williamr@2
   840
	inline MStreamBuf* ColSourceL(TDbColNo aCol) const;
williamr@2
   841
	inline MStreamBuf* ColSinkL(TDbColNo aCol);
williamr@2
   842
	CDbCursor& CheckCol(TDbColNo aCol) const;
williamr@2
   843
	TDbColumnC ColumnC(TDbColNo aCol,TDbColType aType) const;
williamr@2
   844
	TDbColumn Column(TDbColNo aCol,TDbColType aType);
williamr@2
   845
protected:
williamr@2
   846
	RDbHandle<CDbCursor> iCursor;
williamr@2
   847
	};
williamr@2
   848
williamr@2
   849
/** 
williamr@2
   850
Allows any column value to be read as stream data.
williamr@2
   851
williamr@2
   852
Note that this is the only way to extract the contents of a Long column from 
williamr@2
   853
a rowset.
williamr@2
   854
williamr@2
   855
Only one column in a rowset object can be opened for reading as a stream at 
williamr@2
   856
a time, and while it is open no column in the same rowset object may be set 
williamr@2
   857
using RDbColWriteStream.
williamr@2
   858
williamr@2
   859
Null columns result in a read stream with no data. Small numeric columns are 
williamr@2
   860
maintained in memory as 32-bit values; hence reading a Uint8 column as a stream 
williamr@2
   861
results in 4 bytes of stream data, not 1. 
williamr@2
   862
@publishedAll
williamr@2
   863
@released
williamr@2
   864
*/
williamr@2
   865
class RDbColReadStream : public RReadStream
williamr@2
   866
	{
williamr@2
   867
public:
williamr@2
   868
	IMPORT_C void OpenL(const RDbRowSet& aView,TDbColNo aCol);
williamr@2
   869
	IMPORT_C void OpenLC(const RDbRowSet& aView,TDbColNo aCol);
williamr@2
   870
	};
williamr@2
   871
williamr@2
   872
/** 
williamr@2
   873
Writes Long columns when inserting or updating rows in a rowset. 
williamr@2
   874
williamr@2
   875
Only one column in a rowset object can be opened for writing as a stream at 
williamr@2
   876
a time. 
williamr@2
   877
@publishedAll
williamr@2
   878
@released
williamr@2
   879
*/
williamr@2
   880
class RDbColWriteStream : public RWriteStream
williamr@2
   881
	{
williamr@2
   882
public:
williamr@2
   883
	/** Constructs this object by invoking the default constructor for 
williamr@2
   884
	RWriteStream. */
williamr@2
   885
	inline RDbColWriteStream() {}
williamr@2
   886
	inline RDbColWriteStream(const MExternalizer<TStreamRef> &anExternalizer);
williamr@2
   887
	IMPORT_C void OpenL(RDbRowSet& aView,TDbColNo aCol);
williamr@2
   888
	IMPORT_C void OpenLC(RDbRowSet& aView,TDbColNo aCol);
williamr@2
   889
	};
williamr@2
   890
williamr@2
   891
/** 
williamr@2
   892
Describes the desired shape of a view's pre-evaluation window.
williamr@2
   893
williamr@2
   894
An instance of this class is passed to the RDbView object as part of the 
williamr@2
   895
Prepare() function. The different constructors for TDbWindow can specify a view:
williamr@2
   896
williamr@2
   897
without pre-evaluation
williamr@2
   898
williamr@2
   899
with full pre-evaluation
williamr@2
   900
williamr@2
   901
with limited pre-evaluation.
williamr@2
   902
williamr@2
   903
@see RDbView 
williamr@2
   904
@publishedAll
williamr@2
   905
@released
williamr@2
   906
*/
williamr@2
   907
class TDbWindow
williamr@2
   908
	{
williamr@2
   909
public:
williamr@2
   910
	/** Denotes a full pre-evaluation window. */
williamr@2
   911
	enum TUnlimited 
williamr@2
   912
		{
williamr@2
   913
		/** No limit on how many rows may be in the window. */
williamr@2
   914
		EUnlimited=KMaxTInt
williamr@2
   915
		};
williamr@2
   916
	enum {ENone=0};
williamr@2
   917
public:
williamr@2
   918
	inline TDbWindow();
williamr@2
   919
	inline TDbWindow(TUnlimited);
williamr@2
   920
	IMPORT_C TDbWindow(TInt aForeSlots,TInt aRearSlots);
williamr@2
   921
	inline TInt Size() const;
williamr@2
   922
	inline TInt PreferredPos() const;
williamr@2
   923
private:
williamr@2
   924
	TInt iSize;
williamr@2
   925
	TInt iPreferredPos;
williamr@2
   926
	};
williamr@2
   927
#if defined(__NO_CLASS_CONSTS__)
williamr@2
   928
/**
williamr@2
   929
@internalComponent
williamr@2
   930
*/
williamr@2
   931
#define KDbUnlimitedWindow TDbWindow(TDbWindow::EUnlimited)
williamr@2
   932
#else
williamr@2
   933
/**
williamr@2
   934
@publishedAll
williamr@2
   935
@released
williamr@2
   936
*/
williamr@2
   937
const TDbWindow KDbUnlimitedWindow=TDbWindow(TDbWindow::EUnlimited);
williamr@2
   938
#endif
williamr@2
   939
williamr@2
   940
/** 
williamr@2
   941
Generates rowsets from an SQL query. The query is prepared and evaluated 
williamr@2
   942
using the interface to this class, while the rowset is manipulated using the 
williamr@2
   943
RDbRowset base class.
williamr@2
   944
williamr@2
   945
There are no special rules to consider when deriving from this class. 
williamr@2
   946
@publishedAll
williamr@2
   947
@released
williamr@2
   948
*/
williamr@2
   949
class RDbView : public RDbRowSet
williamr@2
   950
	{
williamr@2
   951
public:
williamr@2
   952
	IMPORT_C TInt Prepare(RDbDatabase& aDatabase,const TDbQuery& aQuery,TAccess anAccess=EUpdatable);
williamr@2
   953
	IMPORT_C TInt Prepare(RDbDatabase& aDatabase,const TDbQuery& aQuery,const TDbWindow& aWindow);
williamr@2
   954
	IMPORT_C TInt Prepare(RDbDatabase& aDatabase,const TDbQuery& aQuery,const TDbWindow& aWindow,TAccess anAccess);
williamr@2
   955
	IMPORT_C TInt EvaluateAll();
williamr@2
   956
	IMPORT_C TInt Evaluate();
williamr@2
   957
	IMPORT_C void Evaluate(TRequestStatus& aStatus);
williamr@2
   958
	IMPORT_C TBool Unevaluated() const;
williamr@2
   959
	};
williamr@2
   960
williamr@2
   961
/** 
williamr@2
   962
This class is internal and is not intended for use. 
williamr@2
   963
@publishedAll
williamr@2
   964
@released
williamr@2
   965
*/
williamr@2
   966
template <class T>
williamr@2
   967
class TUnion
williamr@2
   968
	{
williamr@2
   969
public:
williamr@2
   970
	inline operator const T&() const;
williamr@2
   971
	inline const T& operator()() const;
williamr@2
   972
	inline T& operator()();
williamr@2
   973
	inline void Set(const T& aT);
williamr@2
   974
private:
williamr@2
   975
	TUint8 iRep[sizeof(T)];
williamr@2
   976
	};
williamr@2
   977
williamr@2
   978
/** 
williamr@2
   979
This class is internal and is not intended for use. 
williamr@2
   980
@publishedAll
williamr@2
   981
@released
williamr@2
   982
*/
williamr@2
   983
class TDbLookupKey
williamr@2
   984
	{
williamr@2
   985
public:
williamr@2
   986
	struct SColumn
williamr@2
   987
		{
williamr@2
   988
		union
williamr@2
   989
			{
williamr@2
   990
			TInt32 iInt32;
williamr@2
   991
			TUint32 iUint32;
williamr@2
   992
			TUnion<TInt64> iInt64;
williamr@2
   993
			TReal32 iReal32;
williamr@2
   994
			TReal64 iReal64;
williamr@2
   995
			TUnion<TTime> iTime;
williamr@2
   996
			struct {const TText8* iPtr;TInt iLength;} iDes8;
williamr@2
   997
			struct {const TText16* iPtr;TInt iLength;} iDes16;
williamr@2
   998
			};
williamr@2
   999
		TDbColType iType;
williamr@2
  1000
		};
williamr@2
  1001
public:
williamr@2
  1002
	inline TDbLookupKey();
williamr@2
  1003
	inline TInt Count() const;
williamr@2
  1004
	inline const SColumn* First() const;
williamr@2
  1005
	void Add(TInt aKey);
williamr@2
  1006
	void Add(TUint aKey);
williamr@2
  1007
	void Add(TInt64 aKey);
williamr@2
  1008
	void Add(TReal32 aKey) __SOFTFP;
williamr@2
  1009
	void Add(TReal64 aKey) __SOFTFP;
williamr@2
  1010
	void Add(TTime aKey);
williamr@2
  1011
	void Add(const TDesC8& aKey);
williamr@2
  1012
	void Add(const TDesC16& aKey);
williamr@2
  1013
private:
williamr@2
  1014
	SColumn& NextKey();
williamr@2
  1015
private:
williamr@2
  1016
	TInt iCount;
williamr@2
  1017
	SColumn iKey[1];	// at least one
williamr@2
  1018
	};
williamr@2
  1019
williamr@2
  1020
/** 
williamr@2
  1021
Database key value.
williamr@2
  1022
williamr@2
  1023
The class encapsulates a key value which is passed to RDbTable::SeekL(), for 
williamr@2
  1024
lookup in the currently active index on that rowset.
williamr@2
  1025
williamr@2
  1026
An instance of this class can store a key value of any type.
williamr@2
  1027
williamr@2
  1028
Note that the class can only hold a single-column key. Use TDbSeekMultiKey 
williamr@2
  1029
for multi-column keys.
williamr@2
  1030
williamr@2
  1031
@see TDbSeekMultiKey
williamr@2
  1032
@see RDbTable 
williamr@2
  1033
@publishedAll
williamr@2
  1034
@released
williamr@2
  1035
*/
williamr@2
  1036
class TDbSeekKey
williamr@2
  1037
	{
williamr@2
  1038
	friend class RDbTable;
williamr@2
  1039
public:
williamr@2
  1040
	inline TDbSeekKey();
williamr@2
  1041
	inline TDbSeekKey(TInt aKey);
williamr@2
  1042
	inline TDbSeekKey(TUint aKey);
williamr@2
  1043
	inline TDbSeekKey(TInt64 aKey);
williamr@2
  1044
	inline TDbSeekKey(TReal32 aKey);
williamr@2
  1045
	inline TDbSeekKey(TReal64 aKey);
williamr@2
  1046
	inline TDbSeekKey(TTime aKey);
williamr@2
  1047
	inline TDbSeekKey(const TDesC8& aKey);
williamr@2
  1048
	inline TDbSeekKey(const TDesC16& aKey);
williamr@2
  1049
	IMPORT_C TDbSeekKey& Add(TInt aKey);
williamr@2
  1050
	IMPORT_C TDbSeekKey& Add(TUint aKey);
williamr@2
  1051
	IMPORT_C TDbSeekKey& Add(TInt64 aKey);
williamr@2
  1052
	IMPORT_C TDbSeekKey& Add(TReal32 aKey) __SOFTFP;
williamr@2
  1053
	IMPORT_C TDbSeekKey& Add(TReal64 aKey) __SOFTFP;
williamr@2
  1054
	IMPORT_C TDbSeekKey& Add(TTime aKey);
williamr@2
  1055
	IMPORT_C TDbSeekKey& Add(const TDesC8& aKey);
williamr@2
  1056
	IMPORT_C TDbSeekKey& Add(const TDesC16& aKey);
williamr@2
  1057
private:
williamr@2
  1058
	TDbLookupKey& Check();
williamr@2
  1059
protected:
williamr@2
  1060
	inline TDbSeekKey(TInt aKeys,TInt);
williamr@2
  1061
private:
williamr@2
  1062
	TInt iMaxKeys;
williamr@2
  1063
	TDbLookupKey iKey;
williamr@2
  1064
	};
williamr@2
  1065
williamr@2
  1066
/** 
williamr@2
  1067
Database multi-column key value.
williamr@2
  1068
williamr@2
  1069
The class extends the behaviour of TDbSeekKey by allowing multi-column indexes 
williamr@2
  1070
to be searched using multi-column key values.
williamr@2
  1071
williamr@2
  1072
The template parameter S specifies the maximum number of column values that 
williamr@2
  1073
can be added to the key value.
williamr@2
  1074
williamr@2
  1075
Use the TDbSeekKey::Add() members to append the values for each column in 
williamr@2
  1076
the key value. 
williamr@2
  1077
@publishedAll
williamr@2
  1078
@released
williamr@2
  1079
*/
williamr@2
  1080
template<TInt S>
williamr@2
  1081
class TDbSeekMultiKey : public TDbSeekKey
williamr@2
  1082
	{
williamr@2
  1083
public:
williamr@2
  1084
	inline TDbSeekMultiKey();
williamr@2
  1085
private:
williamr@2
  1086
	TDbLookupKey::SColumn iExtraKeys[S-1];
williamr@2
  1087
	};
williamr@2
  1088
williamr@2
  1089
/** 
williamr@2
  1090
Provides access to table data as a rowset, allowing manipulation of a named 
williamr@2
  1091
table in the database. Additionally, a named index can be used to order the 
williamr@2
  1092
rowset, and to provide fast key-based row retrieval from the table.
williamr@2
  1093
williamr@2
  1094
There are no special rules to consider when deriving from this class. 
williamr@2
  1095
@publishedAll
williamr@2
  1096
@released
williamr@2
  1097
*/
williamr@2
  1098
class RDbTable : public RDbRowSet
williamr@2
  1099
	{
williamr@2
  1100
public:
williamr@2
  1101
	/** Database table seek comparison types. */
williamr@2
  1102
	enum TComparison 
williamr@2
  1103
		{
williamr@2
  1104
		/** Retrieve the last row which is strictly less than the key value. */
williamr@2
  1105
		ELessThan,
williamr@2
  1106
		/** Retrieve the last row which is equal to or less than the key 
williamr@2
  1107
		value. */
williamr@2
  1108
		ELessEqual,
williamr@2
  1109
		/** Retrieve the first row which is equal to the key value. */
williamr@2
  1110
		EEqualTo,
williamr@2
  1111
		/** Retrieve the first row which is equal to or greater than the key 
williamr@2
  1112
		value. */
williamr@2
  1113
		EGreaterEqual,
williamr@2
  1114
		/** Retrieve the first row which is strictly greater than the key 
williamr@2
  1115
		value. */
williamr@2
  1116
		EGreaterThan
williamr@2
  1117
		};
williamr@2
  1118
public:
williamr@2
  1119
	IMPORT_C TInt Open(RDbDatabase& aDatabase,const TDesC& aName,TAccess anAccess=EUpdatable);
williamr@2
  1120
	inline TInt SetIndex(const TDesC& anIndex);
williamr@2
  1121
	inline TInt SetNoIndex();
williamr@2
  1122
	IMPORT_C TBool SeekL(const TDbSeekKey& aKey,TComparison aComparison=EEqualTo);
williamr@2
  1123
private:
williamr@2
  1124
	IMPORT_C TInt SetIndex(const TDesC* anIndex);
williamr@2
  1125
	};
williamr@2
  1126
williamr@2
  1127
/**
williamr@2
  1128
@publishedAll
williamr@2
  1129
@released
williamr@2
  1130
*/
williamr@2
  1131
class CDbNames : public CBase
williamr@2
  1132
	{
williamr@2
  1133
private:
williamr@2
  1134
	inline CDbNames();
williamr@2
  1135
public:
williamr@2
  1136
	static CDbNames* NewLC();
williamr@2
  1137
	~CDbNames();
williamr@2
  1138
	inline TInt Count() const;
williamr@2
  1139
	inline const TDesC& operator[](TInt anIndex) const;
williamr@2
  1140
	IMPORT_C void AddL(const TDesC& aName);
williamr@2
  1141
private:
williamr@2
  1142
	CArrayPakFlat<TDbNameC> iList;
williamr@2
  1143
	};
williamr@2
  1144
/**
williamr@2
  1145
@publishedAll
williamr@2
  1146
@released
williamr@2
  1147
*/
williamr@2
  1148
typedef CDbNames CDbTableNames,CDbIndexNames,CDbDatabaseNames;
williamr@2
  1149
williamr@2
  1150
/**
williamr@2
  1151
The maximum length for a generic DBMS string, which might be transferred from DBMS server
williamr@2
  1152
to the DBMS client using IPC.
williamr@2
  1153
@publishedAll
williamr@2
  1154
@released
williamr@2
  1155
*/
williamr@2
  1156
const TInt KDbMaxStrLen = 256;
williamr@2
  1157
williamr@2
  1158
/** 
williamr@2
  1159
Represents a generic read-only DBMS string. It maps to a non-modifiable buffer descriptor 
williamr@2
  1160
with maximum size KDbMaxStrLen.
williamr@2
  1161
williamr@2
  1162
@see TBufC
williamr@2
  1163
@publishedAll
williamr@2
  1164
@released
williamr@2
  1165
*/
williamr@2
  1166
typedef TBufC<KDbMaxStrLen> TDbStringC;
williamr@2
  1167
williamr@2
  1168
/**
williamr@2
  1169
CDbStrings encapsulates functionality used for transferring an array of strings from 
williamr@2
  1170
DBMS server to the DBMS client. The maximal length of each element of the array is 
williamr@2
  1171
KDbMaxStrLen characters.
williamr@2
  1172
The typical usage pattern of CDbStrings class is:
williamr@2
  1173
@code
williamr@2
  1174
CDbStrings* strings = <a call of an exported DBMS method>;
williamr@2
  1175
TInt cnt = strings.Count();
williamr@2
  1176
for(TInt i=0;i<cnt;++i)
williamr@2
  1177
	{
williamr@2
  1178
	const TDesC& str = (*strings)[i];
williamr@2
  1179
	<do something with "str" variable>;
williamr@2
  1180
	}
williamr@2
  1181
delete strings;
williamr@2
  1182
@endcode
williamr@2
  1183
@publishedAll
williamr@2
  1184
@released
williamr@2
  1185
*/
williamr@2
  1186
class CDbStrings : public CBase
williamr@2
  1187
	{
williamr@2
  1188
private:
williamr@2
  1189
	inline CDbStrings();
williamr@2
  1190
public:
williamr@2
  1191
	static CDbStrings* NewLC();
williamr@2
  1192
	virtual ~CDbStrings();
williamr@2
  1193
	inline TInt Count() const;
williamr@2
  1194
	inline const TDesC& operator[](TInt aIndex) const;
williamr@2
  1195
	void AddL(const TDesC& aStr);
williamr@2
  1196
private:
williamr@2
  1197
	CArrayPakFlat<TDbStringC> iList;
williamr@2
  1198
	};
williamr@2
  1199
williamr@2
  1200
/**
williamr@2
  1201
Abstract class providing the functionality of a database.
williamr@2
  1202
williamr@2
  1203
The source of the database and the implementation characteristics of a particular
williamr@2
  1204
database are provided by a class derived from RDbDatabase. 
williamr@2
  1205
williamr@2
  1206
DBMS has one such implementation: the store database.
williamr@2
  1207
williamr@2
  1208
This class is not intended for user derivation.
williamr@2
  1209
williamr@2
  1210
Note: For functions (i.e. Execute) that take an Sql string, if the string
williamr@2
  1211
contains a LIKE clause with * (asterisks) wildcard then the 
williamr@2
  1212
characters between them must be no longer than length 255.
williamr@2
  1213
If only one * exists then the length is taken from the start and to the end of
williamr@2
  1214
the clause. However, if the clause contains a ? (question mark) wildcard
williamr@2
  1215
within it then the characters between must be no longer than length 253. 
williamr@2
  1216
williamr@2
  1217
@publishedAll
williamr@2
  1218
@released
williamr@2
  1219
*/
williamr@2
  1220
class RDbDatabase
williamr@2
  1221
	{
williamr@2
  1222
	friend class RDbView;
williamr@2
  1223
	friend class RDbTable;
williamr@2
  1224
	friend class RDbIncremental;
williamr@2
  1225
	friend class RDbUpdate;
williamr@2
  1226
	friend class RDbNotifier;
williamr@2
  1227
public:
williamr@2
  1228
	struct TSize {TInt iSize;TInt iUsage;};
williamr@2
  1229
public:
williamr@2
  1230
	IMPORT_C void Close();
williamr@2
  1231
	IMPORT_C TInt Destroy();
williamr@2
  1232
//
williamr@2
  1233
	IMPORT_C TBool IsDamaged() const;
williamr@2
  1234
	IMPORT_C TInt Recover();
williamr@2
  1235
//
williamr@2
  1236
	IMPORT_C TInt UpdateStats();
williamr@2
  1237
	IMPORT_C TSize Size() const;
williamr@2
  1238
	IMPORT_C TInt Compact();
williamr@2
  1239
	IMPORT_C TInt Begin();
williamr@2
  1240
	IMPORT_C TInt Commit();
williamr@2
  1241
	IMPORT_C void Rollback();
williamr@2
  1242
	IMPORT_C TBool InTransaction() const;
williamr@2
  1243
//
williamr@2
  1244
	inline TInt CreateTable(const TDesC& aName,const CDbColSet& aDef);
williamr@2
  1245
	inline TInt CreateTable(const TDesC& aName,const CDbColSet& aDef,const CDbKey& aPrimaryKey);
williamr@2
  1246
	IMPORT_C TInt DropTable(const TDesC& aName);
williamr@2
  1247
	IMPORT_C TInt AlterTable(const TDesC& aName,const CDbColSet& aNewDef);
williamr@2
  1248
	IMPORT_C TInt CreateIndex(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey);
williamr@2
  1249
 	IMPORT_C TInt DropIndex(const TDesC& aName,const TDesC& aTable);
williamr@2
  1250
//
williamr@2
  1251
	IMPORT_C TInt Execute(const TDesC& aSql,TDbTextComparison aComparison=EDbCompareNormal);
williamr@2
  1252
//
williamr@2
  1253
	IMPORT_C CDbTableNames* TableNamesL() const;
williamr@2
  1254
	IMPORT_C CDbColSet* ColSetL(const TDesC& aName) const;
williamr@2
  1255
	IMPORT_C CDbIndexNames* IndexNamesL(const TDesC& aTable) const;
williamr@2
  1256
	IMPORT_C CDbKey* KeyL(const TDesC& aName,const TDesC& aTable) const;
williamr@2
  1257
private:
williamr@2
  1258
	IMPORT_C TInt CreateTable(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey);
williamr@2
  1259
protected:
williamr@2
  1260
	RDbHandle<CDbDatabase> iDatabase;
williamr@2
  1261
	};
williamr@2
  1262
williamr@2
  1263
/** 
williamr@2
  1264
Provides the interface for performing long-running database operations in 
williamr@2
  1265
incremental steps, allowing application programs to remain responsive to other 
williamr@2
  1266
events.
williamr@2
  1267
williamr@2
  1268
After an operation has begun, a standard interface is used to continue and 
williamr@2
  1269
complete all incremental operations. On successful return from one of the 
williamr@2
  1270
initiating functions, a step value is also returned. This gives the progress 
williamr@2
  1271
indication and is, initially, positive. This value should be passed into 
williamr@2
  1272
subsequent steps in the operation, each of which may decrement the value by 
williamr@2
  1273
some amount, although they are allowed to leave it unchanged. The value 
williamr@2
  1274
reaches zero, if, and only if the operation completes.
williamr@2
  1275
williamr@2
  1276
While an incremental operation is in progress, the database cannot be used 
williamr@2
  1277
for any other operations such as opening tables or preparing views. 
williamr@2
  1278
williamr@2
  1279
Starting an incremental operation also requires that no rowsets are open on 
williamr@2
  1280
the database and that no commit is pending for data manipulation transactions.
williamr@2
  1281
williamr@2
  1282
If no explicit transaction has been started by the database, then an automatic 
williamr@2
  1283
transaction is begun when any incremental operation is started and is committed 
williamr@2
  1284
when complete or rolled back if the operation either fails or is abandoned 
williamr@2
  1285
prior to completion. 
williamr@2
  1286
@publishedAll
williamr@2
  1287
@released
williamr@2
  1288
*/
williamr@2
  1289
class RDbIncremental
williamr@2
  1290
	{
williamr@2
  1291
public:
williamr@2
  1292
	IMPORT_C void Close();
williamr@2
  1293
	IMPORT_C TInt Next(TInt& aStep);
williamr@2
  1294
	IMPORT_C void Next(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus);
williamr@2
  1295
//
williamr@2
  1296
	IMPORT_C TInt Recover(RDbDatabase& aDatabase,TInt& aStep);
williamr@2
  1297
	IMPORT_C TInt Compact(RDbDatabase& aDatabase,TInt& aStep);
williamr@2
  1298
	IMPORT_C TInt DropTable(RDbDatabase& aDatabase,const TDesC& aTable,TInt& aStep);
williamr@2
  1299
	IMPORT_C TInt AlterTable(RDbDatabase& aDatabase,const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep);
williamr@2
  1300
	IMPORT_C TInt CreateIndex(RDbDatabase& aDatabase,const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep);
williamr@2
  1301
	IMPORT_C TInt DropIndex(RDbDatabase& aDatabase,const TDesC& aName,const TDesC& aTable,TInt& aStep);
williamr@2
  1302
	inline TInt Execute(RDbDatabase& aDatabase,const TDesC& aSql,TInt& aStep);
williamr@2
  1303
	IMPORT_C TInt Execute(RDbDatabase& aDatabase,const TDesC& aSql,TDbTextComparison aComparison,TInt& aStep);
williamr@2
  1304
	IMPORT_C TInt UpdateStats(RDbDatabase& aDatabase,TInt& aStep);
williamr@2
  1305
private:
williamr@2
  1306
	RDbHandle<CDbIncremental> iState;
williamr@2
  1307
	};
williamr@2
  1308
williamr@2
  1309
/** 
williamr@2
  1310
Provides an interface to allow incremental execution of a DML (SQL data 
williamr@2
  1311
update) statement. 
williamr@2
  1312
williamr@2
  1313
This class offers similar behaviour to the RDbIncremental class, in that it 
williamr@2
  1314
allows an application to perform long running operations while remaining 
williamr@2
  1315
responsive to events. However, unlike that class, RDbUpdate is restricted to 
williamr@2
  1316
executing DML statements.
williamr@2
  1317
williamr@2
  1318
@see RDbIncremental 
williamr@2
  1319
@publishedAll
williamr@2
  1320
@released
williamr@2
  1321
*/
williamr@2
  1322
class RDbUpdate
williamr@2
  1323
	{
williamr@2
  1324
public:
williamr@2
  1325
	IMPORT_C TInt Execute(RDbDatabase& aDatabase,const TDesC& aSql,TDbTextComparison aComparison=EDbCompareNormal);
williamr@2
  1326
	IMPORT_C void Close();
williamr@2
  1327
//
williamr@2
  1328
	IMPORT_C TInt Next();
williamr@2
  1329
	IMPORT_C void Next(TRequestStatus& aStatus);
williamr@2
  1330
	IMPORT_C TInt RowCount() const;
williamr@2
  1331
private:
williamr@2
  1332
	RDbHandle<CDbIncremental> iUpdate;
williamr@2
  1333
	TPckgBuf<TInt> iRows;
williamr@2
  1334
	};
williamr@2
  1335
williamr@2
  1336
/** 
williamr@2
  1337
Provides notification of database changes to clients.
williamr@2
  1338
williamr@2
  1339
This is useful for shared databases. 
williamr@2
  1340
@publishedAll
williamr@2
  1341
@released
williamr@2
  1342
*/
williamr@2
  1343
class RDbNotifier
williamr@2
  1344
	{
williamr@2
  1345
public:
williamr@2
  1346
	/** Defines the events which may be reported by a DBMS change notifier 
williamr@2
  1347
	through this RDbNotifier object.
williamr@2
  1348
williamr@2
  1349
	Each enumerator corresponds to a distinct event type.
williamr@2
  1350
williamr@2
  1351
	The changes are reported through a TRequestStatus object when an 
williamr@2
  1352
	outstanding notification request completes.
williamr@2
  1353
williamr@2
  1354
	Notes
williamr@2
  1355
williamr@2
  1356
	If further database events occur while a client is handling the completion 
williamr@2
  1357
	of a previous event, the notifier remembers the most significant event. The 
williamr@2
  1358
	order of importance is:
williamr@2
  1359
williamr@2
  1360
	ERecover > ERollback > ECommit
williamr@2
  1361
williamr@2
  1362
	where the symbol > means "is more important than" */
williamr@2
  1363
	enum TEvent 
williamr@2
  1364
		{
williamr@2
  1365
		/** The database has been closed. */
williamr@2
  1366
		EClose,
williamr@2
  1367
		/** All read locks have been removed. */
williamr@2
  1368
		EUnlock,
williamr@2
  1369
		/** A transaction has been committed. */
williamr@2
  1370
		ECommit,
williamr@2
  1371
		/** A transaction has been rolled back */
williamr@2
  1372
		ERollback,
williamr@2
  1373
		/** The database has been recovered */
williamr@2
  1374
		ERecover
williamr@2
  1375
		};
williamr@2
  1376
public:
williamr@2
  1377
	IMPORT_C TInt Open(RDbDatabase& aDatabase);
williamr@2
  1378
	IMPORT_C void Close();
williamr@2
  1379
//
williamr@2
  1380
	IMPORT_C void NotifyUnlock(TRequestStatus& aStatus);
williamr@2
  1381
	IMPORT_C void NotifyChange(TRequestStatus& aStatus);
williamr@2
  1382
	IMPORT_C void Cancel();
williamr@2
  1383
private:
williamr@2
  1384
	RDbHandle<CDbNotifier> iNotifier;
williamr@2
  1385
	};
williamr@2
  1386
williamr@2
  1387
/** 
williamr@2
  1388
Client-server databases
williamr@2
  1389
williamr@2
  1390
Represents a session with the DBMS server. A thread uses this class to set 
williamr@2
  1391
up a DBMS server session and this provides the basis for sharing databases 
williamr@2
  1392
with other threads. 
williamr@2
  1393
@publishedAll
williamr@2
  1394
@released
williamr@2
  1395
*/
williamr@2
  1396
class RDbs : public RSessionBase
williamr@2
  1397
	{
williamr@2
  1398
public:
williamr@2
  1399
	/**
williamr@2
  1400
	This enum is used in GetDatabasePolicy/GetTablePolicy/GetTablePolicies calls and specifies
williamr@2
  1401
	requested security policy type: read/write/schema.
williamr@2
  1402
	@publishedAll
williamr@2
  1403
	@released
williamr@2
  1404
	*/
williamr@2
  1405
	typedef enum {EReadPolicy, EWritePolicy, ESchemaPolicy} TPolicyType;
williamr@2
  1406
williamr@2
  1407
public:
williamr@2
  1408
	IMPORT_C static TVersion Version();
williamr@2
  1409
	IMPORT_C TInt Connect();
williamr@2
  1410
	IMPORT_C CDbDatabaseNames* DatabaseNamesL(TDriveNumber aDrive, TUid aPolicyUid);
williamr@2
  1411
	IMPORT_C TInt CopyDatabase(const TDesC& aSrcDbName, const TDesC& aDestDbName, TUid aPolicyUid);
williamr@2
  1412
	IMPORT_C TInt DeleteDatabase(const TDesC& aDbName, TUid aPolicyUid);
williamr@2
  1413
	IMPORT_C TInt GetDatabasePolicy(TUid aPolicyUid, TPolicyType aPolicyType, 
williamr@2
  1414
									TSecurityPolicy& aDbPolicy);
williamr@2
  1415
	IMPORT_C TInt GetTablePolicy(TUid aPolicyUid, const TDesC& aTableName, 
williamr@2
  1416
								 TPolicyType aPolicyType, TSecurityPolicy& aTablePolicy);
williamr@2
  1417
	IMPORT_C TInt GetTablePolicies(TUid aPolicyUid, const TDesC& aTableName, 
williamr@2
  1418
								   TPolicyType aPolicyType, 
williamr@2
  1419
								   TSecurityPolicy& aDbPolicy, TSecurityPolicy& aTablePolicy);
williamr@2
  1420
	//
williamr@2
  1421
	IMPORT_C void ResourceMark();
williamr@2
  1422
	IMPORT_C void ResourceCheck();
williamr@2
  1423
	IMPORT_C TInt ResourceCount();
williamr@2
  1424
	IMPORT_C void SetHeapFailure(TInt aTAllocFail,TInt aRate);
williamr@2
  1425
williamr@2
  1426
	IMPORT_C TInt ReserveDriveSpace(TInt aDriveNo, TInt aSpace);
williamr@2
  1427
	IMPORT_C void FreeReservedSpace(TInt aDriveNo);
williamr@2
  1428
	IMPORT_C TInt GetReserveAccess(TInt aDriveNo);
williamr@2
  1429
	IMPORT_C TInt ReleaseReserveAccess(TInt aDriveNo);
williamr@2
  1430
williamr@2
  1431
	IMPORT_C TInt GetBackupPath(TSecureId aRequesterSid, const TDesC& aDbName, 
williamr@2
  1432
								TUid aDbPolicyUid, TDes& aBackupPath);
williamr@2
  1433
	IMPORT_C CDbStrings* BackupPathsL(TSecureId aRequesterSid, TUid aDbPolicyUid);
williamr@2
  1434
williamr@2
  1435
private:
williamr@2
  1436
	TInt DoConnect();
williamr@2
  1437
	TInt SessionMessage(TInt aFunction);
williamr@2
  1438
	TInt GetPolicy(TUid aPolicyUid, const TDesC& aTableName, 
williamr@2
  1439
				   TUint aMask, TSecurityPolicy& aPolicy);
williamr@2
  1440
	};
williamr@2
  1441
williamr@2
  1442
/**
williamr@2
  1443
Generic database implementation
williamr@2
  1444
@publishedAll
williamr@2
  1445
@released
williamr@2
  1446
*/
williamr@2
  1447
class RDbNamedDatabase : public RDbDatabase
williamr@2
  1448
	{
williamr@2
  1449
public:
williamr@2
  1450
	/** Specifies which operations can be performed on a rowset. */
williamr@2
  1451
	enum TAccess 
williamr@2
  1452
	{
williamr@2
  1453
	EReadWrite,
williamr@2
  1454
	/** Row navigation and reading are permitted. */
williamr@2
  1455
	EReadOnly
williamr@2
  1456
	};
williamr@2
  1457
public:
williamr@2
  1458
	IMPORT_C TInt Create(RDbs& aDbs, const TDesC& aDatabase, const TDesC& aFormat);
williamr@2
  1459
	IMPORT_C TInt Create(RFs& aFs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC());
williamr@2
  1460
	IMPORT_C TInt Replace(RFs& aFs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC());
williamr@2
  1461
	IMPORT_C TInt Open(RFs& aFs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC(),TAccess aMode=EReadWrite);
williamr@2
  1462
	IMPORT_C TInt Open(RDbs& aDbs,const TDesC& aDatabase,const TDesC& aFormat=TPtrC());
williamr@2
  1463
	};
williamr@2
  1464
williamr@2
  1465
/**
williamr@2
  1466
@internalComponent
williamr@2
  1467
*/
williamr@2
  1468
const TInt KDbStoreMaxColumnLength=255;
williamr@2
  1469
williamr@2
  1470
/**
williamr@2
  1471
DBMS Store database implementation
williamr@2
  1472
@publishedAll
williamr@2
  1473
@released
williamr@2
  1474
*/
williamr@2
  1475
class RDbStoreDatabase : public RDbDatabase
williamr@2
  1476
	{
williamr@2
  1477
public:
williamr@2
  1478
	IMPORT_C TStreamId CreateL(CStreamStore* aStore);
williamr@2
  1479
	IMPORT_C void OpenL(CStreamStore* aStore,TStreamId anId);
williamr@2
  1480
	IMPORT_C static void CompressL(CStreamStore& aStore,TStreamId aId);
williamr@2
  1481
	IMPORT_C static void DecompressL(CStreamStore& aStore,TStreamId aId);
williamr@2
  1482
	};
williamr@2
  1483
williamr@2
  1484
#include <d32dbms.inl>
williamr@2
  1485
#endif