50 TextFileBuffer::Iterator::Iterator(
TextFileBuffer* pBuf,
size_t b,
size_t idx)
52 : pBuffer(pBuf), block(b), index(idx)
56 TextFileBuffer::Iterator::operator++()
ynothrow
58 YAssert(pBuffer,
"Null pointer found.");
59 YAssert(block < pBuffer->nBlock,
"End iterator found.");
61 auto& vec((*pBuffer)[block].
first);
63 YAssert(index < vec.size(),
"Invalid index found.");
66 yunseq(++block, index = 0);
71 TextFileBuffer::Iterator::operator--()
ynothrow
73 YAssert(pBuffer,
"Null buffer pointer found.");
74 YAssert(block != 0 || index != 0,
"Begin iterator found."),
75 YAssert(block < pBuffer->nBlock || *
this == pBuffer->GetEnd(),
76 "Invalid iterator found.");
80 index = (*pBuffer)[--block].first.size();
82 YAssert(index != 0,
"Invalid index found.");
85 YAssert(index < (*pBuffer)[block].
first.size(),
"Invalid index found.");
93 YAssert(pBuffer,
"Null pointer found.");
95 auto& vec((*pBuffer)[block].
first);
97 YAssert(!vec.empty(),
"Empty block found.");
98 YAssert(index < vec.size(),
"Invalid index found.");
104 operator==(
const TextFileBuffer::Iterator& x,
const TextFileBuffer::Iterator& y)
107 YAssert(x.pBuffer == y.pBuffer,
"Iterators to different buffer are not"
110 return x.block == y.block && x.index == y.index;
115 :
File(file), nTextSize(
File.GetTextSize()),
116 nBlock((nTextSize + BlockSize - 1) / BlockSize), Map(),
154 == ConversionResult::OK))
191 size_t n_byte(0), n_char(0);
199 == ConversionResult::OK))
224 const auto& vec((*
this)[idx].
first);
226 YAssert(!vec.empty() && bool(
File),
"Block loading failed.");
230 const auto mid(vec.cbegin() + pos);
232 YAssert(mid <= vec.cend(),
"Wrong iterator found.");
234 auto it(vec.begin());
236 YAssert(it <= mid,
"Wrong iterator found.");
246 == ConversionResult::OK))
260 const auto i_end(buf.GetEnd());
261 auto i_beg(buf.GetIterator(pos));
264 throw std::out_of_range(
"Wrong offset found.");
268 YAssert(pos < pos + len,
"Unexpected unsigned integer round up.");
272 str.reserve(len * 2);
273 while(len != 0 && i_beg != i_end)
275 str.push_back(*i_beg);
278 return std::move(str);