Node that represents a concatenation between two String

Introduced properties

private var _byte_length: Int

core :: Concat :: _byte_length

private var _flat_cache: FlatString

core :: Concat :: _flat_cache

Cache for the latest accessed FlatString in self
private var _flat_last_pos_start: Int

core :: Concat :: _flat_last_pos_start

Position of the beginning of flat_cache in self
private var _left: String

core :: Concat :: _left

Left child of the node
private var _length: Int

core :: Concat :: _length

private var _right: String

core :: Concat :: _right

Right child of the node
private fun balance: String

core :: Concat :: balance

Returns a balanced version of self
protected fun byte_length=(byte_length: Int)

core :: Concat :: byte_length=

init defaultinit(left: String, right: String)

core :: Concat :: defaultinit

private fun flat_cache: FlatString

core :: Concat :: flat_cache

Cache for the latest accessed FlatString in self
private fun flat_cache=(flat_cache: FlatString)

core :: Concat :: flat_cache=

Cache for the latest accessed FlatString in self
private fun flat_last_pos_start: Int

core :: Concat :: flat_last_pos_start

Position of the beginning of flat_cache in self
private fun flat_last_pos_start=(flat_last_pos_start: Int)

core :: Concat :: flat_last_pos_start=

Position of the beginning of flat_cache in self
private fun get_leaf_at(pos: Int): FlatString

core :: Concat :: get_leaf_at

private fun left: String

core :: Concat :: left

Left child of the node
private fun left=(left: String)

core :: Concat :: left=

Left child of the node
protected fun length=(length: Int)

core :: Concat :: length=

private fun recurse_balance(nodes: Array[String], len: Int): String

core :: Concat :: recurse_balance

private fun right: String

core :: Concat :: right

Right child of the node
private fun right=(right: String)

core :: Concat :: right=

Right child of the node

Redefined properties

redef fun *(i: Int): SELFTYPE

core $ Concat :: *

Concatenates self i times
redef fun +(o: Text): SELFTYPE

core $ Concat :: +

Concatenates o to self
redef type SELF: Concat

core $ Concat :: SELF

Type of this instance, automatically specialized in every class
redef fun [](i: Int): Char

text_stat :: text_stat $ Concat :: []

Access a character at index in the string.
redef fun [](i: Int): Char

core $ Concat :: []

Access a character at index in the string.
redef fun byte_length: Int

core $ Concat :: byte_length

Number of bytes in self
redef fun byte_length: Int

text_stat :: text_stat $ Concat :: byte_length

Number of bytes in self
redef fun bytes: SequenceRead[Int]

core $ Concat :: bytes

Gets a view on the bytes of the Text object
redef fun chars: SequenceRead[Char]

core $ Concat :: chars

Gets a view on the chars of the Text object
redef fun copy_to_native(dest: CString, n: Int, src_offset: Int, dest_offset: Int)

core $ Concat :: copy_to_native

Copies n bytes from self at src_offset into dest starting at dest_offset
redef fun empty: SELFTYPE

core $ Concat :: empty

Returns an empty Text of the right type
redef init init

core $ Concat :: init

redef init init

text_stat :: text_stat $ Concat :: init

redef fun insert_at(s: String, pos: Int): SELFTYPE

core $ Concat :: insert_at

Insert s at pos.
redef fun internal_to_dot: String

ropes_debug :: ropes_debug $ Concat :: internal_to_dot

Writes self as a dot file on the hard drive
redef fun is_empty: Bool

core $ Concat :: is_empty

Is the current Text empty (== "")
redef fun iterator: Iterator[Char]

core $ Concat :: iterator

Gets an iterator on the chars of self
redef fun length: Int

core $ Concat :: length

Number of characters contained in self.
redef fun output

core $ Concat :: output

Display self on stdout (debug only).
redef fun reversed: SELFTYPE

core $ Concat :: reversed

Returns a reversed version of self
redef fun substring(from: Int, count: Int): SELFTYPE

core $ Concat :: substring

Create a substring.
redef fun substrings: Iterator[FlatText]

core $ Concat :: substrings

Iterates on the substrings of self if any
redef fun to_cstring: CString

core $ Concat :: to_cstring

Return a null terminated char *
redef fun to_lower: SELFTYPE

core $ Concat :: to_lower

A lower case version of self
redef fun to_upper: SELFTYPE

core $ Concat :: to_upper

A upper case version of self

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
abstract fun *(i: Int): SELFTYPE

core :: Text :: *

Concatenates self i times
abstract fun +(o: Text): SELFTYPE

core :: Text :: +

Concatenates o to self
fun /(path: Text): String

core :: Text :: /

Alias for join_path
abstract fun <(other: OTHER): Bool

core :: Comparable :: <

Is self lesser than other?
fun <=(other: OTHER): Bool

core :: Comparable :: <=

not other < self
fun <=>(other: OTHER): Int

core :: Comparable :: <=>

-1 if <, +1 if > and 0 otherwise
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
fun >(other: OTHER): Bool

core :: Comparable :: >

other < self
fun >=(other: OTHER): Bool

core :: Comparable :: >=

not self < other
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type OTHER: Comparable

core :: Comparable :: OTHER

What self can be compared to?
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
type SELFTYPE: Text

core :: Text :: SELFTYPE

Type of self (used for factorization of several methods, ex : substring_from, empty...)
fun [](index: Int): Char

core :: Text :: []

Access a character at index in the string.
private var _byte_length: Int

