Mercurial > hg > audiodb
view 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 |
line wrap: on
line source
#include "audioDB.h" void audioDB::liszt(const char* dbName, unsigned offset, unsigned numLines, adb__lisztResponse* adbLisztResponse){ if(!dbH) { initTables(dbName, 0); } assert(trackTable && fileTable); if(offset>dbH->numFiles){ char tmpStr[MAXSTR]; sprintf(tmpStr, "numFiles=%u, lisztOffset=%u", dbH->numFiles, offset); error("listKeys offset out of range", tmpStr); } if(!adbLisztResponse){ for(Uns32T k=0; k<numLines && offset+k<dbH->numFiles; k++){ fprintf(stdout, "[%d] %s (%d)\n", offset+k, fileTable+(offset+k)*O2_FILETABLE_ENTRY_SIZE, trackTable[offset+k]); } } else{ adbLisztResponse->result.Rkey = new char*[numLines]; adbLisztResponse->result.Rlen = new unsigned int[numLines]; Uns32T k = 0; for( ; k<numLines && offset+k<dbH->numFiles; k++){ adbLisztResponse->result.Rkey[k] = new char[MAXSTR]; snprintf(adbLisztResponse->result.Rkey[k], O2_MAXFILESTR, "%s", fileTable+(offset+k)*O2_FILETABLE_ENTRY_SIZE); adbLisztResponse->result.Rlen[k] = trackTable[offset+k]; } adbLisztResponse->result.__sizeRkey = k; adbLisztResponse->result.__sizeRlen = k; } }