Mutable strings of characters.

Introduced properties

fun copy(start: Int, len: Int, dest: Buffer, new_start: Int)

core :: FlatBuffer :: copy

Copies the content of self in dest
init from(s: Text)

core :: FlatBuffer :: from

Create a new string copied from s.
init with_capacity(cap: Int)

core :: FlatBuffer :: with_capacity

Create a new empty string with a given capacity.

Redefined properties

redef type SELF: FlatBuffer

core $ FlatBuffer :: SELF

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

text_stat :: text_stat $ FlatBuffer :: []

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

core $ FlatBuffer :: []=

Modifies the char contained at pos index
redef fun add(c: Char)

core $ FlatBuffer :: add

Adds a char c at the end of self
redef fun append(s: Text)

core $ FlatBuffer :: append

Adds the content of text s at the end of self
redef fun append_substring_impl(s: Text, from: Int, length: Int)

core $ FlatBuffer :: append_substring_impl

Unsafe version of append_substring for performance
redef fun byte_length: Int

text_stat :: text_stat $ FlatBuffer :: byte_length

Number of bytes in self
redef fun bytepos: Int

text_stat :: text_stat $ FlatBuffer :: bytepos

Cached position (bytes) in the CString underlying the String
redef fun bytepos=(p: Int)

text_stat :: text_stat $ FlatBuffer :: bytepos=

Cached position (bytes) in the CString underlying the String
redef fun bytes: SequenceRead[Int]

core $ FlatBuffer :: bytes

Gets a view on the bytes of the Text object
redef fun char_to_byte_index(i: Int): Int

text_stat :: text_stat $ FlatBuffer :: char_to_byte_index

Index of the character index in _items
redef fun chars: SequenceRead[Char]

core $ FlatBuffer :: chars

Gets a view on the chars of the Text object
redef fun clear

core $ FlatBuffer :: clear

Clears the buffer
redef fun empty: SELFTYPE

core $ FlatBuffer :: empty

Returns an empty Text of the right type
redef fun enlarge(cap: Int)

core $ FlatBuffer :: enlarge

Enlarges the subsequent array containing the chars of self
redef fun fast_cstring: CString

core $ FlatBuffer :: fast_cstring

Returns a char* starting at position first_byte
redef init init

text_stat :: text_stat $ FlatBuffer :: init

redef init init

core $ FlatBuffer :: init

Create a new empty string.
redef fun insert(s: Text, pos: Int)

core $ FlatBuffer :: insert

Inserts s at position pos
redef fun insert_char(c: Char, pos: Int)

core $ FlatBuffer :: insert_char

Inserts c at position pos
redef fun length: Int

text_stat :: text_stat $ FlatBuffer :: length

Number of characters contained in self.
redef fun lower

core $ FlatBuffer :: lower

Changes each upper-case char in self by its lower-case variant
redef fun position: Int

text_stat :: text_stat $ FlatBuffer :: position

Cache of the latest position (char) explored in the string
redef fun position=(p: Int)

text_stat :: text_stat $ FlatBuffer :: position=

Cache of the latest position (char) explored in the string
redef fun recv(mpi: MPI, at: Int, count: Int, source: Rank, tag: Tag, comm: Comm)

mpi :: mpi $ FlatBuffer :: recv

Type specific receive from MPI
redef fun recv_fill(mpi: MPI, dest: Rank, tag: Tag, comm: Comm)

mpi :: mpi $ FlatBuffer :: recv_fill

Type specific receive and fill buffer from MPI
redef fun remove_at(p: Int, len: nullable Int)

core $ FlatBuffer :: remove_at

Removes a substring from self at position pos
redef fun reverse

core $ FlatBuffer :: reverse

Reverses itself in-place
redef fun substring(from: Int, count: Int): SELFTYPE

core $ FlatBuffer :: substring

Create a substring.
redef fun times(repeats: Int)

core $ FlatBuffer :: times

self is appended in such a way that self is repeated r times
redef fun to_cstring: CString

core $ FlatBuffer :: to_cstring

Return a null terminated char *
redef fun to_s: String

core $ FlatBuffer :: to_s

User readable representation of self.
redef fun upper

core $ FlatBuffer :: upper