core :: Concat :: _byte_length

private var _flat_cache: FlatString

core :: Concat :: _flat_cache

Cache for the latest accessed FlatString in self
private var _flat_last_pos_start: Int

core :: Concat :: _flat_last_pos_start

Position of the beginning of flat_cache in self
private var _hash_cache: nullable Int

core :: Text :: _hash_cache

private var _left: String

core :: Concat :: _left

Left child of the node
private var _length: Int

core :: Concat :: _length

private var _right: String

core :: Concat :: _right

Right child of the node
fun a_to(base: Int): Int

core :: Text :: a_to

If self contains only digits and letters, return the corresponding integer in a given base
protected fun accept_json_serializer(v: JsonSerializer)

serialization :: Serializable :: accept_json_serializer

Refinable service to customize the serialization of this class to JSON
protected fun accept_msgpack_attribute_counter(v: AttributeCounter)

serialization :: Serializable :: accept_msgpack_attribute_counter

Hook to customize the behavior of the AttributeCounter
protected fun accept_msgpack_serializer(v: MsgPackSerializer)

serialization :: Serializable :: accept_msgpack_serializer

Hook to customize the serialization of this class to MessagePack
protected fun add_to_bundle(bundle: NativeBundle, key: JavaString)

serialization :: Serializable :: add_to_bundle

Called by []= to dynamically choose the appropriate method according
fun alert

core :: Text :: alert

Raise a JavaScript alert
fun append_to_bytes(b: Bytes)

core :: Text :: append_to_bytes

Appends self.bytes to b
private fun balance: String

core :: Concat :: balance

Returns a balanced version of self
fun basename(extension: nullable String): String

core :: Text :: basename

Extract the basename of a path and strip the extension
fun binarydigest_to_bytes: Bytes

core :: Text :: binarydigest_to_bytes

Return a Bytes by reading 0 and 1.
fun blue: String

core :: Text :: blue

Make the text appear in blue in a ANSI/VT100 terminal.
fun bold: String

core :: Text :: bold

Make the text appear in bold in a ANSI/VT100 terminal.
abstract fun byte_length: Int

core :: Text :: byte_length

Number of bytes in self
protected fun byte_length=(byte_length: Int)

core :: Concat :: byte_length=

abstract fun bytes: SequenceRead[Int]

core :: Text :: bytes

Gets a view on the bytes of the Text object
fun capitalized(keep_upper: nullable Bool): SELFTYPE

core :: Text :: capitalized

Returns a capitalized self
abstract fun chars: SequenceRead[Char]

core :: Text :: chars

Gets a view on the chars of the Text object
private fun chars_to_escape_csv(sep_char: Char, delim_char: Char, eol: String): Int

core :: Text :: chars_to_escape_csv

How many more bytes should be allocated for CSV escaping ?
private fun chars_to_unescape_csv(delim_char: Char): Int

core :: Text :: chars_to_unescape_csv

How many bytes should be removed for CSV unescaping ?
fun chdir: nullable Error

core :: Text :: chdir

Change the current working directory
fun check_base64: nullable Error

core :: Text :: check_base64

Is self a well-formed Base64 entity ?
fun chomp: SELFTYPE

core :: Text :: chomp

Returns self removed from its last line terminator (if any).
fun clamp(min: OTHER, max: OTHER): OTHER

core :: Comparable :: clamp

Constraint self within [min..max]
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
abstract fun clone: SELF

core :: Cloneable :: clone

Duplicate self
fun copy_to_native(dest: CString, n: Int, src_offset: Int, dest_offset: Int)

core :: Text :: copy_to_native

Copies n bytes from self at src_offset into dest starting at dest_offset
fun core_serialize_to(serializer: Serializer)

serialization :: Serializable :: core_serialize_to

Actual serialization of self to serializer
fun cyan: String

core :: Text :: cyan

Make the text appear in cyan in a ANSI/VT100 terminal.
fun decode_base64: Bytes

core :: Text :: decode_base64

Decodes the receiver string to base64 using a custom padding character.
init defaultinit(left: String, right: String)

core :: Concat :: defaultinit

fun deserialize_json(static_type: nullable String): nullable Object

core :: Text :: deserialize_json

Deserialize a nullable Object from this JSON formatted string
fun dgettext(domain: String): String

core :: String :: dgettext

Gettext dgettext, SEE gettext manual for further info
fun dirname: String

core :: Text :: dirname

Extract the dirname of a path
protected abstract fun empty: SELFTYPE

core :: Text :: empty

Returns an empty Text of the right type
fun encode_base64: String

core :: Text :: encode_base64

Encodes the receiver string to base64 using a custom padding character.
fun english_scoring: Float

core :: Text :: english_scoring

Score self according to english's letter frequency.
fun environ: String

core :: String :: environ

Return environment value for the symbol.
private fun escape(out: FlatBuffer, c: Char, pos: Int): Int

core :: Text :: escape

Read and escape the markdown contained in self.
fun escape_more_to_c(chars: String): String

core :: Text :: escape_more_to_c

Escape additionnal characters
fun escape_to_c: String

core :: Text :: escape_to_c

Escape " \ ', trigraphs and non printable characters using the rules of literal C strings and characters
private fun escape_to_csv(sep_char: Char, delim_char: Char, eol: String): String

core :: Text :: escape_to_csv

Escape the content of self for inclusion in a CSV document
fun escape_to_dot: String

core :: Text :: escape_to_dot

