redef type OTHER: Text
- # Type of the view on self (.chars)
- type SELFVIEW: StringCharView
-
# Type of self (used for factorization of several methods, ex : substring_from, empty...)
type SELFTYPE: Text
# Gets a view on the chars of the Text object
#
# assert "hello".chars.to_a == ['h', 'e', 'l', 'l', 'o']
- fun chars: SELFVIEW is abstract
+ fun chars: SequenceRead[Char] is abstract
# Number of characters contained in self.
#
# Abstract class for the SequenceRead compatible
# views on String and Buffer objects
-abstract class StringCharView
+private abstract class StringCharView
super SequenceRead[Char]
type SELFTYPE: Text
# View on Buffer objects, extends Sequence
# for mutation operations
-abstract class BufferCharView
+private abstract class BufferCharView
super StringCharView
super Sequence[Char]
# Indes in _items of the last item of the string
private var index_to: Int
- redef var chars: SELFVIEW = new FlatStringCharView(self)
+ redef var chars: SequenceRead[Char] = new FlatStringCharView(self)
################################################
# AbstractString specific methods #
abstract class Buffer
super Text
- redef type SELFVIEW: BufferCharView
redef type SELFTYPE: Buffer
# Specific implementations MUST set this to `true` in order to invalidate caches
return super
end
+ # In Buffers, the internal sequence of character is mutable
+ # Thus, `chars` can be used to modify the buffer.
+ redef fun chars: Sequence[Char] is abstract
end
# Mutable strings of characters.
redef type SELFTYPE: FlatBuffer
- redef var chars: SELFVIEW = new FlatBufferCharView(self)
+ redef var chars: Sequence[Char] = new FlatBufferCharView(self)
private var capacity: Int