16#include <QRegularExpression>
59 for (
auto it = m_d->
m_mapping.lowerBound(offset),
60 it_end = m_d->
m_mapping.upperBound(offset+txt.size());
64 txt = txt.replace(it.key()-offset, it.value().size(), it.value());
82 :(std::get<0>((m_d->
m_shiftFrom.lowerBound(offset+indexOfToken-1)-1).value()))
85 auto correctedOffset = offset + correction;
87 auto correctedPosition = correctedOffset+indexOfToken;
90 return correctedPosition;
110 QRegularExpression rx(
"(&([^;]*);)");
113 qsizetype indexofent = 0;
114 QRegularExpressionMatch match;
115 while ((indexofent =
m_xml.indexOf(rx, indexofent, &match)) != -1)
119 int indexInResolved = indexofent-shift;
120 QString entity = match.captured(1);
121 QString entityString = match.captured(2);
124 shift += entity.size()-parsedEntity.size();
126 m_shiftFrom.insert(indexInResolved, {shift, entity, parsedEntity});
130 indexofent += match.capturedLength();
140 QRegularExpression rx(
"(&([^;]*);)");
143 qsizetype indexofent = 0;
144 QRegularExpressionMatch match;
145 while ((indexofent =
m_xml_noent.indexOf(rx, indexofent, &match)) != -1)
147 auto entity = match.captured(1);
148 auto entityString = match.captured(2);
151 QString(parsedEntity.size(),
'_'));
152 m_mapping.insert(indexofent, parsedEntity);
153 indexofent += parsedEntity.size();
166 os <<
"ShiftFrom shiftFrom: {" ;
169 os <<
"{" << k <<
":" <<
"{" << std::get<0>(sf.m_d->
m_shiftFrom[k])
QMap< int, QString > m_mapping
~ShiftFromPrivate()=default
ShiftFromPrivate(const QString &xml)
QMap< int, std::tuple< int, QString, QString > > m_shiftFrom
QString rebuild_text(const QString &input, int offset) const
Replace in input the sequences in mapping (shifted by offset)
int correct_offset(int offset, int indexOfToken) const
Return the correct absolute position of a token in its origin text when found at position indexOfToke...
const QString & xml_noent()
ShiftFrom(const QString &xml)
std::ostream & operator<<(ostream &os, const Node &node)
QString parseEntity(QStringView entity)