Escape string used in labels for graphviz
fun escape_to_js: Text

core :: Text :: escape_to_js

Escape the content of self to pass to JavaScript code
fun escape_to_mk: String

core :: Text :: escape_to_mk

Escape to include in a Makefile
fun escape_to_nit: String

core :: Text :: escape_to_nit

Escape to C plus braces
fun escape_to_sh: String

core :: Text :: escape_to_sh

Escape to POSIX Shell (sh).
fun escape_to_utf16: String

core :: Text :: escape_to_utf16

Returns self with all characters escaped with their UTF-16 representation
fun file_copy_to(dest: String)

core :: Text :: file_copy_to

Copy content of file at self to dest
fun file_delete: Bool

core :: Text :: file_delete

Remove a file, return true if success
fun file_exists: Bool

core :: Text :: file_exists

return true if a file with this names exists
fun file_extension: nullable String

core :: Text :: file_extension

Return right-most extension (without the dot)
fun file_lstat: nullable FileStat

core :: Text :: file_lstat

The status of a file or of a symlink. see POSIX lstat(2).
fun file_stat: nullable FileStat

core :: Text :: file_stat

The status of a file. see POSIX stat(2).
fun files: Array[String]

core :: Text :: files

Returns entries contained within the directory represented by self.
fun filter_nonprintable: String

core :: String :: filter_nonprintable

Use a special notation for whitespace characters that are not '\n' (LFD) or ' ' (space).
fun first: Char

core :: Text :: first

Gets the first char of the Text
private fun flat_cache: FlatString

core :: Concat :: flat_cache

Cache for the latest accessed FlatString in self
private fun flat_cache=(flat_cache: FlatString)

core :: Concat :: flat_cache=

Cache for the latest accessed FlatString in self
private fun flat_last_pos_start: Int

core :: Concat :: flat_last_pos_start

Position of the beginning of flat_cache in self
private fun flat_last_pos_start=(flat_last_pos_start: Int)

core :: Concat :: flat_last_pos_start=

Position of the beginning of flat_cache in self
fun format(args: Object...): String

core :: Text :: format

Format self by replacing each %n with the nth item of args
init from_deserializer(deserializer: Deserializer)

serialization :: Serializable :: from_deserializer

Create an instance of this class from the deserializer
fun from_percent_encoding: String

core :: Text :: from_percent_encoding

Decode self from percent (or URL) encoding to a clear string
fun from_utf16_digit(pos: nullable Int): Int

core :: Text :: from_utf16_digit

Returns a UTF-16 escape value
fun from_utf16_escape(pos: nullable Int, ln: nullable Int): Char

core :: Text :: from_utf16_escape

Returns the Unicode char escaped by self
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
private fun get_leaf_at(pos: Int): FlatString

core :: Concat :: get_leaf_at

private fun get_numext: Text

core :: Text :: get_numext

Gets the numeric extension (i/u 8/16/32) in self is present
private fun get_numhead: Text

core :: Text :: get_numhead

Gets the numeric head of self if present
fun get_translation(domain: String, dir: String): String

core :: String :: get_translation

Gets the translation of self via gettext from dir using domain
fun gettext: String

core :: String :: gettext

Gettext gettext, SEE gettext manual for further info
fun git_name: nullable String

core :: Text :: git_name

Get package name from the Git address self
fun gray: String

core :: Text :: gray

Make the text appear in dark gray (or black) in a ANSI/VT100 terminal.
fun green: String

core :: Text :: green

Make the text appear in green in a ANSI/VT100 terminal.
fun group_exists: Bool

core :: Text :: group_exists

Does the operating system know the group named self?
fun has(pattern: Pattern): Bool

core :: Text :: has

Does self contains at least one instance of pattern?
fun has_prefix(prefix: String): Bool

core :: Text :: has_prefix

Is this string prefixed by prefix?
fun has_substring(str: String, pos: Int): Bool

core :: Text :: has_substring

Does self have a substring str starting from position pos?
fun has_suffix(suffix: String): Bool

core :: Text :: has_suffix

Is this string suffixed by suffix?
fun hash: Int

core :: Object :: hash

The hash code of the object.
private fun hash_cache: nullable Int

core :: Text :: hash_cache

private fun hash_cache=(hash_cache: nullable Int)

core :: Text :: hash_cache=

fun hexdigest: String

core :: Text :: hexdigest

Gets the hexdigest of the bytes of self
fun hexdigest_to_bytes: Bytes

core :: Text :: hexdigest_to_bytes

Returns a new Bytes instance with the digest as content
fun html_escape: String

core :: Text :: html_escape

Escape the characters <, >, &, ", ' and / as HTML/XML entity references.
fun http_download(output_path: nullable Text, accept_status_code: nullable Int): nullable String

core :: Text :: http_download

Download the file at URL self to output_path with a simple HTTP request
fun http_get(accept_status_code: nullable Int): nullable String

core :: Text :: http_get

Execute a simple HTTP GET request to the URL self
private abstract fun http_get: HttpRequestResult

core :: Text :: http_get

Execute an HTTP GET request synchronously at the URI self
fun index_of(c: Char): Int

core :: Text :: index_of

Gets the index of the first occurence of 'c'
fun index_of_from(c: Char, pos: Int): Int

core :: Text :: index_of_from

Gets the index of the first occurence of ´c´ starting from ´pos´
init init

core :: Object :: init

abstract fun insert_at(s: String, pos: Int): SELFTYPE

