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

Function parseIndex

lib/KOReaderSync/ProgressMapper.cpp:16–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15namespace {
16int parseIndex(const std::string& xpath, const char* prefix, bool last = false) {
17 const size_t prefixLen = strlen(prefix);
18 const size_t pos = last ? xpath.rfind(prefix) : xpath.find(prefix);
19 if (pos == std::string::npos) return -1;
20 const size_t numStart = pos + prefixLen;
21 const size_t numEnd = xpath.find(']', numStart);
22 if (numEnd == std::string::npos || numEnd == numStart) return -1;
23 int val = 0;
24 for (size_t i = numStart; i < numEnd; i++) {
25 if (xpath[i] < '0' || xpath[i] > '9') return -1;
26 val = val * 10 + (xpath[i] - '0');
27 }
28 return val;
29}
30
31int parseCharOffset(const std::string& xpath) {
32 const size_t textPos = xpath.rfind("text()");

Callers 1

toCrossPointMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected