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