Mercurial > hg > audiodb
diff audioDB-internals.h @ 430:2d14d21f826b api-inversion
Make the keys std::set in adb_t a std::map instead.
The key's index can usefully be the value, and now suddenly we can
remove audioDB::getKeyPos and its oh-so-helpful "this should be an STL
map" comment.
author | mas01cr |
---|---|
date | Wed, 24 Dec 2008 10:55:36 +0000 |
parents | adaa6a688a04 |
children | 62a0515f59be |
line wrap: on
line diff
--- a/audioDB-internals.h Wed Dec 24 10:55:32 2008 +0000 +++ b/audioDB-internals.h Wed Dec 24 10:55:36 2008 +0000 @@ -12,7 +12,7 @@ int fd; int flags; adb_header_t *header; - std::set<std::string> *keys; + std::map<std::string,uint32_t> *keys; }; typedef struct { @@ -169,3 +169,13 @@ buffer++; } } + +static inline uint32_t audiodb_key_index(adb_t *adb, const char *key) { + std::map<std::string,uint32_t>::iterator it; + it = adb->keys->find(key); + if(it == adb->keys->end()) { + return (uint32_t) -1; + } else { + return (*it).second; + } +}