core :: Text :: insert_at

Insert s at pos.
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
private abstract fun internal_to_dot: String

core :: Text :: internal_to_dot

Writes self as a dot file on the hard drive
fun is_base64: Bool

core :: Text :: is_base64

Is self a well-formed Base64 entity ?
fun is_between(c: OTHER, d: OTHER): Bool

core :: Comparable :: is_between

c <= self <= d
fun is_bi: Bool

core :: Text :: is_bi

Is self a well-formed BigInt (i.e. parsable via to_bi)
fun is_bin: Bool

core :: Text :: is_bin

Returns true if the string contains only Binary digits
private fun is_blank: Bool

core :: String :: is_blank

Is this string blank?
fun is_dec: Bool

core :: Text :: is_dec

Returns true if the string contains only Decimal digits
fun is_empty: Bool

core :: Text :: is_empty

Is the current Text empty (== "")
fun is_hex: Bool

core :: Text :: is_hex

Returns true if the string contains only Hex chars
private fun is_html_block: Bool

core :: Text :: is_html_block

Is self a HRML block element?
private fun is_html_unsafe: Bool

core :: Text :: is_html_unsafe

Is self an unsafe HTML element?
protected fun is_in(s: Text): Bool

core :: Pattern :: is_in

Is self in s?
fun is_int: Bool

core :: Text :: is_int

Is self a well-formed Integer (i.e. parsable via to_i)
fun is_lower: Bool

core :: Text :: is_lower

Are all letters in self lower-case ?
fun is_num: Bool

core :: Text :: is_num

Is self a valid integer ?
fun is_numeric: Bool

core :: Text :: is_numeric

Is this string in a valid numeric format compatible with to_f?
fun is_oct: Bool

core :: Text :: is_oct

Returns true if the string contains only Octal digits
fun is_package_name: Bool

core :: Text :: is_package_name

Does self look like a package name?
fun is_r: Bool

core :: Text :: is_r

Is self a well-formed Ratio (i.e. parsable via to_r)
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun is_sha1_digest: Bool

core :: Text :: is_sha1_digest

Is self a SHA-1 hexdigest?
private fun is_space_or_tab(index: Int): Bool

core :: String :: is_space_or_tab

Is the character at index a space or a tab
fun is_upper: Bool

core :: Text :: is_upper

Are all letters in self upper-case ?
fun is_valid_hexdigest: Bool

core :: Text :: is_valid_hexdigest

Is self a valid hexdigest ?
fun is_valid_macro_name: Bool

core :: String :: is_valid_macro_name

Is self a valid macro identifier?
fun is_whitespace: Bool

core :: Text :: is_whitespace

Is the string non-empty but only made of whitespaces?
fun iterator: Iterator[Char]

core :: Text :: iterator

Gets an iterator on the chars of self
fun join_path(path: Text): String

core :: Text :: join_path

Correctly join two path using the directory separator.
private fun json_need_escape: Bool

core :: Text :: json_need_escape

Does self need treatment from JSON to Nit ?
private fun json_to_nit_string: String

core :: Text :: json_to_nit_string

Escapes self from a JSON string to a Nit string
fun justify(length: Int, left: Float, char: nullable Char): String

core :: Text :: justify

Justify self in a space of length
fun l_trim: SELFTYPE

core :: Text :: l_trim

Removes the whitespaces at the beginning of self
fun last: Char

core :: Text :: last

Gets the last char of self
fun last_index_of(c: Char): Int

core :: Text :: last_index_of

Gets the last index of char ´c´
fun last_index_of_from(item: Char, pos: Int): Int

core :: Text :: last_index_of_from

The index of the last occurrence of an element starting from pos (in reverse order).
private fun left: String

core :: Concat :: left

Left child of the node
private fun left=(left: String)

core :: Concat :: left=

Left child of the node
abstract fun length: Int

core :: Text :: length

Number of characters contained in self.
protected fun length=(length: Int)

core :: Concat :: length=

fun levenshtein_distance(other: String): Int

core :: Text :: levenshtein_distance

Return the Levenshtein distance between two strings
fun light_gray: String

core :: Text :: light_gray

Make the text appear in light gray (or white) in a ANSI/VT100 terminal.
fun max(other: OTHER): OTHER

core :: Comparable :: max

The maximum between self and other (prefers self if equals).
fun md5: String

core :: Text :: md5

MD5 digest of self
fun md_to_html: Writable

core :: String :: md_to_html

Parse self as markdown and return the HTML representation
private fun meta_from_fence: nullable Text

core :: Text :: meta_from_fence

Extract string found at end of fence opening.
fun min(c: OTHER): OTHER

core :: Comparable :: min

The minimum between self and c (prefer self if equals)
fun mkdir(mode: nullable Int): nullable Error

core :: Text :: mkdir

Create a directory (and all intermediate directories if needed)
protected fun msgpack_extra_array_items: Int

serialization :: Serializable :: msgpack_extra_array_items

Hook to request a larger than usual metadata array
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
private fun normal: TermCharFormat

core :: Text :: normal

private fun normalize_reference: String

core :: String :: normalize_reference

Normalize link reference names
private fun nslog

core :: Text :: nslog

intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun open_in_browser

core :: Text :: open_in_browser

Open the URL self with the default browser
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun pack_l(ln: Int): Array[Text]

core :: Text :: pack_l

Packs the content of a string in packs of ln chars.
fun pack_r(ln: Int): Array[Text]

