+ # Concatenates `o` to `self`
+ #
+ # assert "hello" + "world" == "helloworld"
+ # assert "" + "hello" + "" == "hello"
+ fun +(o: Text): SELFTYPE is abstract
+
+ # Concatenates self `i` times
+ #
+ # assert "abc" * 4 == "abcabcabcabc"
+ # assert "abc" * 1 == "abc"
+ # assert "abc" * 0 == ""
+ fun *(i: Int): SELFTYPE is abstract
+
+ fun insert_at(s: String, pos: Int): SELFTYPE is abstract
+
+ redef fun substrings: Iterator[String] is abstract
+
+ # Returns a reversed version of self
+ #
+ # assert "hello".reversed == "olleh"
+ # assert "bob".reversed == "bob"
+ # assert "".reversed == ""
+ fun reversed: SELFTYPE is abstract
+
+ # A upper case version of `self`
+ #
+ # assert "Hello World!".to_upper == "HELLO WORLD!"
+ fun to_upper: SELFTYPE is abstract
+
+ # A lower case version of `self`
+ #
+ # assert "Hello World!".to_lower == "hello world!"
+ fun to_lower : SELFTYPE is abstract
+
+ # Takes a camel case `self` and converts it to snake case
+ #
+ # assert "randomMethodId".to_snake_case == "random_method_id"
+ #
+ # If `self` is upper, it is returned unchanged
+ #
+ # assert "RANDOM_METHOD_ID".to_snake_case == "RANDOM_METHOD_ID"
+ #
+ # If the identifier is prefixed by an underscore, the underscore is ignored
+ #
+ # assert "_privateField".to_snake_case == "_private_field"
+ fun to_snake_case: SELFTYPE
+ do
+ if self.is_upper then return self
+
+ var new_str = new FlatBuffer.with_capacity(self.length)
+ var is_first_char = true
+
+ for i in [0..length[ do
+ var char = chars[i]
+ if is_first_char then
+ new_str.add(char.to_lower)
+ is_first_char = false
+ else if char.is_upper then
+ new_str.add('_')
+ new_str.add(char.to_lower)
+ else
+ new_str.add(char)
+ end
+ end
+
+ return new_str.to_s
+ end
+
+ # Takes a snake case `self` and converts it to camel case
+ #
+ # assert "random_method_id".to_camel_case == "randomMethodId"
+ #
+ # If the identifier is prefixed by an underscore, the underscore is ignored
+ #
+ # assert "_private_field".to_camel_case == "_privateField"
+ #
+ # If `self` is upper, it is returned unchanged
+ #
+ # assert "RANDOM_ID".to_camel_case == "RANDOM_ID"
+ #
+ # If there are several consecutive underscores, they are considered as a single one
+ #
+ # assert "random__method_id".to_camel_case == "randomMethodId"
+ fun to_camel_case: SELFTYPE
+ do
+ if self.is_upper then return self
+
+ var new_str = new FlatBuffer
+ var is_first_char = true
+ var follows_us = false
+
+ for i in [0..length[ do
+ var char = chars[i]
+ if is_first_char then
+ new_str.add(char)
+ is_first_char = false
+ else if char == '_' then
+ follows_us = true
+ else if follows_us then
+ new_str.add(char.to_upper)
+ follows_us = false
+ else
+ new_str.add(char)
+ end
+ end
+
+ return new_str.to_s
+ end
+
+ # Returns a capitalized `self`
+ #
+ # Letters that follow a letter are lowercased
+ # Letters that follow a non-letter are upcased.
+ #
+ # SEE : `Char::is_letter` for the definition of letter.
+ #
+ # assert "jAVASCRIPT".capitalized == "Javascript"
+ # assert "i am root".capitalized == "I Am Root"
+ # assert "ab_c -ab0c ab\nc".capitalized == "Ab_C -Ab0C Ab\nC"
+ fun capitalized: SELFTYPE do
+ if length == 0 then return self
+
+ var buf = new FlatBuffer.with_capacity(length)
+
+ var curr = chars[0].to_upper
+ var prev = curr
+ buf[0] = curr
+
+ for i in [1 .. length[ do
+ prev = curr
+ curr = self[i]
+ if prev.is_letter then
+ buf[i] = curr.to_lower
+ else
+ buf[i] = curr.to_upper
+ end
+ end
+
+ return buf.to_s
+ end
+end
+
+private class FlatSubstringsIter
+ super Iterator[FlatText]
+
+ var tgt: nullable FlatText
+
+ redef fun item do
+ assert is_ok
+ return tgt.as(not null)
+ end
+
+ redef fun is_ok do return tgt != null
+
+ redef fun next do tgt = null