ffmt_strings Module

String helpers.


Used by

  • module~~ffmt_strings~~UsedByGraph module~ffmt_strings ffmt_strings module~ffmt_cli ffmt_cli module~ffmt_cli->module~ffmt_strings module~ffmt_config ffmt_config module~ffmt_cli->module~ffmt_config module~ffmt_diff ffmt_diff module~ffmt_cli->module~ffmt_diff module~ffmt_format ffmt_format module~ffmt_cli->module~ffmt_format module~ffmt_settings ffmt_settings module~ffmt_cli->module~ffmt_settings module~ffmt_walk ffmt_walk module~ffmt_cli->module~ffmt_walk module~ffmt_config->module~ffmt_strings module~ffmt_config->module~ffmt_settings module~ffmt_constructs ffmt_constructs module~ffmt_constructs->module~ffmt_strings module~ffmt_statements ffmt_statements module~ffmt_constructs->module~ffmt_statements module~ffmt_tokens ffmt_tokens module~ffmt_constructs->module~ffmt_tokens module~ffmt_diff->module~ffmt_strings module~ffmt_format->module~ffmt_strings module~ffmt_layout ffmt_layout module~ffmt_format->module~ffmt_layout module~ffmt_lexer ffmt_lexer module~ffmt_format->module~ffmt_lexer module~ffmt_linebreak ffmt_linebreak module~ffmt_format->module~ffmt_linebreak module~ffmt_relational ffmt_relational module~ffmt_format->module~ffmt_relational module~ffmt_format->module~ffmt_statements module~ffmt_structure ffmt_structure module~ffmt_format->module~ffmt_structure module~ffmt_format->module~ffmt_tokens module~ffmt_use_sort ffmt_use_sort module~ffmt_format->module~ffmt_use_sort module~ffmt_whitespace ffmt_whitespace module~ffmt_format->module~ffmt_whitespace module~ffmt_case ffmt_case module~ffmt_format->module~ffmt_case module~ffmt_source ffmt_source module~ffmt_format->module~ffmt_source module~ffmt_layout->module~ffmt_strings module~ffmt_layout->module~ffmt_statements module~ffmt_layout->module~ffmt_structure module~ffmt_layout->module~ffmt_tokens module~ffmt_layout->module~ffmt_whitespace module~ffmt_layout->module~ffmt_case module~ffmt_layout->module~ffmt_source module~ffmt_lexer->module~ffmt_strings module~ffmt_lexer->module~ffmt_tokens module~ffmt_linebreak->module~ffmt_strings module~ffmt_linebreak->module~ffmt_statements module~ffmt_linebreak->module~ffmt_tokens module~ffmt_linebreak->module~ffmt_source module~ffmt_relational->module~ffmt_strings module~ffmt_relational->module~ffmt_statements module~ffmt_relational->module~ffmt_tokens module~ffmt_relational->module~ffmt_source module~ffmt_settings->module~ffmt_strings module~ffmt_statements->module~ffmt_strings module~ffmt_statements->module~ffmt_tokens module~ffmt_structure->module~ffmt_strings module~ffmt_structure->module~ffmt_constructs module~ffmt_structure->module~ffmt_statements module~ffmt_structure->module~ffmt_tokens module~ffmt_structure->module~ffmt_source module~ffmt_tokens->module~ffmt_strings module~ffmt_use_sort->module~ffmt_strings module~ffmt_use_sort->module~ffmt_statements module~ffmt_use_sort->module~ffmt_tokens module~ffmt_use_sort->module~ffmt_source module~ffmt_walk->module~ffmt_strings module~ffmt_whitespace->module~ffmt_strings module~ffmt_whitespace->module~ffmt_statements module~ffmt_whitespace->module~ffmt_tokens module~ffmt_whitespace->module~ffmt_source proc~read_stdin read_stdin proc~read_stdin->module~ffmt_strings module~ffmt_case->module~ffmt_statements module~ffmt_case->module~ffmt_tokens module~ffmt_case->module~ffmt_source module~ffmt_directives ffmt_directives module~ffmt_directives->module~ffmt_statements module~ffmt_directives->module~ffmt_tokens module~ffmt_source->module~ffmt_lexer module~ffmt_source->module~ffmt_statements module~ffmt_source->module~ffmt_tokens module~ffmt_source->module~ffmt_directives

Derived Types

type, public ::  string_builder_t

Builds a string by appending pieces in amortized constant time.

Components

Type Visibility Attributes Name Initial
character(len=:), private, allocatable :: buf

storage; only buf(1:n) is in use

integer, private :: n = 0

length of the string so far

Type-Bound Procedures

procedure, public :: append => builder_append
procedure, public :: get => builder_get
procedure, public :: length => builder_length

type, public ::  string_t

A variable-length string, for arrays of strings of different lengths.

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: s

the string


Functions

private pure function builder_get(self) result(str)

The string built so far.

Arguments

Type IntentOptional Attributes Name
class(string_builder_t), intent(in) :: self

the builder

Return Value character(len=:), allocatable

private pure function builder_length(self) result(n)

Length of the string built so far.

Arguments

Type IntentOptional Attributes Name
class(string_builder_t), intent(in) :: self

the builder

Return Value integer

private pure function int_width(i)

Number of characters of i as text, with any sign.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i

the number

Return Value integer

public elemental function lower_char(c)

c in lowercase (ASCII letters only; other bytes, including UTF-8, are unchanged).

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(in) :: c

the character

Return Value character(len=1)

public pure function lowercase(s) result(l)

s in lowercase (see lower_char).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: s

the text

Return Value character(len=len)

public pure function to_s(i) result(s)

Integer to string, without padding. Digits are built by hand: an internal write costs far more, and this is called for every token by the safety check.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i

the number

Return Value character(len=int_width)

public pure function utf8_width(text) result(w)

Number of characters (code points) in UTF-8 text: bytes that are not continuation bytes.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

UTF-8 bytes

Return Value integer


Subroutines

private pure subroutine builder_append(self, str)

Append str to the string, doubling the storage when it is full.

Arguments

Type IntentOptional Attributes Name
class(string_builder_t), intent(inout) :: self

the builder

character(len=*), intent(in) :: str

the piece to append

public pure subroutine make_lowercase(s)

Turn s into lowercase in place, without a temporary copy (see lower_char).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(inout) :: s

the text