compiler/shared/l0/stdlib/std/text.l0

Module std.text

Overview Symbols grouped by source file: compiler/shared/l0/stdlib/std/text.l0

Module: std.text

Source: compiler/shared/l0/stdlib/std/text.l0 Language: Dea/L0

Imports / Includes

  • std.vector
  • std.assert
  • std.integer
  • std.string
  • sys.memory
  • sys.rt

Symbols

Function sb_create

func sb_create() -> StringBuffer*

Creates a new, empty StringBuffer .

Returns: A pointer to the newly created StringBuffer.

Function sb_append

func sb_append(self: StringBuffer*, s: string)

Appends a string to the StringBuffer .

Parameters:

  • self: The pointer to the StringBuffer.
  • s: The string to append.

Function sb_append_int

func sb_append_int(self: StringBuffer*, value: int)

Appends an integer to the StringBuffer .

Parameters:

  • self: The pointer to the StringBuffer.
  • value: The integer value to append.

Function sb_append_byte

func sb_append_byte(self: StringBuffer*, b: byte)

Appends a byte to the StringBuffer .

Parameters:

  • self: The pointer to the StringBuffer.
  • b: The byte value to append.

Function sb_to_string

func sb_to_string(self: StringBuffer*) -> string

Converts the accumulated contents of the StringBuffer into a single string.

Parameters:

Returns: The final concatenated string.

Function sb_size

func sb_size(self: StringBuffer*) -> int

Returns the current total size of all strings in the StringBuffer .

Parameters:

Returns: The total size in bytes.

Function sb_free

func sb_free(self: StringBuffer*)

Free a StringBuffer and its accumulated string parts.

Parameters:

  • self: String buffer to free.

Function cb_create

func cb_create() -> CharBuffer*

Creates a new, empty CharBuffer .

Returns: A pointer to the newly created CharBuffer.

Function cb_capacity

func cb_capacity(self: CharBuffer*) -> int

Returns the current capacity of the CharBuffer .

Parameters:

Returns: The total capacity.

Function cb_size

func cb_size(self: CharBuffer*) -> int

Returns the number of characters currently in the CharBuffer .

Parameters:

Returns: The character count.

Function cb_reserve

func cb_reserve(self: CharBuffer*, total_capacity: int)

Ensures the CharBuffer has at least the specified capacity.

Parameters:

  • self: The pointer to the CharBuffer.
  • total_capacity: The desired capacity.

Function cb_append

func cb_append(self: CharBuffer*, c: byte)

Appends a single character to the CharBuffer .

Parameters:

  • self: The pointer to the CharBuffer.
  • c: The character to append.

Function cb_append_s

func cb_append_s(self: CharBuffer*, s: string)

Appends a string to the CharBuffer .

Parameters:

  • self: The pointer to the CharBuffer.
  • s: The string to append.

Function cb_append_slice

func cb_append_slice(self: CharBuffer*, s: string, start: int, length: int)

Appends a slice of a string to the CharBuffer .

Parameters:

  • self: The pointer to the CharBuffer.
  • s: The string containing the slice.
  • start: The starting index of the slice.
  • length: The number of characters to append.

Function cb_append_int

func cb_append_int(self: CharBuffer*, value: int)

Appends an integer to the CharBuffer .

Parameters:

  • self: The pointer to the CharBuffer.
  • value: The integer value to append.

Function cb_reverse

func cb_reverse(cb: CharBuffer*)

Reverses the contents of the CharBuffer in place.

Parameters:

Function cb_to_string

func cb_to_string(self: CharBuffer*) -> string

Converts the accumulated characters in the CharBuffer into a string.

Parameters:

Returns: The final string.

Function cb_clear

func cb_clear(self: CharBuffer*)

Clears all characters from the CharBuffer without freeing memory.

Parameters:

Function cb_free

func cb_free(self: CharBuffer*)

Free a CharBuffer and its backing character storage.

Parameters:

  • self: Character buffer to free.

Function to_upper_s

func to_upper_s(s: string) -> string

Converts all characters in the input string to uppercase.

Parameters:

  • s: The string to convert.

Returns: The uppercase string.

Function to_lower_s

func to_lower_s(s: string) -> string

Converts all characters in the input string to lowercase.

Parameters:

  • s: The string to convert.

Returns: The lowercase string.

Function repeat_s

func repeat_s(s: string, count: int) -> string

Returns a new string that is the input string s repeated count times.

