String Derived Type

type, public :: String


Constructor

public interface String

  • private function new_String(s) result(str)

    Arguments

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

    Return Value type(String)


Type-Bound Procedures

procedure, public, pass(from) :: assign_char_from_string

  • private subroutine assign_char_from_string(to, from)

    Arguments

    Type IntentOptional Attributes Name
    character(len=:), intent(out), allocatable :: to
    class(String), intent(in) :: from

procedure, public :: assign_string_from_char

  • private subroutine assign_string_from_char(to, from)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(out) :: to
    character(len=*), intent(in) :: from

procedure, public :: assign_string_from_string

  • private subroutine assign_string_from_string(to, from)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(out) :: to
    class(String), intent(in) :: from

generic, public :: assignment(=) => assign_string_from_string

  • private subroutine assign_string_from_string(to, from)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(out) :: to
    class(String), intent(in) :: from

generic, public :: assignment(=) => assign_string_from_char

  • private subroutine assign_string_from_char(to, from)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(out) :: to
    character(len=*), intent(in) :: from

generic, public :: assignment(=) => assign_char_from_string

  • private subroutine assign_char_from_string(to, from)

    Arguments

    Type IntentOptional Attributes Name
    character(len=:), intent(out), allocatable :: to
    class(String), intent(in) :: from

procedure, public :: capitalize

  • private function capitalize(this)

    Arguments

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

    Return Value type(String)