Changes each lower-case char in self by its upper-case variant

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.
abstract fun []=(index: Int, item: Char)

core :: Buffer :: []=

Modifies the char contained at pos index
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
abstract fun add(c: Char)

core :: Buffer :: add

Adds a char c at the end of self
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
abstract fun append(s: Text)

core :: Buffer :: append

Adds the content of text s at the end of self
fun append_substring(s: Text, from: Int, length: Int)

core :: Buffer :: append_substring

Appends length chars from s starting at index from
fun append_substring_impl(s: Text, from: Int, length: Int)

core :: Buffer :: append_substring_impl

Unsafe version of append_substring for performance
fun append_to_bytes(b: Bytes)

core :: Text :: append_to_bytes

Appends self.bytes to b
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 :: FlatText :: byte_length=

fun bytepos: Int

core :: FlatText :: bytepos

Cached position (bytes) in the CString underlying the String
protected fun bytepos=(bytepos: Int)

core :: FlatText :: bytepos=

Cached position (bytes) in the CString underlying the String
abstract fun bytes: SequenceRead[Int]

core :: Text :: bytes

Gets a view on the bytes of the Text object
fun camel_case

core :: Buffer :: camel_case

Takes a snake case self and converts it to camel case
fun capitalize(keep_upper: nullable Bool, src: nullable Text)

core :: Buffer :: capitalize

Capitalizes each word in self
fun capitalized(keep_upper: nullable Bool): SELFTYPE

core :: Text :: capitalized

Returns a capitalized self
fun char_to_byte_index(index: Int): Int

core :: FlatText :: char_to_byte_index

Index of the character index in _items
abstract fun chars: SequenceRead[Char]

core :: Text :: chars

Gets a view on the chars of the Text object
fun chars_to_escape_to_c: Int

core :: FlatText :: chars_to_escape_to_c

By escaping self to C, how many more bytes will be needed ?
fun chars_to_html_escape: Int

core :: FlatText :: chars_to_html_escape

By escaping self to HTML, how many more bytes will be needed ?
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 clear

core :: Buffer :: clear

Clears the buffer
abstract fun clone: SELF

core :: Cloneable :: clone

Duplicate self
fun copy(start: Int, len: Int, dest: Buffer, new_start: Int)

core :: FlatBuffer :: copy

Copies the content of self in dest
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.
fun deserialize_json(static_type: nullable String): nullable Object

core :: Text :: deserialize_json

Deserialize a nullable Object from this JSON formatted string
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.
abstract fun enlarge(cap: Int)

core :: Buffer :: enlarge

Enlarges the subsequent array containing the chars of 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
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
abstract fun fast_cstring: CString

core :: FlatText :: fast_cstring

Returns a char* starting at position first_byte
fun fetch_char_at(index: Int): Char

core :: FlatText :: fetch_char_at

Gets a Char at index in self
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 first: Char

core :: Text :: first

Gets the first char of the Text
protected fun first_byte: Int

core :: FlatText :: first_byte

First byte of the CString
fun format(args: Object...): String

core :: Text :: format

Format self by replacing each %n with the nth item of args
init from(s: Text)

core :: FlatBuffer :: from

Create a new string copied from s.
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
init from_text(t: Text): Buffer

core :: Buffer :: from_text

Returns an instance of a subclass of Buffer with t as content
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.
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.
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
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(s: Text, pos: Int)

core :: Buffer :: insert

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

core :: Text :: insert_at

Insert s at pos.
abstract fun insert_char(c: Char, pos: Int)

core :: Buffer :: insert_char

Inserts c at position pos
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
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
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
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_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?
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_whitespace: Bool

core :: Text :: is_whitespace

Is the string non-empty but only made of whitespaces?
fun items: CString

core :: FlatText :: items

Underlying CString (char*)
protected fun items=(items: CString)

core :: FlatText :: items=

Underlying CString (char*)
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.
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
protected fun last_byte: Int

core :: FlatText :: last_byte

Last byte of the CString
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).
abstract fun length: Int

core :: Text :: length

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

core :: FlatText :: 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.
abstract fun lower

core :: Buffer :: lower

Changes each upper-case char in self by its lower-case variant
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 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
abstract init new: Buffer

core :: Buffer :: new

Returns an arbitrary subclass of Buffer with default parameters
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_json: nullable Serializable

core :: Text :: parse_json

Parse self as JSON.
fun position: Int

core :: FlatText :: position

Cache of the latest position (char) explored in the string
protected fun position=(position: Int)

core :: FlatText :: position=

Cache of the latest position (char) explored in the string
fun prefix(t: Text): nullable Match

core :: Text :: prefix

Extract a given prefix, if any.
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
fun realpath: String

core :: Text :: realpath

Return the canonicalized absolute pathname (see POSIX function realpath)
protected abstract fun recv(mpi: MPI, at: Int, count: Int, source: Rank, tag: Tag, comm: Comm)

mpi :: Receptacle :: recv

Type specific receive from MPI
protected abstract fun recv_fill(mpi: MPI, source: Rank, tag: Tag, comm: Comm)

mpi :: Receptacle :: recv_fill

Type specific receive and fill buffer from MPI
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
abstract fun remove_at(pos: Int, length: nullable Int)

core :: Buffer :: remove_at

Removes a substring from self at position pos
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 reverse

core :: Buffer :: reverse

Reverses itself in-place
abstract fun reversed: SELFTYPE

core :: Text :: reversed

Returns a reversed version of self
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
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
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 ..
fun snake_case

core :: Buffer :: snake_case

Takes a camel case self and converts it to snake case
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
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
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.
abstract fun times(r: Int)

core :: Buffer :: times

self is appended in such a way that self is repeated r times
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 '
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 underline: String

core :: Text :: underline

Make the text underlined in a ANSI/VT100 terminal.
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_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
abstract fun upper

core :: Buffer :: upper

Changes each lower-case char in self by its upper-case variant
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 init with_cap(i: Int): Buffer

core :: Buffer :: with_cap

Returns an instance of a subclass of Buffer with i base capacity
init with_capacity(cap: Int)

core :: FlatBuffer :: with_capacity

Create a new empty string with a given capacity.
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).
protected fun written: Bool

core :: Buffer :: written

Copy-On-Write flag
protected fun written=(written: Bool)

core :: Buffer :: written=

Copy-On-Write flag
fun yellow: String

core :: Text :: yellow

Make the text appear in yellow in a ANSI/VT100 terminal.
package_diagram core::FlatBuffer FlatBuffer core::FlatText FlatText core::FlatBuffer->core::FlatText core::Buffer Buffer core::FlatBuffer->core::Buffer mpi::Receptacle Receptacle core::FlatBuffer->mpi::Receptacle core::Text Text core::FlatText->core::Text core::Buffer->core::Text core::Object Object mpi::Receptacle->core::Object ...core::Text ... ...core::Text->core::Text ...core::Object ... ...core::Object->core::Object

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 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
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

abstract class Buffer

core :: Buffer

A mutable sequence of characters.
abstract class FlatText

core :: FlatText

All kinds of array-based text representations.
interface Receptacle

mpi :: Receptacle

Something which can receive data directly and efficiently from MPI

Class definitions

