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

Function parseCharOffset

lib/KOReaderSync/ProgressMapper.cpp:31–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31int parseCharOffset(const std::string& xpath) {
32 const size_t textPos = xpath.rfind("text()");
33 const size_t dotPos = (textPos != std::string::npos) ? xpath.find('.', textPos) : xpath.rfind('.');
34 if (dotPos == std::string::npos || dotPos + 1 >= xpath.size()) return 0;
35 int val = 0;
36 for (size_t i = dotPos + 1; i < xpath.size(); i++) {
37 if (xpath[i] < '0' || xpath[i] > '9') return 0;
38 val = val * 10 + (xpath[i] - '0');
39 }
40 return val;
41}
42
43// Parse the N from text()[N] in the XPath (1-based; defaults to 1 if absent or 1).
44int parseTextNodeIndex(const std::string& xpath) {

Callers 1

toCrossPointMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected