annotate liszt.cpp @ 402:58b88ab69424
api-inversion
Move the struct adb definition from the auidioDB_API.h into the
audioDB-internals.h header file, leaving only the typedef behind.
Thus a user of the API sees only an incomplete type, which cannot be
instantiated (but /pointers/ to it can); there's then less temptation to
break the abstraction barrier by using structure fields in client code.
Not only that, but we can now safely put C++ stuff in the structure.
Take advantage of this by putting a std::set<std::string> in there, to
hold all the keys currently in the database; populate this field on
audiodb_open() (and delete it on audiodb_close). This will be useful
when we come to implement variants of audiodb_insert().
author |
mas01cr |
date |
Wed, 03 Dec 2008 17:40:15 +0000 |
parents |
4ded52b104e6 |
children |
e18843dc0aea |
rev |
line source |
mas01cr@386
|
1 #include "audioDB.h"
|
mas01cr@386
|
2
|
mas01cr@386
|
3 void audioDB::liszt(const char* dbName, unsigned offset, unsigned numLines, adb__lisztResponse* adbLisztResponse){
|
mas01cr@386
|
4 if(!dbH) {
|
mas01cr@386
|
5 initTables(dbName, 0);
|
mas01cr@386
|
6 }
|
mas01cr@386
|
7
|
mas01cr@386
|
8 assert(trackTable && fileTable);
|
mas01cr@386
|
9
|
mas01cr@386
|
10 if(offset>dbH->numFiles){
|
mas01cr@386
|
11 char tmpStr[MAXSTR];
|
mas01cr@386
|
12 sprintf(tmpStr, "numFiles=%u, lisztOffset=%u", dbH->numFiles, offset);
|
mas01cr@386
|
13 error("listKeys offset out of range", tmpStr);
|
mas01cr@386
|
14 }
|
mas01cr@386
|
15
|
mas01cr@386
|
16 if(!adbLisztResponse){
|
mas01cr@386
|
17 for(Uns32T k=0; k<numLines && offset+k<dbH->numFiles; k++){
|
mas01cr@386
|
18 fprintf(stdout, "[%d] %s (%d)\n", offset+k, fileTable+(offset+k)*O2_FILETABLE_ENTRY_SIZE, trackTable[offset+k]);
|
mas01cr@386
|
19 }
|
mas01cr@386
|
20 }
|
mas01cr@386
|
21 else{
|
mas01cr@386
|
22 adbLisztResponse->result.Rkey = new char*[numLines];
|
mas01cr@386
|
23 adbLisztResponse->result.Rlen = new unsigned int[numLines];
|
mas01cr@386
|
24 Uns32T k = 0;
|
mas01cr@386
|
25 for( ; k<numLines && offset+k<dbH->numFiles; k++){
|
mas01cr@386
|
26 adbLisztResponse->result.Rkey[k] = new char[MAXSTR];
|
mas01cr@386
|
27 snprintf(adbLisztResponse->result.Rkey[k], O2_MAXFILESTR, "%s", fileTable+(offset+k)*O2_FILETABLE_ENTRY_SIZE);
|
mas01cr@386
|
28 adbLisztResponse->result.Rlen[k] = trackTable[offset+k];
|
mas01cr@386
|
29 }
|
mas01cr@386
|
30 adbLisztResponse->result.__sizeRkey = k;
|
mas01cr@386
|
31 adbLisztResponse->result.__sizeRlen = k;
|
mas01cr@386
|
32 }
|
mas01cr@386
|
33
|
mas01cr@386
|
34 }
|