fortran_strings Module


Uses


Contents


Variables

Type Visibility Attributes Name Initial
character(len=*), private, parameter :: UPPERCASE_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
character(len=*), private, parameter :: lowercase_chars = 'abcdefghijklmnopqrstuvwxyz'

Interfaces

public interface str

@brief Convert to Fortran string

@author Oskar Weser

@details It is a generic procedure that accepts int32 or int64.

@param[in] An int32 or int64.

  • private pure function int32_to_str(i) result(str)

    Arguments

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

    Return Value character(len=:), allocatable

  • private pure function int64_to_str(i) result(str)

    Arguments

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

    Return Value character(len=:), allocatable

  • private pure function realsp_to_str(x, after_comma) result(res)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=sp), intent(in) :: x
    integer, intent(in) :: after_comma

    Return Value character(len=:), allocatable

  • private pure function realdp_to_str(x, after_comma) result(res)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: x
    integer, intent(in) :: after_comma

    Return Value character(len=:), allocatable

  • private pure function bool_to_str(cond) result(res)

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(in) :: cond

    Return Value character(len=:), allocatable

public interface operator(.in.)

  • private pure function contains(substring, string)

    Arguments

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

    Return Value logical


Derived Types

type, public ::  Token_t

Components

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

Type-Bound Procedures

procedure , private , :: eq_Token_t Function
generic, public :: operator(==) => eq_Token_t
procedure , private , :: neq_Token_t Function
generic, public :: operator(/=) => neq_Token_t
procedure , private , :: add_Token_t Function
generic, public :: operator(+) => add_Token_t

Functions

private pure function int32_to_str(i) result(str)

Arguments

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

Return Value character(len=:), allocatable

private pure function int64_to_str(i) result(str)

Arguments

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

Return Value character(len=:), allocatable

private pure function realdp_to_str(x, after_comma) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x
integer, intent(in) :: after_comma

Return Value character(len=:), allocatable

private pure function realsp_to_str(x, after_comma) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: x
integer, intent(in) :: after_comma

Return Value character(len=:), allocatable

private pure function bool_to_str(cond) result(res)

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: cond

Return Value character(len=:), allocatable

public pure function to_upper(in_str) result(string)

Changes a string to upper case

Arguments

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

Return Value character(len=len_trim(in_str))

public pure function to_lower(in_str) result(string)

Changes a string to lower case

Arguments

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

Return Value character(len=len_trim(in_str))

private pure function contains(substring, string)

Arguments

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

Return Value logical

public pure function split(expr, delimiter) result(res)

@brief Split string by delimiter (defaults to space).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: expr
character(len=1), intent(in), optional :: delimiter

Return Value type(Token_t), allocatable, (:)

public pure function join(tokens, delimiter) result(res)

Join an array of tokens into one string

Arguments

Type IntentOptional Attributes Name
type(Token_t), intent(in) :: tokens(:)
character(len=*), intent(in) :: delimiter

Return Value character(len=:), allocatable

public pure function count_char(str, char) result(c)

@brief Count the occurence of a character in a string.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str
character(len=1), intent(in) :: char

Return Value integer

public elemental function to_int(str)

Arguments

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

Return Value integer

public elemental function to_int32(str)

Arguments

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

Return Value integer(kind=int32)

public elemental function to_int64(str)

Arguments

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

Return Value integer(kind=int64)

public elemental function to_realsp(str)

Arguments

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

Return Value real(kind=sp)

public elemental function to_realdp(str)

Arguments

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

Return Value real(kind=dp)

public elemental function can_be_real(str)

Arguments

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

Return Value logical

public elemental function can_be_int(str)

Arguments

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

Return Value logical

private elemental function eq_Token_t(this, other)

Arguments

Type IntentOptional Attributes Name
class(Token_t), intent(in) :: this
class(Token_t), intent(in) :: other

Return Value logical

private elemental function neq_Token_t(this, other)

Arguments

Type IntentOptional Attributes Name
class(Token_t), intent(in) :: this
class(Token_t), intent(in) :: other

Return Value logical

private elemental function add_Token_t(this, other)

Arguments

Type IntentOptional Attributes Name
class(Token_t), intent(in) :: this
class(Token_t), intent(in) :: other

Return Value type(Token_t)