Loading...
Searching...
No Matches
String

Definition

String module.

Data Types

type  string
 Represents text as a sequence of ASCII code units. The derived type wraps an allocatable character array. More...

Methods

◆ character_assign_string()

subroutine character_assign_string ( class(string), intent(inout) lhs,
character(*), intent(in) rhs )

Assignment overloading. Assign a character array to a string.

Parameters
[in,out]lhsstring
[in]rhscharacter(*)

Examples

type(string) :: s
s = 'foo'

Remarks

Definition at line 65 of file String.f90.

◆ str()

pure recursive character(:) function, allocatable, public str ( class(*), intent(in) value,
character(*), intent(in), optional fmt )

Function to stringify anything.

Parameters
[in]valueThe value of any intrinsic type to be stringified
[in]fmt(optional) The format value

Examples

pure function to_string(this) result(s)
class(arg), intent(in) :: this
character(:), allocatable :: s
if (allocated(this%display)) then
s = this%display
else
s = str(this%value)
end if
end function
Returns
A character array corresponding to the character representation of the value argument.

Remarks

Definition at line 143 of file String.f90.

◆ string_assign_character()

subroutine string_assign_character ( character(:), intent(inout), allocatable lhs,
class(string), intent(in) rhs )
private

Assignment overloading. Assign a string to a character array.

Parameters
[in,out]lhscharacter(*), allocatable
[in]rhsstring

Examples

type(string) :: s
character(:), allocatable :: c
s = 'foo'
c = s
! the value of c is now 'foo'

Remarks

Definition at line 90 of file String.f90.

◆ string_len()

pure integer function string_len ( class(string), intent(in) this)
private

Length of the string entity.

Parameters
[in]thisstring

Examples

type(string) :: s
integer :: l
s = string('foo')
l = s%len()
! the value of l is 3
Returns
An integer cooresponding to the length of the string

Remarks

Definition at line 113 of file String.f90.