core :: Text :: pack_r

Packs the content of a string in packs of ln chars.
fun parse_bmfont(dir: String): MaybeError[BMFont, Error]

core :: Text :: parse_bmfont

Parse self as an XML BMFont description file
fun parse_import: Map[String, ExternalPackage]

core :: Text :: parse_import

Parse the external package declaration, as declared in package.ini
fun parse_json: nullable Serializable

core :: Text :: parse_json

Parse self as JSON.
fun prefix(t: Text): nullable Match

core :: Text :: prefix

Extract a given prefix, if any.
fun program_is_in_path: Bool

core :: String :: program_is_in_path

Search for the program self in all directories from PATH
fun purple: String

core :: Text :: purple

Make the text appear in magenta in a ANSI/VT100 terminal.
fun r_trim: SELFTYPE

core :: Text :: r_trim

Removes the whitespaces at the end of self
fun railfence(depth: Int): Text

core :: Text :: railfence

Returns a rail-fence cipher from self with depth rails
private fun read(out: FlatBuffer, nstart: Int, nend: Int): Int

core :: Text :: read

Read self between nstart and nend (excluded) and writte chars to out.
private fun read_raw_until(out: FlatBuffer, start: Int, nend: Char...): Int

core :: Text :: read_raw_until

Read self as raw text until nend and append it to the out buffer.
private fun read_until(out: FlatBuffer, start: Int, nend: Char...): Int

core :: Text :: read_until

Read self until nend and append it to the out buffer.
private fun read_until(out: FlatBuffer, start: Int, nend: Char...): Int

core :: Text :: read_until

Read self as raw text until nend and append it to the out buffer.
private fun read_until_char(from: Int, char: Char, buffer: Buffer): Int

core :: String :: read_until_char

Reads self until to is encountered and store result in buffer.
private fun read_until_pos(from: Int, to: Int, buffer: Buffer): Int

core :: String :: read_until_pos

Reads self from pos from to pos to and store result in buffer.
private fun read_xml(out: FlatBuffer, start: Int, safe_mode: Bool): Int

core :: Text :: read_xml

Read self as XML and append it to the out buffer.
private fun read_xml_until(out: FlatBuffer, from: Int, to: Char...): Int

core :: Text :: read_xml_until

Read self as XML until to and append it to the out buffer.
fun realpath: String

core :: Text :: realpath

Return the canonicalized absolute pathname (see POSIX function realpath)
private fun recurse_balance(nodes: Array[String], len: Int): String

core :: Concat :: recurse_balance

fun red: String

core :: Text :: red

Make the text appear in red in a ANSI/VT100 terminal.
fun relpath(dest: String): String

core :: Text :: relpath

Returns the relative path needed to go from self to dest.
fun remove_all(pattern: Pattern): String

core :: Text :: remove_all

Returns a copy of self minus all occurences of pattern
fun replace(pattern: Pattern, string: Text): String

core :: Text :: replace

Replace all occurrences of pattern with string
fun replace_first(pattern: Pattern, string: Text): String

core :: Text :: replace_first

Replace the first occurrence of pattern with string
abstract fun reversed: SELFTYPE

core :: Text :: reversed

Returns a reversed version of self
private fun right: String

core :: Concat :: right

Right child of the node
private fun right=(right: String)

core :: Concat :: right=

Right child of the node
fun rmdir: nullable Error

core :: Text :: rmdir

Delete a directory and all of its content, return true on success
fun rot(x: Int): Text

core :: Text :: rot

Performs a Rotation of x on each letter of self
fun run_js

core :: Text :: run_js

Run self as JavaScript code
private fun run_js_native(script: CString)

core :: Text :: run_js_native

fun search(pattern: Pattern): nullable Match

core :: Text :: search

Search the first occurence of pattern.
fun search_all(pattern: Pattern): Array[Match]

core :: Text :: search_all

Search all occurrences of pattern into self.
protected fun search_all_in(s: Text): Array[Match]

core :: Pattern :: search_all_in

Search all self occurrences into s.
fun search_from(pattern: Pattern, from: Int): nullable Match

core :: Text :: search_from

Search the first occurence of pattern after from.
protected abstract fun search_in(s: Text, from: Int): nullable Match

core :: Pattern :: search_in

Search self into s from a certain position.
protected abstract fun search_index_in(s: Text, from: Int): Int

core :: Pattern :: search_index_in

Search self into s from a certain position.
fun search_last(t: Text): nullable Match

core :: Text :: search_last

Search the last occurence of the text t.
fun search_last_up_to(t: Text, up_to: Int): nullable Match

core :: Text :: search_last_up_to

Search the last occurence of the text t before up_to.
protected abstract fun send(mpi: MPI, at: Int, count: Int, dest: Rank, tag: Tag, comm: Comm)

mpi :: Sendable :: send

Type specific send over MPI
protected abstract fun send_all(mpi: MPI, dest: Rank, tag: Tag, comm: Comm)

mpi :: Sendable :: send_all

Type specific send full buffer over MPI
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun serialize_msgpack(plain: nullable Bool): Bytes

serialization :: Serializable :: serialize_msgpack

Serialize self to MessagePack bytes
fun serialize_to(serializer: Serializer)

serialization :: Serializable :: serialize_to

Serialize self to serializer
fun serialize_to_json(plain: nullable Bool, pretty: nullable Bool): String

serialization :: Serializable :: serialize_to_json

Serialize self to JSON
private fun serialize_to_or_delay(v: Serializer)

