core :: RopeByteIterator :: defaultinit
# Forward iterator on the bytes of a `Rope`
private class RopeByteIterator
super IndexedIterator[Int]
# Position in current `String`
var pns: Int is noautoinit
# Current `String` being iterated on
var ns: CString is noautoinit
# Substrings of the Rope
var subs: IndexedIterator[FlatString] is noautoinit
# Maximum position to iterate on (e.g. Rope.byte_length)
var max: Int is noautoinit
# Position (char) in the Rope (0-indexed)
var pos: Int is noautoinit
init from(root: Concat, pos: Int) do
subs = new RopeSubstrings.from(root, pos)
pns = pos - subs.index
self.pos = pos
ns = subs.item._items
max = root.byte_length - 1
end
redef fun item do return ns[pns]
redef fun is_ok do return pos <= max
redef fun index do return pos
redef fun next do
pns += 1
pos += 1
if pns < subs.item._byte_length then return
if not subs.is_ok then return
subs.next
if not subs.is_ok then return
ns = subs.item._items
pns = 0
end
end
lib/core/text/ropes.nit:373,1--412,3