core $ FlatBuffer
# Mutable strings of characters.
class FlatBuffer
	super FlatText
	super Buffer

	redef fun chars do return new FlatBufferCharView(self)

	redef fun bytes do return new FlatBufferByteView(self)

	private var capacity = 0

	redef fun fast_cstring do return _items.fast_cstring(0)

	redef fun substrings do return new FlatSubstringsIter(self)

	# Re-copies the `CString` into a new one and sets it as the new `Buffer`
	#
	# This happens when an operation modifies the current `Buffer` and
	# the Copy-On-Write flag `written` is set at true.
	private fun reset do
		var nns = new CString(capacity)
		if _byte_length != 0 then _items.copy_to(nns, _byte_length, 0, 0)
		_items = nns
		written = false
	end

	# Shifts the content of the buffer by `len` bytes to the right, starting at byte `from`
	#
	# Internal only, does not modify _byte_length or length, this is the caller's responsability
	private fun rshift_bytes(from: Int, len: Int) do
		var oit = _items
		var nit = _items
		var bt = _byte_length
		if bt + len > capacity then
			capacity = capacity * 2 + 2
			nit = new CString(capacity)
			oit.copy_to(nit, 0, 0, from)
		end
		oit.copy_to(nit, bt - from, from, from + len)
	end

	# Shifts the content of the buffer by `len` bytes to the left, starting at `from`
	#
	# Internal only, does not modify _byte_length or length, this is the caller's responsability
	private fun lshift_bytes(from: Int, len: Int) do
		var it = _items
		it.copy_to(it, _byte_length - from, from, from - len)
	end

	redef fun []=(index, item)
	do
		assert index >= 0 and index <= _length
		if written then reset
		if index == _length then
			add item
			return
		end
		var it = _items
		var ip = it.char_to_byte_index(index)
		var c = it.char_at(ip)
		var clen = c.u8char_len
		var itemlen = item.u8char_len
		var size_diff = itemlen - clen
		if size_diff > 0 then
			rshift_bytes(ip + clen, size_diff)
		else if size_diff < 0 then
			lshift_bytes(ip + clen, -size_diff)
		end
		_byte_length += size_diff
		it.set_char_at(ip, item)
	end

	redef fun insert(s, pos) do
		assert pos >= 0 and pos <= length
		if pos == length then
			append s
			return
		end
		var slen = s.byte_length
		enlarge(byte_length + slen)
		var it = _items
		var shpos = it.char_to_byte_index(pos)
		rshift_bytes(shpos, slen)
		s.copy_to_native(it, slen, 0, shpos)
		length += s.length
		byte_length += slen
	end

	redef fun insert_char(c, pos) do
		assert pos >= 0 and pos <= length
		if pos == length then
			add c
			return
		end
		var clen = c.u8char_len
		enlarge(byte_length + clen)
		var it = _items
		var shpos = it.char_to_byte_index(pos)
		rshift_bytes(shpos, clen)
		it.set_char_at(shpos, c)
		length += 1
		byte_length += clen
	end

	redef fun add(c)
	do
		if written then reset
		var clen = c.u8char_len
		var bt = _byte_length
		enlarge(bt + clen)
		_items.set_char_at(bt, c)
		_byte_length += clen
		_length += 1
	end

	redef fun clear do
		_byte_length = 0
		_length = 0
		if written then
			_capacity = 16
			reset
		end
	end

	redef fun empty do return new Buffer

	redef fun enlarge(cap)
	do
		var c = capacity
		if cap <= c then return
		if c <= 16 then c = 16
		while c <= cap do c = c * 2
		# The COW flag can be set at false here, since
		# it does a copy of the current `Buffer`
		written = false
		var bln = _byte_length
		var a = new CString(c)
		if bln > 0 then
			var it = _items
			if bln > 0 then it.copy_to(a, bln, 0, 0)
		end
		_items = a
		capacity = c
	end

	redef fun to_s
	do
		written = true
		var bln = _byte_length
		if bln == 0 then _items = new CString(1)
		return new FlatString.full(_items, bln, 0, _length)
	end

	redef fun to_cstring
	do
		var bln = _byte_length
		var new_native = new CString(bln + 1)
		new_native[bln] = 0
		if _length > 0 then _items.copy_to(new_native, bln, 0, 0)
		return new_native
	end

	# Create a new empty string.
	init do end

	# Low-level creation a new buffer with given data.
	#
	# `_items` will be used as is, without copy, to store the characters of the buffer.
	# Aliasing issues is the responsibility of the caller.
	#
	# If `_items` is shared, `written` should be set to true after the creation
	# so that a modification will do a copy-on-write.
	private init with_infos(items: CString, capacity, byte_length, length: Int)
	do
		self._items = items
		self.capacity = capacity
		self._byte_length = byte_length
		self._length = length
	end

	# Create a new string copied from `s`.
	init from(s: Text)
	do
		_items = new CString(s.byte_length)
		for i in s.substrings do i._items.copy_to(_items, i._byte_length, first_byte, 0)
		_byte_length = s.byte_length
		_length = s.length
		_capacity = _byte_length
	end

	# Create a new empty string with a given capacity.
	init with_capacity(cap: Int)
	do
		assert cap >= 0
		_items = new CString(cap)
		capacity = cap
		_byte_length = 0
	end

	redef fun append(s)
	do
		if s.is_empty then return
		var sl = s.byte_length
		var nln = _byte_length + sl
		enlarge(nln)
		if s isa FlatText then
			s._items.copy_to(_items, sl, s.first_byte, _byte_length)
		else
			for i in s.substrings do append i
			return
		end
		_byte_length = nln
		_length += s.length
	end

	# Copies the content of self in `dest`
	fun copy(start: Int, len: Int, dest: Buffer, new_start: Int)
	do
		var self_chars = self.chars
		var dest_chars = dest.chars
		for i in [0..len-1] do
			dest_chars[new_start+i] = self_chars[start+i]
		end
	end

	redef fun substring(from, count)
	do
		assert count >= 0
		if from < 0 then from = 0
		if (from + count) > _length then count = _length - from
		if count <= 0 then return new Buffer
		var its = _items
		var bytefrom = its.char_to_byte_index(from)
		var byteto = its.char_to_byte_index(count + from - 1)
		byteto += its.char_at(byteto).u8char_len - 1
		var byte_length = byteto - bytefrom + 1
		var r_items = new CString(byte_length)
		its.copy_to(r_items, byte_length, bytefrom, 0)
		return new FlatBuffer.with_infos(r_items, byte_length, byte_length, count)
	end

	redef fun append_substring_impl(s, from, length) do
		if length <= 0 then return
		if not s isa FlatText then
			super
			return
		end
		var sits = s._items
		var bytest = s.char_to_byte_index(from)
		var bytend = s.char_to_byte_index(from + length - 1)
		var btln = bytend - bytest + sits.char_at(bytend).u8char_len
		enlarge(btln + _byte_length)
		sits.copy_to(_items, btln, bytest, _byte_length)
		_byte_length += btln
		_length += length
	end

	redef fun remove_at(p, len) do
		if len == null then len = 1
		if len == 0 then return
		var its = _items
		var bst = char_to_byte_index(p)
		var bend = char_to_byte_index(p + len - 1)
		bend += its.char_at(bend).u8char_len
		var blen = bend - bst
		lshift_bytes(bend, bend - bst)
		byte_length -= blen
		length -= len
	end

	redef fun reverse
	do
		written = false
		var ns = new FlatBuffer.with_capacity(capacity)
		for i in chars.reverse_iterator do ns.add i
		_items = ns._items
	end

	redef fun times(repeats)
	do
		var bln = _byte_length
		var x = new FlatString.full(_items, bln, 0, _length)
		for i in [1 .. repeats[ do
			append(x)
		end
	end

	redef fun upper
	do
		if written then reset
		for i in [0 .. _length[ do self[i] = self[i].to_upper
	end

	redef fun lower
	do
		if written then reset
		for i in [0 .. _length[ do self[i] = self[i].to_lower
	end
end
lib/core/text/flat.nit:865,1--1163,3

text_stat :: text_stat $ FlatBuffer
redef class FlatBuffer

	init do
		sys.flatbuf_allocations += 1
	end

	redef fun bytepos do
		sys.bytepos_call.inc "FlatBuffer"
		return super
	end

	redef fun bytepos=(p) do
		sys.bytepos_call.inc "FlatBuffer"
		super
	end

	redef fun position do
		sys.position_call.inc "FlatBuffer"
		return super
	end

	redef fun position=(p) do
		sys.position_call.inc "FlatBuffer"
		super
	end

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

	redef fun length do
		sys.length_calls.inc "FlatBuffer"
		return super
	end

	redef fun [](i) do
		sys.index_call.inc "FlatBuffer"
		return super
	end

	redef fun char_to_byte_index(i) do
		sys.index_call.inc "FlatBuffer"
		return super
	end
end
lib/text_stat/text_stat.nit:215,1--260,3

mpi :: mpi $ FlatBuffer
redef class FlatBuffer
	super Receptacle

	redef fun recv(mpi, at, count, source, tag, comm)
	do
		var min_capacity = at + count
		if capacity < min_capacity then enlarge min_capacity

		var array
		if at != 0 then
			array = items + at
		else array = items

		mpi.native_recv(array, count, new DataType.char,
			source, tag, new Comm.world, new Status.ignore)

		length = capacity
	end

	redef fun recv_fill(mpi, dest, tag, comm) do recv(mpi, 0, capacity, dest, tag, comm)
end
lib/mpi/mpi.nit:436,1--456,3