本文整理汇总了C++中FileOffset::getWithOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ FileOffset::getWithOffset方法的具体用法?C++ FileOffset::getWithOffset怎么用?C++ FileOffset::getWithOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileOffset
的用法示例。
在下文中一共展示了FileOffset::getWithOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: commitInsertFromRange
bool EditedSource::commitInsertFromRange(SourceLocation OrigLoc,
FileOffset Offs,
FileOffset InsertFromRangeOffs, unsigned Len,
bool beforePreviousInsertions) {
if (Len == 0)
return true;
SmallString<128> StrVec;
FileOffset BeginOffs = InsertFromRangeOffs;
FileOffset EndOffs = BeginOffs.getWithOffset(Len);
FileEditsTy::iterator I = FileEdits.upper_bound(BeginOffs);
if (I != FileEdits.begin())
--I;
for (; I != FileEdits.end(); ++I) {
FileEdit &FA = I->second;
FileOffset B = I->first;
FileOffset E = B.getWithOffset(FA.RemoveLen);
if (BeginOffs == B)
break;
if (BeginOffs < E) {
if (BeginOffs > B) {
BeginOffs = E;
++I;
}
break;
}
}
for (; I != FileEdits.end() && EndOffs > I->first; ++I) {
FileEdit &FA = I->second;
FileOffset B = I->first;
FileOffset E = B.getWithOffset(FA.RemoveLen);
if (BeginOffs < B) {
bool Invalid = false;
StringRef text = getSourceText(BeginOffs, B, Invalid);
if (Invalid)
return false;
StrVec += text;
}
StrVec += FA.Text;
BeginOffs = E;
}
if (BeginOffs < EndOffs) {
bool Invalid = false;
StringRef text = getSourceText(BeginOffs, EndOffs, Invalid);
if (Invalid)
return false;
StrVec += text;
}
return commitInsert(OrigLoc, Offs, StrVec.str(), beforePreviousInsertions);
}
示例2:
EditedSource::FileEditsTy::iterator
EditedSource::getActionForOffset(FileOffset Offs) {
FileEditsTy::iterator I = FileEdits.upper_bound(Offs);
if (I == FileEdits.begin())
return FileEdits.end();
--I;
FileEdit &FA = I->second;
FileOffset B = I->first;
FileOffset E = B.getWithOffset(FA.RemoveLen);
if (Offs >= B && Offs < E)
return I;
return FileEdits.end();
}
示例3: commitRemove
void EditedSource::commitRemove(SourceLocation OrigLoc,
FileOffset BeginOffs, unsigned Len) {
if (Len == 0)
return;
FileOffset EndOffs = BeginOffs.getWithOffset(Len);
FileEditsTy::iterator I = FileEdits.upper_bound(BeginOffs);
if (I != FileEdits.begin())
--I;
for (; I != FileEdits.end(); ++I) {
FileEdit &FA = I->second;
FileOffset B = I->first;
FileOffset E = B.getWithOffset(FA.RemoveLen);
if (BeginOffs < E)
break;
}
FileOffset TopBegin, TopEnd;
FileEdit *TopFA = nullptr;
if (I == FileEdits.end()) {
FileEditsTy::iterator
NewI = FileEdits.insert(I, std::make_pair(BeginOffs, FileEdit()));
NewI->second.RemoveLen = Len;
return;
}
FileEdit &FA = I->second;
FileOffset B = I->first;
FileOffset E = B.getWithOffset(FA.RemoveLen);
if (BeginOffs < B) {
FileEditsTy::iterator
NewI = FileEdits.insert(I, std::make_pair(BeginOffs, FileEdit()));
TopBegin = BeginOffs;
TopEnd = EndOffs;
TopFA = &NewI->second;
TopFA->RemoveLen = Len;
} else {
TopBegin = B;
TopEnd = E;
TopFA = &I->second;
if (TopEnd >= EndOffs)
return;
unsigned diff = EndOffs.getOffset() - TopEnd.getOffset();
TopEnd = EndOffs;
TopFA->RemoveLen += diff;
if (B == BeginOffs)
TopFA->Text = StringRef();
++I;
}
while (I != FileEdits.end()) {
FileEdit &FA = I->second;
FileOffset B = I->first;
FileOffset E = B.getWithOffset(FA.RemoveLen);
if (B >= TopEnd)
break;
if (E <= TopEnd) {
FileEdits.erase(I++);
continue;
}
if (B < TopEnd) {
unsigned diff = E.getOffset() - TopEnd.getOffset();
TopEnd = E;
TopFA->RemoveLen += diff;
FileEdits.erase(I);
}
break;
}
}