blob: 3727434fff518b20cca6cae04505f4ccc2f2da18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "index.h"
#include "istream/stream.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");
// 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;
}
}
}
|