aboutsummaryrefslogtreecommitdiff
path: root/example.cc
blob: f2a091d8a4fd0840c768d7ccf444d6519ec3bb51 (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
#include "istream/stream.h"
#include "util/base64.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.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::cout << get("gcide.dict.dz", offset, length) << std::endl;
}