watch_util Module

Miscellaneous string utilities.

Provides small helpers for formatting and manipulating allocatable strings and string arrays.


Uses

    • fpm_strings
  • module~~watch_util~~UsesGraph module~watch_util watch_util fpm_strings fpm_strings module~watch_util->fpm_strings

Used by

  • module~~watch_util~~UsedByGraph module~watch_util watch_util module~watch_banner watch_banner module~watch_banner->module~watch_util module~watch_engine watch_engine module~watch_engine->module~watch_util module~watch_engine->module~watch_banner module~watch_exec watch_exec module~watch_engine->module~watch_exec module~watch_fpm_graph watch_fpm_graph module~watch_engine->module~watch_fpm_graph module~watch_exec->module~watch_util module~watch_fpm_graph->module~watch_util

Derived Types

type, public ::  string_accum_t

Simple amortized string accumulator.

Read more…

Components

Type Visibility Attributes Name Initial
type(string_t), public, allocatable :: a(:)
integer, public :: n = 0

Type-Bound Procedures

procedure, public :: push => accum_push
procedure, public :: to_array => accum_to_array

Functions

public pure function ftoa(x) result(s)

Format a real number with two decimal places.

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: x

Return Value character(len=:), allocatable

public pure function join_csv(a, empty) result(s)

Join a list of strings into a comma-separated value string.

Read more…

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(in), allocatable :: a(:)
character(len=*), intent(in) :: empty

Return Value character(len=:), allocatable

public pure function trim_or_default(s, default) result(r)

Trim an allocatable string or return a default if empty/unallocated.

Arguments

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

Return Value character(len=:), allocatable

public pure function trim_or_empty(s) result(r)

Trim an allocatable string or return an empty string if unallocated.

Arguments

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

Return Value character(len=:), allocatable


Subroutines

public subroutine sort_unique_strings(a)

Sort an array of strings and remove duplicates.

Read more…

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(inout), allocatable :: a(:)

private subroutine accum_push(self, s)

Append a string to the accumulator (grows capacity as needed).

Arguments

Type IntentOptional Attributes Name
class(string_accum_t), intent(inout) :: self
character(len=*), intent(in) :: s

private subroutine accum_to_array(self, out)

Materialize the accumulator into a right-sized array.

Read more…

Arguments

Type IntentOptional Attributes Name
class(string_accum_t), intent(inout) :: self
type(string_t), intent(out), allocatable :: out(:)