std::u16string DictionaryReader::decodeArticle(IBitStream &bstr, unsigned reference) { loadDecoder(); bstr.seek(header().articlesOffset + reference); std::u16string body; bool res = decoder()->DecodeArticle(&bstr, body); if (!res) throw std::runtime_error("can't decode article"); return body; }
std::vector<ArticleHeading> collectHeadingFromPage(IBitStream& bstr, DictionaryReader& reader, unsigned pageNumber) { std::vector<ArticleHeading> res; bstr.seek(reader.header().pagesOffset + 512 * pageNumber); CachePage page; page.loadHeader(bstr); if (page.isLeaf()) { std::u16string prefix; for (size_t idx = 0; idx < page.headingsCount(); ++idx) { ArticleHeading h; h.Load(*reader.decoder(), bstr, prefix); res.push_back(h); } } return res; }