diff options
author | Adrian Kummerlaender | 2017-10-06 14:37:53 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-10-06 14:43:00 +0200 |
commit | d951a22faf35aabe526de2588006c9381904b137 (patch) | |
tree | 3d02269647d0d8490f5d105c50c49295d688af72 /example.cc | |
parent | 538236772ce6edde390079c32533c1e70cf8bdca (diff) | |
download | DictzipQuery-d951a22faf35aabe526de2588006c9381904b137.tar DictzipQuery-d951a22faf35aabe526de2588006c9381904b137.tar.gz DictzipQuery-d951a22faf35aabe526de2588006c9381904b137.tar.bz2 DictzipQuery-d951a22faf35aabe526de2588006c9381904b137.tar.lz DictzipQuery-d951a22faf35aabe526de2588006c9381904b137.tar.xz DictzipQuery-d951a22faf35aabe526de2588006c9381904b137.tar.zst DictzipQuery-d951a22faf35aabe526de2588006c9381904b137.zip |
Provide definition reader primitive
Diffstat (limited to 'example.cc')
-rw-r--r-- | example.cc | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -4,19 +4,24 @@ #include <string> #include <iostream> -int main() { - dictzip::Istream stream("gcide.dict.dz"); +std::string get(const std::string& path, std::size_t offset, std::size_t length) { + dictzip::Istream stream(path.c_str()); + + std::string result; + result.resize(length); + + stream.seekg(offset); + stream.read(result.data(), length); + + return result; +} +int main() { // Decode location of _Accession_ + // `gcide.index[1089]: "Accession 8Aw Wt" const std::size_t offset = dictzip::base64_decode("8Aw"); const std::size_t length = dictzip::base64_decode("Wt"); // Print the GCIDE definition of _Accession_ - std::string data; - data.reserve(length); - - stream.seekg(offset); - stream.read(const_cast<char*>(data.data()), length); - - std::cout << data.c_str() << std::endl; + std::cout << get("gcide.dict.dz", offset, length) << std::endl; } |