serialization :: Serializable :: serialize_to_or_delay

Accept references or force direct serialization (using serialize_to)
fun setenv(v: String)

core :: String :: setenv

Set the enviroment value of a variable.
fun sha1: Bytes

core :: Text :: sha1

Computes the SHA1 of the receiver
fun sha1_hexdigest: String

core :: Text :: sha1_hexdigest

Computes the SHA1 of the receiver.
fun simplify_path: String

core :: Text :: simplify_path

Simplify a file path by remove useless ., removing //, and resolving ..
private fun skip_spaces(start: Int): Int

core :: Text :: skip_spaces

Get the position of the next non-space character.
fun split(pattern: Pattern): Array[String]

core :: Text :: split

Split self using pattern as separator.
protected fun split_in(s: Text): Array[Match]

core :: Pattern :: split_in

Split s using self is separator.
fun split_once_on(pattern: Pattern): Array[SELFTYPE]

core :: Text :: split_once_on

Split self on the first occurence of pattern
fun split_with(pattern: Pattern): Array[String]

core :: Text :: split_with

@deprecated alias for split
fun strip_extension(extension: nullable String): String

core :: Text :: strip_extension

Remove the trailing extension.
fun strip_nullable: Text

core :: Text :: strip_nullable

Strip the nullable prefix from the type name self
fun strip_nullable_and_params: Text

core :: Text :: strip_nullable_and_params

Strip the nullable prefix and the params from the type name self
private fun strip_numext: Text

core :: Text :: strip_numext

Removes the numeric extension if present
private fun strip_numhead: Text

core :: Text :: strip_numhead

Removes the numeric head of self if present
fun strip_start_slashes: String

core :: String :: strip_start_slashes

Returns a String copy of self without any of the prefixed '/'s
abstract fun substring(from: Int, count: Int): SELFTYPE

core :: Text :: substring

Create a substring.
fun substring_from(from: Int): SELFTYPE

core :: Text :: substring_from

Create a substring from self beginning at the from position
private abstract fun substrings: Iterator[FlatText]

core :: Text :: substrings

Iterates on the substrings of self if any
fun suffix(t: Text): nullable Match

core :: Text :: suffix

Extract a given suffix, if any.
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_a: Array[Char]

core :: Text :: to_a

Gets an Array containing the chars of self
fun to_bi: BigInt

core :: Text :: to_bi

If self contains a BigInt, return the corresponding BigInt
fun to_bin: Int

core :: Text :: to_bin

If self contains only '0' et '1', return the corresponding integer.
abstract fun to_buffer: Buffer

core :: Text :: to_buffer

Returns a copy of self as a Buffer
fun to_bytes: Bytes

core :: Text :: to_bytes

Returns a mutable copy of self's bytes
abstract fun to_camel_case: SELFTYPE

core :: Text :: to_camel_case

Takes a snake case self and converts it to camel case
fun to_cmangle: String

core :: Text :: to_cmangle

Mangle a string to be a unique string only made of alphanumeric characters and underscores.
fun to_cpp_string: CppString

core :: Text :: to_cpp_string

Get self as a CppString
abstract fun to_cstring: CString

core :: Text :: to_cstring

Return a null terminated char *
fun to_dec: Int

core :: Text :: to_dec

If self contains only digits '0' .. '9', return the corresponding integer.
fun to_dot: String

core :: Text :: to_dot

Returns the graphviz-formatted content of self
fun to_f: Float

core :: Text :: to_f

If self contains a float, return the corresponding float
fun to_hex(pos: nullable Int, ln: nullable Int): Int

core :: Text :: to_hex

If self contains only digits and alpha <= 'f', return the corresponding integer.
abstract fun to_i: Int

core :: Text :: to_i

Returns self as the corresponding integer
fun to_java_string: JavaString

core :: Text :: to_java_string

Get self as a JavaString
fun to_json: String

serialization :: Serializable :: to_json

Serialize self to plain JSON
fun to_json_value: JsonValue

core :: Text :: to_json_value

Parse self to a JsonValue
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

abstract fun to_lower: SELFTYPE

core :: Text :: to_lower

A lower case version of self
fun to_n: Numeric

core :: Text :: to_n

Get the numeric version of self
fun to_nsstring: NSString

core :: Text :: to_nsstring

Get a NSString from self
fun to_num: nullable Numeric

core :: Text :: to_num

If self is a properly formatted integer, returns the corresponding value
fun to_oct: Int

core :: Text :: to_oct

If self contains only digits <= '7', return the corresponding integer.
fun to_path: Path

core :: Text :: to_path

Access file system related services on the path at self
fun to_percent_encoding: String

core :: Text :: to_percent_encoding

Encode self to percent (or URL) encoding
fun to_pretty_json: String

serialization :: Serializable :: to_pretty_json

Serialize self to plain pretty JSON
fun to_program_name: String

core :: Text :: to_program_name

Convert the path (self) to a program name.
fun to_r: Ratio

core :: Text :: to_r

If self contains a Ratio, return the corresponding Ratio
fun to_re: Regex

core :: Text :: to_re

Get a Regex instance from self
fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun to_sexp: SExpEntity

core :: Text :: to_sexp

Tries to parse self as an S-Expression
abstract fun to_snake_case: SELFTYPE

core :: Text :: to_snake_case

Takes a camel case self and converts it to snake case
fun to_sql_date_string: String

core :: Text :: to_sql_date_string

