MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / generateXPath

Method generateXPath

lib/KOReaderSync/ProgressMapper.cpp:889–902  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

887}
888
889std::string ProgressMapper::generateXPath(const std::shared_ptr<Epub>& epub, int spineIndex, float intra) {
890 const std::string base = "/body/DocFragment[" + std::to_string(spineIndex + 1) + "]/body";
891 if (intra <= 0.0f) return base;
892
893 size_t spineSize = 0;
894 const auto href = epub->getSpineItem(spineIndex).href;
895 if (href.empty() || !epub->getItemSize(href, &spineSize) || spineSize == 0) return base;
896
897 ParagraphStreamer s(static_cast<size_t>(spineSize * std::min(intra, 1.0f)));
898 if (!streamSpine(epub, spineIndex, s)) return base;
899
900 const int p = s.paragraphCount();
901 return (p > 0) ? base + "/p[" + std::to_string(p) + "]" : base;
902}

Callers

nothing calls this directly

Calls 5

streamSpineFunction · 0.85
getSpineItemMethod · 0.80
getItemSizeMethod · 0.80
paragraphCountMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected