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

Method getSpineIndexForTocIndex

lib/Epub/Epub.cpp:832–850  ·  view source on GitHub ↗

work out the section index for a toc index

Source from the content-addressed store, hash-verified

830
831// work out the section index for a toc index
832int Epub::getSpineIndexForTocIndex(const int tocIndex) const {
833 if (!bookMetadataCache || !bookMetadataCache->isLoaded()) {
834 LOG_ERR("EBP", "getSpineIndexForTocIndex called but cache not loaded");
835 return 0;
836 }
837
838 if (tocIndex < 0 || tocIndex >= bookMetadataCache->getTocCount()) {
839 LOG_ERR("EBP", "getSpineIndexForTocIndex: tocIndex %d out of range", tocIndex);
840 return 0;
841 }
842
843 const int spineIndex = bookMetadataCache->getTocEntry(tocIndex).spineIndex;
844 if (spineIndex < 0) {
845 LOG_DBG("EBP", "Section not found for TOC index %d", tocIndex);
846 return 0;
847 }
848
849 return spineIndex;
850}
851
852int Epub::getTocIndexForSpineIndex(const int spineIndex) const { return getSpineItem(spineIndex).tocIndex; }
853

Callers

nothing calls this directly

Calls 3

getTocCountMethod · 0.80
getTocEntryMethod · 0.80
isLoadedMethod · 0.45

Tested by

no test coverage detected