Format the date represented by self into an escaped string for SQLite
fun to_sql_string: String

core :: Text :: to_sql_string

Return self between 's, escaping \ and '
fun to_symbol: Symbol

core :: String :: to_symbol

Get the unique corresponding to the string
fun to_u16string: U16String

core :: String :: to_u16string

Returns a UTF-16 encoded version of self
abstract fun to_upper: SELFTYPE

core :: Text :: to_upper

A upper case version of self
fun to_xml: XMLEntity

core :: Text :: to_xml

Tries to parse the current string to XML
fun trim: SELFTYPE

core :: Text :: trim

Trims trailing and preceding white spaces
fun trunc(max_length: Int, message: nullable String): String

core :: String :: trunc

If needed, truncate self at max_length characters and append an informative message.
fun u16_length: Int

core :: String :: u16_length

Returns the number of UTF-16 code units in self
fun underline: String

core :: Text :: underline

Make the text underlined in a ANSI/VT100 terminal.
private fun unescape_csv(delim_char: Char): String

core :: Text :: unescape_csv

Unescape the content of self from CSV format to Nit String
fun unescape_json: Text

core :: Text :: unescape_json

Removes JSON-escaping if necessary in a JSON string
fun unescape_nit: String

core :: Text :: unescape_nit

Return a string where Nit escape sequences are transformed.
fun unescape_string: String

core :: String :: unescape_string

Remove escape backslash from string
fun unescape_to_bytes: Bytes

core :: Text :: unescape_to_bytes

Return a Bytes instance where Nit escape sequences are transformed.
fun unrail(depth: Int): Text

core :: Text :: unrail

Transforms a rail-fence-encrypted Text to its original
fun user_exists: Bool

core :: Text :: user_exists

Does the operating system know the user named self?
fun uvigenere(key: String): String

core :: Text :: uvigenere

Vigenere decoder on ASCII letters.
fun vigenere(key: String): String

core :: Text :: vigenere

Vigenere encoder on ASCII letters.
abstract fun write_to(stream: Writer)

core :: Writable :: write_to

Write itself to a stream
fun write_to_bytes: Bytes

core :: Writable :: write_to_bytes

Like write_to but return a new Bytes (may be quite large)
fun write_to_file(filepath: String)

core :: Writable :: write_to_file

Like write_to but take care of creating the file
fun write_to_string: String

core :: Writable :: write_to_string

Like write_to but return a new String (may be quite large).
private fun xml_tag: String

core :: Text :: xml_tag

Extract the XML tag name from a XML tag.
fun yellow: String

core :: Text :: yellow

Make the text appear in yellow in a ANSI/VT100 terminal.
package_diagram core::ropes::Concat Concat core::ropes::Rope Rope core::ropes::Concat->core::ropes::Rope core::String String core::ropes::Concat->core::String core::Text Text core::ropes::Rope->core::Text core::String->core::Text sqlite3::Sqlite3Data Sqlite3Data core::String->sqlite3::Sqlite3Data nitc::JsonRef JsonRef core::String->nitc::JsonRef ...core::Text ... ...core::Text->core::Text ...sqlite3::Sqlite3Data ... ...sqlite3::Sqlite3Data->sqlite3::Sqlite3Data ...nitc::JsonRef ... ...nitc::JsonRef->nitc::JsonRef

Ancestors

interface Cloneable

core :: Cloneable

Something that can be cloned
interface Comparable

core :: Comparable

The ancestor of class where objects are in a total order.
interface DirectSerializable

serialization :: DirectSerializable

Instances of this class are not delayed and instead serialized immediately
interface JsonRef

nitc :: JsonRef

Something that goes in a JsonNamespace
interface Object

core :: Object

The root of the class hierarchy.
interface Pattern

core :: Pattern

Patterns are abstract string motifs (include String and Char).
interface Sendable

mpi :: Sendable

Something sendable directly and efficiently over MPI
interface Serializable

serialization :: Serializable

Instances of this class can be passed to Serializer::serialize
interface Sqlite3Data

sqlite3 :: Sqlite3Data

A data type supported by Sqlite3
abstract class Text

core :: Text

High-level abstraction for all text representations
interface Writable

core :: Writable

Things that can be efficienlty written to a Writer

Parents

private abstract class Rope

core :: Rope

String using a tree-based representation with leaves as FlatStrings
abstract class String

core :: String

Immutable sequence of characters.

Class definitions

