From c7a82e67007aecb46315780b53a691a519d90513 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 7 Oct 2017 16:57:15 +0200 Subject: Introduce ArchiveFile class --- example.cc | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'example.cc') diff --git a/example.cc b/example.cc index 3727434..3ce640c 100644 --- a/example.cc +++ b/example.cc @@ -1,31 +1,18 @@ #include "index.h" -#include "istream/stream.h" +#include "archive.h" #include #include -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[0], length); - - return result; -} - int main(int argc, char** argv) { if ( argc != 2 ) { std::cerr << "Empty query." << std::endl; } else { dictzip::IndexFile index("gcide.index"); + dictzip::ArchiveFile archive("gcide.dict.dz"); - // Get index entries of requested word definitions for ( auto& entry : index.get(argv[1]) ) { - // Print the GCIDE definition - std::cout << get("gcide.dict.dz", entry.offset, entry.length) << std::endl; + std::cout << archive.get(entry) << std::endl; } } } -- cgit v1.2.3