Parameters:

  • s: The string to repeat.
  • count: The number of repetitions.

Returns: The repeated string.

Function split_s

func split_s(s: string, sep: string) -> StringVector*

Splits a string into parts based on a separator string.

Parameters:

  • s: The string to split.
  • sep: The separator string.

Returns: A new StringVector containing the parts.

Function _line_strip_trailing_cr

func _line_strip_trailing_cr(s: string) -> string

Internal helper to strip a trailing CR from a line string.

Parameters:

  • s: The string.

Returns: The stripped string.

Function lines_s

func lines_s(s: string) -> StringVector*

Splits a string into lines, supporting both LF and CRLF.

Parameters:

  • s: The string to split into lines.

Returns: A new StringVector containing the lines.

Function join_s

func join_s(parts: StringVector*, sep: string) -> string

Joins parts of a string vector using a separator.

Parameters:

  • parts: The vector of string parts.
  • sep: The separator string.

Returns: The single joined string.

Function replace_s

func replace_s(s: string, old: string, replacement: string) -> string

Replaces all occurrences of an old substring with a new replacement string.

Parameters:

  • s: The source string.
  • old: The substring to replace.
  • replacement: The replacement substring.

Returns: The modified string.

Function int_to_string_base

func int_to_string_base(value: int, base: int) -> string

Converts an integer to a string representation in the specified base.

Parameters:

  • value: The integer value.
  • base: The numeric base (2-16).

Returns: The string representation.

Function reverse_s

func reverse_s(s: string) -> string

Reverses the characters in a string.

Parameters:

  • s: The string to reverse.

Returns: The reversed string.

Function int_to_string

func int_to_string(value: int) -> string

Converts an integer to its decimal string representation.

Parameters:

  • value: The integer value.

Returns: The decimal string.

Function int_to_hex_string

func int_to_hex_string(value: int) -> string

Converts an integer to its hexadecimal string representation.

Parameters:

  • value: The integer value.

Returns: The hex string.

Function int_to_bin_string

func int_to_bin_string(value: int) -> string

Converts an integer to its binary string representation.

Parameters:

  • value: The integer value.

Returns: The binary string.

Function bool_to_string

func bool_to_string(value: bool) -> string

Converts a boolean to its string representation ("true" or "false").

Parameters:

  • value: The boolean value.

Returns: The string representation.

Function string_to_bool

func string_to_bool(s: string) -> bool?

Parses a string representation of a boolean.

Parameters:

  • s: The string to parse.

Returns: The boolean value, or null if invalid.

Function byte_to_string

func byte_to_string(value: byte) -> string

Converts a byte to its decimal string representation.

Parameters:

  • value: The byte value.

Returns: The decimal string.

Function byte_to_string_base

func byte_to_string_base(value: byte, base: int) -> string

Converts a byte to its string representation in the specified base.

Parameters:

  • value: The byte value.
  • base: The numeric base (2-16).

Returns: The string representation.

Function string_to_int

func string_to_int(s: string) -> int?

Converts a decimal numeric string to an integer.

Returns null when parsing fails or overflows 32-bit signed range.

Parameters:

  • s: The string to parse.

Returns: The integer value, or null.

Function string_to_byte

func string_to_byte(s: string) -> byte?

Converts a decimal numeric string to a byte.

Parameters:

  • s: The string to parse.

Returns: The byte value, or null if invalid or out of range (0-255).

Function string_to_byte_base

func string_to_byte_base(s: string, base: int) -> byte?

Converts a numeric string in the specified base to a byte.

Parameters:

  • s: The string to parse.
  • base: The numeric base (2-16).

Returns: The byte value, or null if invalid or out of range.

Function string_to_int_base

func string_to_int_base(s: string, base: int) -> int?

Converts a numeric string 's' expressed in base 'base' to an integer.

Handles optional leading '-' for negative numbers and ignores leading zeros. No special prefixes like "0x" for hex or "0b" for binary are expected or allowed. Checks for overflow and invalid characters. Returns null if the string is not a valid 32-bit signed integer.

Parameters:

  • s: The string to parse.
  • base: The numeric base (2-16).

Returns: The integer value, or null.

Struct StringBuffer

StringBuffer allows for efficient construction of strings by accumulating parts in a vector.

StringBuffer Field parts

parts: StringVector*

StringBuffer Field size

size: int

Struct CharBuffer

CharBuffer allows for efficient building of strings by accumulating individual characters.

CharBuffer Field chars

chars: VectorBase*