There is a great deal of general database functionality that can be put into
a "common" src file. These include open (encapsulating the find, etc.),
close, etc.
Here is an example of a common DBUtils.h that we have generated from several
projects:
DmOpenRef DBCreate(char *name, ULong creator, ULong type, Boolean
bDeleteOld, UInt openMode);
Boolean DBDelete(DmOpenRef dbRef, char *name, Boolean bUnlock);
Err DBSetBackupBit(char *name);
LocalID DBFind(char *name);
DmOpenRef DBOpen(char *name, UInt openMode);
Err DBClose(DmOpenRef dbRef);
VoidHand DBGetRecord(DmOpenRef dbRef, Int recIndex);
Boolean DBReleaseRecord(DmOpenRef dbRef, Int recIndex);
VoidHand DBGetNewRecord(DmOpenRef dbRef, Int *recIndexP, ULong size);
VoidHand DBAddRecord(DmOpenRef dbRef, VoidPtr srcP, ULong size, Int
*recIndexP);
Boolean DBDeleteRecord(DmOpenRef dbRef, Int recIndexP);
Boolean DBModifyRecord(DmOpenRef dbRef, Int recIndex, ULong
recOffset, VoidPtr srcPtr, ULong size);
Boolean DBSetRecord(DmOpenRef dbRef, Int recIndex, ULong recOffset, ULong
size, Byte value);
VoidPtr DBGetRecPtr(DmOpenRef dbRef, Int recIndex);
void DBReleaseRecPtr(DmOpenRef dbRef, VoidPtr recP, Int
recIndex);
UInt DBFindRecPtr(DmOpenRef dbRef, VoidPtr recP);
Boolean DBAddString(DmOpenRef dbRef, CharPtr string, UInt maxLen,
Int *recIndexP);
Boolean DBCopyString(VoidHand recH, ULong offset, CharPtr string,
UInt maxLen);
Boolean DBWriteString(DmOpenRef dbRef, UInt recIndex, CharPtr
string, UInt maxLen);
Boolean DBReadString(DmOpenRef dbRef, UInt recIndex, CharPtr string,
UInt maxLen);
UInt DBFindString(DmOpenRef dbRef, CharPtr string);
void DBUnlockAllRec(DmOpenRef dbRef);
UInt DBFindRecIndex(DmOpenRef dbRef, VoidHand recH);
Boolean DBIsRecordDeleted(DmOpenRef dbRef, UInt recIndex);
Boolean DBIsRecordBusy(DmOpenRef dbRef, UInt recIndex);
Boolean DBIsRecordPrivate(DmOpenRef dbRef, UInt recIndex);
Boolean DBDoesUniqueIDExist(DmOpenRef dbRef, ULong uniqueID, UInt
*recIndex);
UInt DBFindRecordByID(DmOpenRef dbRef, ULong uniqueID);
ULong DBGetRecUniqueID(DmOpenRef dbRef, UInt recIndex);
UInt DBNumRecords(DmOpenRef dbRef);
UInt DBNumNonDeletedRecords(DmOpenRef dbRef);
Of course, some of these are such thin wrappers around OS API that it may
seem not worth the
effort, but others are really nice savers of code.
It seems that one can come up with generic interfaces for a lot of common
functionality if one
adds enough parameters to the functions!!! (Not that this is necessarily a
good thing to do!!)
Kevin
__________________________
Kevin O'Keefe
The Windward Group
TEL: (408) 399-8577
FAX: (408) 395-9642
mailto:[EMAIL PROTECTED]
__________________________
> -----Original Message-----
> From: Ernst Steenbrink [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 13, 1999 6:02 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Creating lots of Databases
>
>
> Well, it appears that you have to write almost the same functions for
> each of the databases.
> >-----Original Message-----
> >From: Shaolin Hu [SMTP:[EMAIL PROTECTED]]
> >Sent: dinsdag 13 april 1999 14:23
> >To: '[EMAIL PROTECTED]'
> >Subject: RE: Creating lots of Databases
> >
> >Well, as I have seen in various examples, every database has
> its own set of
> >functions to write to the database, get the database, etc. I
> would like to
> >see that standardized in one set of functions. This however
> I have not seen
> >in any of the examples I have found. If I have to write all
> the function
> >seperately for each of the databases it will take much space.
> >
> >Ernst.
> >
> >I'm currently working on an application that has about 20 databases
> >the compiled code is about 95k, the prc is about 150k. I
> think it is still
> >pretty small, consider a simillar application in VB will be
> way over 1M.
> >What your definition of small?
> >
> >> -----Original Message-----
> >> From: Ernst Steenbrink [SMTP:[EMAIL PROTECTED]]
> >> Sent: Tuesday, April 13, 1999 6:33 AM
> >> To: 'Palm Developers Forum List
> [[EMAIL PROTECTED]] (E-mail)'
> >> Subject: Creating lots of Databases
> >>
> >> Hi All,
> >>
> >> I have a project where I will have to create +/- 20
> databases with an
> >> average of 8 fields each.
> >> The fields will have a length ranging from 5 to 50 characters.
> >> I have looked at the example given in the tutorial by O'reilly and
> >> noticed that there was a lot of code to support just three
> databases.
> >> I was wondering if there where any examples where they
> used a lot of
> >> databases and have managed to keep the code smaller.
> >> The application will be running on a palm III
> >>
> >> Ernst.
> >>
> >> >Ernst Steenbrink
> >> >Tinoway Nederland B.V.
> >> >Tel: +31 (0) 30 6005119
> >> >* [EMAIL PROTECTED]
> >> >
> >> >Fultonbaan 16
> >> >3439 NE Nieuwegein
> >> >The Netherlands
> >> >Tel: +31 (0) 30 6005111
> >> >Fax: +31 (0) 30 6005110
> >> >[EMAIL PROTECTED]
> >> >http://www.tinoway.com
> >>
> >>
> >>
> >
>