core $ Concat
# Node that represents a concatenation between two `String`
private class Concat
	super Rope
	super String

	redef fun chars do return new RopeChars(self)

	redef fun bytes do return new RopeBytes(self)

	redef var length is noinit

	redef var byte_length is noinit

	redef fun substrings do return new RopeSubstrings.from(self, 0)

	redef fun empty do return ""

	# Cache for the latest accessed FlatString in `self`
	var flat_cache: FlatString is noinit

	# Position of the beginning of `flat_cache` in `self`
	var flat_last_pos_start: Int is noinit

	redef fun to_cstring do
		var len = _byte_length
		var ns = new CString(len + 1)
		ns[len] = 0
		var off = 0
		for i in substrings do
			var ilen = i._byte_length
			i.as(FlatString)._items.copy_to(ns, ilen, i.as(FlatString)._first_byte, off)
			off += ilen
		end
		return ns
	end

	# Left child of the node
	var left: String
	# Right child of the node
	var right: String

	init do
		var l = _left
		var r = _right
		_length = l.length + r.length
		_byte_length = l.byte_length + r.byte_length
		_flat_last_pos_start = _length
	end

	redef fun is_empty do return _byte_length == 0

	redef fun output do
		_left.output
		_right.output
	end

	redef fun iterator do return new RopeCharIterator.from(self, 0)

	redef fun *(i) do
		var x: String = self
		for j in [1 .. i[ do x += self
		return x
	end

	redef fun [](i) do
		assert i >= 0 and i < _length
		var flps = _flat_last_pos_start
		if i >= flps then
			var fc = _flat_cache
			if i < flps + fc._length then return fc.fetch_char_at(i - flps)
		end
		var lf = get_leaf_at(i)
		return lf.fetch_char_at(i - _flat_last_pos_start)
	end

	fun get_leaf_at(pos: Int): FlatString do
		var flps = _flat_last_pos_start
		if pos >= flps then
			var fc = _flat_cache
			if pos < flps + fc._length then return fc
		end
		var s: String = self
		var st = pos
		loop
			if s isa FlatString then break
			s = s.as(Concat)
			var lft = s._left
			var llen = lft.length
			if pos >= llen then
				s = s._right
				pos -= llen
			else
				s = lft
			end
		end
		_flat_last_pos_start = st - pos
		_flat_cache = s
		return s
	end

	redef fun substring(from, count) do
		if from < 0 then
			count += from
			if count < 0 then return ""
			from = 0
		end

		var ln = _length
		if (count + from) > ln then count = ln - from
		if count <= 0 then return ""
		var end_index = from + count - 1

		var flps = _flat_last_pos_start
		if from >= flps then
			var fc = _flat_cache
			if end_index < flps + fc._length then
				return fc.substring_impl(from - flps, count, end_index - flps)
			end
		end

		var lft = _left
		var llen = lft.length
		if from < llen then
			if from + count < llen then return lft.substring(from, count)
			var lsublen = llen - from
			return lft.substring_from(from) + _right.substring(0, count - lsublen)
		else
			return _right.substring(from - llen, count)
		end
	end

	redef fun reversed do return new Concat(_right.reversed, _left.reversed)

	redef fun insert_at(s, pos) do
		var lft = _left
		if pos > lft.length then
			return lft + _right.insert_at(s, pos - lft.length)
		end
		return lft.insert_at(s, pos) + _right
	end

	redef fun to_upper do return new Concat(_left.to_upper, _right.to_upper)

	redef fun to_lower do return new Concat(_left.to_lower, _right.to_lower)

	redef fun +(o) do
		var s = o.to_s
		var slen = s.byte_length
		if s isa Concat then
			return new Concat(self, s)
		else
			var r = _right
			var rlen = r.byte_length
			if rlen + slen > maxlen then return new Concat(self, s)
			return new Concat(_left, r + s)
		end
	end

	redef fun copy_to_native(dest, n, src_offset, dest_offset) do
		var l = _left
		if src_offset < l.byte_length then
			var lcopy = l.byte_length - src_offset
			lcopy = if lcopy > n then n else lcopy
			l.copy_to_native(dest, lcopy, src_offset, dest_offset)
			dest_offset += lcopy
			n -= lcopy
			src_offset = 0
		end
		_right.copy_to_native(dest, n, src_offset, dest_offset)
	end

	# Returns a balanced version of `self`
	fun balance: String do
		var children = new Array[String]
		var rnod: String
		var iter: nullable RopeCharIteratorPiece = new RopeCharIteratorPiece(self, false, false, null)
		loop
			if iter == null then break
			rnod = iter.node
			if not rnod isa Concat then
				children.push rnod
				iter = iter.prev
				continue
			end
			if not iter.ldone then
				iter.ldone = true
				iter = new RopeCharIteratorPiece(rnod._left, false, false, iter)
			else if not iter.rdone then
				iter.rdone = true
				iter = new RopeCharIteratorPiece(rnod._right, false, false, iter)
			else
				iter = iter.prev
			end

		end
		return recurse_balance(children, children.length)
	end

	fun recurse_balance(nodes: Array[String], len: Int): String do
		var finpos = 0
		var stpos = 0
		while stpos < len do
			if len - stpos > 1 then
				nodes[finpos] = new Concat(nodes[stpos], nodes[stpos + 1])
				stpos += 2
			else
				nodes[finpos] = nodes[stpos]
				stpos += 1
			end
			finpos += 1
		end
		if finpos == 1 then return nodes[0]
		return recurse_balance(nodes, finpos)
	end
end
lib/core/text/ropes.nit:68,1--282,3

text_stat :: text_stat $ Concat
redef class Concat
	init do
		sys.concat_allocations += 1
	end

	redef fun byte_length do
		sys.byte_length_call.inc "Concat"
		return super
	end

	redef fun [](i) do
		sys.index_call.inc "Concat"
		if flat_last_pos_start != -1 then
			var fsp = i - flat_last_pos_start
			if fsp >= 0 and fsp < flat_cache.length then return flat_cache[fsp]
		end
		sys.concat_cache_miss += 1
		var s: String = self
		var st = i
		loop
			if s isa FlatString then break
			s = s.as(Concat)
			var lft = s.left
			var llen = lft.length
			if i >= llen then
				s = s.right
				i -= llen
			else
				s = s.left
			end
		end
		flat_last_pos_start = st - i
		flat_cache = s
		return s[i]
	end
end
lib/text_stat/text_stat.nit:133,1--168,3