diff options
| author | Adrian Kummerlaender | 2017-10-07 16:57:15 +0200 | 
|---|---|---|
| committer | Adrian Kummerlaender | 2017-10-07 16:57:15 +0200 | 
| commit | c7a82e67007aecb46315780b53a691a519d90513 (patch) | |
| tree | ccdeb8ae75a200ec41e34d79eba1ad9671f5a5da /example.cc | |
| parent | 51a422f161e7e7cc5b1093a12e004165754ec1b9 (diff) | |
| download | DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.gz DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.bz2 DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.lz DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.xz DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.zst DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.zip  | |
Introduce ArchiveFile class
Diffstat (limited to 'example.cc')
| -rw-r--r-- | example.cc | 19 | 
1 files changed, 3 insertions, 16 deletions
@@ -1,31 +1,18 @@  #include "index.h" -#include "istream/stream.h" +#include "archive.h"  #include <string>  #include <iostream> -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;  		}  	}  }  | 
