00001
00002
00003
00004
00005 #ifndef __BOOKDBENGINE_H__
00006 #define __BOOKDBENGINE_H__
00007
00008
00009 #include <e32std.h>
00010 #include <badesca.h>
00011 #include <d32dbms.h>
00012 #include <f32file.h>
00013
00014
00015
00016 class CFileStore;
00017
00018
00019 _LIT(KBooksTable, "Books");
00020 _LIT(KBooksAuthorCol, "Author");
00021 _LIT(KBooksTitleCol, "Title");
00022 _LIT(KBooksDescriptionCol, "Description");
00023 _LIT(KBooksDateCol,"PublishDate");
00024 _LIT(KBooksIndexName,"BooksIndex");
00025 const int KTitleMaxLength = 60;
00026 const int KDescriptionMaxLength = 128;
00027
00028
00033 const int KBookItemMaxLength = 256;
00034
00039 _LIT(KSeparator,"|");
00040
00041
00074 class CBookDb : public CBase
00075 {
00076 public:
00077
00083 static CBookDb* NewL();
00084
00090 ~CBookDb();
00091
00092
00093 public:
00094
00110 TInt OpenDb(const TFileName& aExistingBookFile);
00111
00130 TInt CreateDb(const TFileName& aNewBookFile);
00131
00145 TInt RemoveDb(const TFileName& aExistingBookFile);
00146
00157 TInt Close();
00158
00165 TBool IsOpen() const;
00166
00183 TInt AddBookWithSql(const TDesC& aAuthor,
00184 const TDesC& aTitle,
00185 const TDesC& aDescription);
00186
00203 TInt AddBookWithCppApiL(const TDesC& aAuthor,
00204 const TDesC& aTitle,
00205 const TDesC& aDescription);
00206
00217 CDesCArrayFlat* GetAllBooksL();
00218
00235 CDesCArrayFlat* GetBooksByKeyL(const TDesC& aColumnName,
00236 const TDesC& aSearchString);
00237
00252 TInt GetABookFast(const TDesC& aTitle, TDes& aResult);
00253
00267 TInt RemoveBooks(const TDesC& aTitle, TInt& aResultCount);
00268
00278 TInt RemoveAllBooks(TInt& aResultCount);
00279
00280
00293 TInt UpdateBookTitle(const TDesC& aOldTitleKey, const TDesC& aNewTitle);
00294
00295
00296
00307 CDesCArrayFlat* ColumnNamesAndSizesL();
00308
00316 TInt HasDateColumn(TBool& aReturnValue);
00317
00327 TInt AddDateColumn();
00328
00338 TInt RemoveDateColumn();
00339
00340 private:
00341
00348 void ConstructL();
00349
00355 CBookDb();
00356
00357 private:
00358
00359 void CreateBooksTableL();
00360 void CreateBooksIndexL();
00361 void DropBooksTable();
00362
00363 private:
00364
00365 RFs iFsSession;
00366 RDbStoreDatabase iBookDb;
00367 CFileStore* iFileStore;
00368 TBool iOpen;
00369 };
00370
00371 #endif // __BOOKDBENGINE_H__
00372
00373