procedure, public, pass(this) :: char_is_equal_to_string

  • private function char_is_equal_to_string(lhs, this) result(are_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

procedure, public, pass(this) :: char_is_greater_than_or_equal_to_string

  • private function char_is_greater_than_or_equal_to_string(lhs, this) result(is_greater_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

procedure, public, pass(this) :: char_is_greater_than_string

  • private function char_is_greater_than_string(lhs, this) result(is_greater_than)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

procedure, public, pass(this) :: char_is_less_than_or_equal_to_string

  • private function char_is_less_than_or_equal_to_string(lhs, this) result(is_less_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

procedure, public, pass(this) :: char_is_less_than_string

  • private function char_is_less_than_string(lhs, this) result(is_less_than)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

procedure, public, pass(this) :: char_is_not_equal_to_string

  • private function char_is_not_equal_to_string(lhs, this) result(are_not_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

procedure, public, pass(this) :: concatenate_char_string

  • private function concatenate_char_string(lhs, this) result(str)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value type(String)

procedure, public :: concatenate_string_char

  • private function concatenate_string_char(this, rhs) result(str)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value type(String)

procedure, public :: concatenate_string_string

  • private function concatenate_string_string(this, rhs) result(str)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value type(String)

procedure, public :: get => get_fixed_length_string

  • private subroutine get_fixed_length_string(this, s)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(out) :: s

generic, public :: index => index_string

  • private function index_string(this, substring, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: substring
    logical, optional :: back

    Return Value integer

generic, public :: index => index_char

  • private function index_char(this, substring, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: substring
    logical, optional :: back

    Return Value integer

procedure, public :: index_char

  • private function index_char(this, substring, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: substring
    logical, optional :: back

    Return Value integer

procedure, public :: index_string

  • private function index_string(this, substring, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: substring
    logical, optional :: back

    Return Value integer

procedure, public :: is_allocated

  • private function is_allocated(this)

    Arguments

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

    Return Value logical

procedure, public :: len => len_string

  • private function len_string(this)

    Arguments

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

    Return Value integer

procedure, public :: len_trim => len_trim_string

  • private function len_trim_string(this)

    Arguments

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

    Return Value integer

procedure, public :: lower

  • private function lower(this)

    Arguments

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

    Return Value type(String)

generic, public :: operator(//) => concatenate_string_string

  • private function concatenate_string_string(this, rhs) result(str)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value type(String)

generic, public :: operator(//) => concatenate_string_char

  • private function concatenate_string_char(this, rhs) result(str)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value type(String)

generic, public :: operator(//) => concatenate_char_string

  • private function concatenate_char_string(lhs, this) result(str)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value type(String)

generic, public :: operator(/=) => string_is_not_equal_to_string

  • private function string_is_not_equal_to_string(this, rhs) result(are_not_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

generic, public :: operator(/=) => string_is_not_equal_to_char

  • private function string_is_not_equal_to_char(this, rhs) result(are_not_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

generic, public :: operator(/=) => char_is_not_equal_to_string

  • private function char_is_not_equal_to_string(lhs, this) result(are_not_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

generic, public :: operator(<) => string_is_less_than_string

  • private function string_is_less_than_string(this, rhs) result(is_less_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

generic, public :: operator(<) => string_is_less_than_char

  • private function string_is_less_than_char(this, rhs) result(is_less_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

generic, public :: operator(<) => char_is_less_than_string

  • private function char_is_less_than_string(lhs, this) result(is_less_than)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

generic, public :: operator(<=) => string_is_less_than_or_equal_to_string

  • private function string_is_less_than_or_equal_to_string(this, rhs) result(is_less_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

generic, public :: operator(<=) => string_is_less_than_or_equal_to_char

  • private function string_is_less_than_or_equal_to_char(this, rhs) result(is_less_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

generic, public :: operator(<=) => char_is_less_than_or_equal_to_string

  • private function char_is_less_than_or_equal_to_string(lhs, this) result(is_less_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

generic, public :: operator(==) => string_is_equal_to_string

  • private function string_is_equal_to_string(this, rhs) result(are_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

generic, public :: operator(==) => string_is_equal_to_char

  • private function string_is_equal_to_char(this, rhs) result(are_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

generic, public :: operator(==) => char_is_equal_to_string

  • private function char_is_equal_to_string(lhs, this) result(are_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

generic, public :: operator(>) => string_is_greater_than_string

  • private function string_is_greater_than_string(this, rhs) result(is_greater_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

generic, public :: operator(>) => string_is_greater_than_char

  • private function string_is_greater_than_char(this, rhs) result(is_greater_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

generic, public :: operator(>) => char_is_greater_than_string

  • private function char_is_greater_than_string(lhs, this) result(is_greater_than)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

generic, public :: operator(>=) => string_is_greater_than_or_equal_to_string

  • private function string_is_greater_than_or_equal_to_string(this, rhs) result(is_greater_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

generic, public :: operator(>=) => string_is_greater_than_or_equal_to_char

  • private function string_is_greater_than_or_equal_to_char(this, rhs) result(is_greater_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

generic, public :: operator(>=) => char_is_greater_than_or_equal_to_string

  • private function char_is_greater_than_or_equal_to_string(lhs, this) result(is_greater_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: lhs
    class(String), intent(in) :: this

    Return Value logical

generic, public :: scan => scan_string

  • private function scan_string(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: set
    logical, optional :: back

    Return Value integer

generic, public :: scan => scan_char

  • private function scan_char(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: set
    logical, optional :: back

    Return Value integer

procedure, public :: scan_char

  • private function scan_char(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: set
    logical, optional :: back

    Return Value integer

procedure, public :: scan_string

  • private function scan_string(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: set
    logical, optional :: back

    Return Value integer

procedure, public :: string_is_equal_to_char

  • private function string_is_equal_to_char(this, rhs) result(are_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_equal_to_string

  • private function string_is_equal_to_string(this, rhs) result(are_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_greater_than_char

  • private function string_is_greater_than_char(this, rhs) result(is_greater_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_greater_than_or_equal_to_char

  • private function string_is_greater_than_or_equal_to_char(this, rhs) result(is_greater_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_greater_than_or_equal_to_string

  • private function string_is_greater_than_or_equal_to_string(this, rhs) result(is_greater_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_greater_than_string

  • private function string_is_greater_than_string(this, rhs) result(is_greater_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_less_than_char

  • private function string_is_less_than_char(this, rhs) result(is_less_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_less_than_or_equal_to_char

  • private function string_is_less_than_or_equal_to_char(this, rhs) result(is_less_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_less_than_or_equal_to_string

  • private function string_is_less_than_or_equal_to_string(this, rhs) result(is_less_than_or_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_less_than_string

  • private function string_is_less_than_string(this, rhs) result(is_less_than)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_not_equal_to_char

  • private function string_is_not_equal_to_char(this, rhs) result(are_not_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: rhs

    Return Value logical

procedure, public :: string_is_not_equal_to_string

  • private function string_is_not_equal_to_string(this, rhs) result(are_not_equal)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: rhs

    Return Value logical

procedure, public :: upper

  • private function upper(this)

    Arguments

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

    Return Value type(String)

generic, public :: verify => verify_string

  • private function verify_string(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: set
    logical, optional :: back

    Return Value integer

generic, public :: verify => verify_char

  • private function verify_char(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: set
    logical, optional :: back

    Return Value integer

procedure, public :: verify_char

  • private function verify_char(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    character(len=*), intent(in) :: set
    logical, optional :: back

    Return Value integer

procedure, public :: verify_string

  • private function verify_string(this, set, back) result(idx)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    class(String), intent(in) :: set
    logical, optional :: back

    Return Value integer

generic, public :: write(formatted) => write_formatted

  • private subroutine write_formatted(this, unit, iotype, v_list, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    integer, intent(in) :: unit
    character(len=*), intent(in) :: iotype
    integer, intent(in) :: v_list(:)
    integer, intent(out) :: iostat
    character(len=*), intent(inout) :: iomsg

procedure, public :: write_formatted

  • private subroutine write_formatted(this, unit, iotype, v_list, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    class(String), intent(in) :: this
    integer, intent(in) :: unit
    character(len=*), intent(in) :: iotype
    integer, intent(in) :: v_list(:)
    integer, intent(out) :: iostat
    character(len=*), intent(inout) :: iomsg

Source Code

   type :: String
      private
      character(:), allocatable :: string
   contains
      ! ASSIGNMENT(=)
      procedure :: assign_string_from_string
      procedure :: assign_string_from_char
      procedure, pass(from) :: assign_char_from_string
      generic :: assignment(=) => assign_string_from_string
      generic :: assignment(=) => assign_string_from_char
      generic :: assignment(=) => assign_char_from_string

      ! OPERATOR(==)
      procedure :: string_is_equal_to_string
      procedure :: string_is_equal_to_char
      procedure, pass(this) :: char_is_equal_to_string
      generic :: operator(==) => string_is_equal_to_string
      generic :: operator(==) => string_is_equal_to_char
      generic :: operator(==) => char_is_equal_to_string

      ! OPERATOR(<)
      procedure :: string_is_less_than_string
      procedure :: string_is_less_than_char
      procedure, pass(this) :: char_is_less_than_string
      generic :: operator(<) => string_is_less_than_string
      generic :: operator(<) => string_is_less_than_char
      generic :: operator(<) => char_is_less_than_string

      ! OPERATOR(<=)
      procedure :: string_is_less_than_or_equal_to_string
      procedure :: string_is_less_than_or_equal_to_char
      procedure, pass(this) :: char_is_less_than_or_equal_to_string
      generic :: operator(<=) => string_is_less_than_or_equal_to_string
      generic :: operator(<=) => string_is_less_than_or_equal_to_char
      generic :: operator(<=) => char_is_less_than_or_equal_to_string

      ! OPERATOR(>)
      procedure :: string_is_greater_than_string
      procedure :: string_is_greater_than_char
      procedure, pass(this) :: char_is_greater_than_string
      generic :: operator(>) => string_is_greater_than_string
      generic :: operator(>) => string_is_greater_than_char
      generic :: operator(>) => char_is_greater_than_string

      ! OPERATOR(>=)
      procedure :: string_is_greater_than_or_equal_to_string
      procedure :: string_is_greater_than_or_equal_to_char
      procedure, pass(this) :: char_is_greater_than_or_equal_to_string
      generic :: operator(>=) => string_is_greater_than_or_equal_to_string
      generic :: operator(>=) => string_is_greater_than_or_equal_to_char
      generic :: operator(>=) => char_is_greater_than_or_equal_to_string

      ! OPERATOR(/=)
      procedure :: string_is_not_equal_to_string
      procedure :: string_is_not_equal_to_char
      procedure, pass(this) :: char_is_not_equal_to_string
      generic :: operator(/=) => string_is_not_equal_to_string
      generic :: operator(/=) => string_is_not_equal_to_char
      generic :: operator(/=) => char_is_not_equal_to_string

      ! OPERATOR(//)
      procedure :: concatenate_string_string
      procedure :: concatenate_string_char
      procedure, pass(this) :: concatenate_char_string
      generic :: operator(//) => concatenate_string_string
      generic :: operator(//) => concatenate_string_char
      generic :: operator(//) => concatenate_char_string

      ! WRITE(FORMATTED)
      procedure :: write_formatted
      generic :: write(formatted) => write_formatted

      ! INTRINSICS
      procedure :: len => len_string
      procedure :: len_trim => len_trim_string

      procedure :: index_string
      procedure :: index_char
      generic :: index => index_string
      generic :: index => index_char

      procedure :: scan_string
      procedure :: scan_char
      generic :: scan => scan_string
      generic :: scan => scan_char

      procedure :: verify_string
      procedure :: verify_char
      generic :: verify => verify_string
      generic :: verify => verify_char

      ! Supplemental
      procedure :: get => get_fixed_length_string
      procedure :: is_allocated
      procedure :: lower
      procedure :: upper
      procedure :: capitalize

   end type String