Loading...
Searching...
No Matches
fpx_string Module Reference

Derived types and interfaces

interface  len
 Return the length of a string. More...
 
interface  len_trim
 Return the trimmed length of a string. More...
 
interface  operator(.contains.)
 
interface  operator(//)
 
type  string
 Represents text as a sequence of ASCII code units. The derived type wraps an allocatable character array. More...
 
interface  trim
 Return the trimmed string. More...
 

Functions/Subroutines

subroutine character_assign_string (lhs, rhs)
 Assignment overloading. Assign a character array to a string.
 
subroutine string_assign_character (lhs, rhs)
 Assignment overloading. Assign a string to a character array.
 
elemental integer function string_len (this)
 Length of the string entity.
 
pure integer function string_len_trim (this)
 Length of the string entity without trailing blanks (len_trim).
 
pure character(:) function, allocatable string_trim (this)
 Returns a copy of the string with trailing blanks removed.
 
pure character(:) function, allocatable string_concat_string (lhs, rhs)
 Concatenation of two string objects.
 
pure character(:) function, allocatable string_concat_character (lhs, rhs)
 Concatenation of string and character expression.
 
pure character(:) function, allocatable character_concat_string (lhs, rhs)
 Concatenation of character expression and string.
 
elemental logical function string_eq_string (lhs, rhs)
 Equality comparison between two string objects.
 
elemental logical function string_eq_character (lhs, rhs)
 Equality comparison between string and character expression.
 
elemental logical function character_eq_string (lhs, rhs)
 Equality comparison (reversed) between character expression and string.
 
subroutine write_formatted (dtv, unit, iotype, v_list, iostat, iomsg)
 
logical function, public starts_with (str, arg1, idx)
 Formatted write support for the string type.
 
character function, public head (str)
 Returns the first non-blank character of a string.
 
character function, public tail (str)
 Returns the last non-blank character of a string.
 
character(:) function, allocatable, public concat (str1, str2)
 Smart concatenation that removes continuation markers (&) and handles line-continuation rules.
 
pure character(len_trim(str)) function, public uppercase (str)
 Convert string to upper case (respects contents of quotes).
 
subroutine, public writechk (unit, str)
 Write a long line split into chunks of size CHKSIZE with continuation (&).
 
character(1) function, public previous (line, pos)
 Returns the previous non-blank character before position pos (updates pos).
 
logical function strings_contain_string (lhs, rhs)
 Checks whether an array of string contains a given string.
 
logical function strings_contain_character (lhs, rhs)
 Checks whether an array of string contains a given character expression.
 
logical function characters_contain_character (lhs, rhs)
 Checks whether an array of character contains a given character expression.
 
logical function characters_contain_string (lhs, rhs)
 Checks whether an array of character contains a given string.
 

Function/Subroutine Documentation

◆ character_assign_string()

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

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 181 of file string.f90.

◆ character_concat_string()

pure character(:) function, allocatable character_concat_string ( character(*), intent(in) lhs,
class(string), intent(in) rhs )
private

Concatenation of character expression and string.

Parameters
[in]lhscharacter expression
[in]rhsstring
Returns
New concatenated string.

Definition at line 311 of file string.f90.

◆ character_eq_string()

elemental logical function character_eq_string ( character(*), intent(in) lhs,
class(string), intent(in) rhs )
private

Equality comparison (reversed) between character expression and string.

Parameters
[in]lhscharacter expression
[in]rhsstring
Returns
.true. if equal, .false. otherwise.

Definition at line 359 of file string.f90.

◆ characters_contain_character()

logical function characters_contain_character ( character(*), dimension(:), intent(in) lhs,
character(*), intent(in) rhs )
private

Checks whether an array of character contains a given character expression.

Parameters
[in]lhsarray of character
[in]rhscharacter expression to search for
Returns
.true. if rhs is present in lhs

Definition at line 590 of file string.f90.

◆ characters_contain_string()

logical function characters_contain_string ( character(*), dimension(:), intent(in) lhs,
type(string), intent(in) rhs )
private

Checks whether an array of character contains a given string.

Parameters
[in]lhsarray of character
[in]rhsstring to search for
Returns
.true. if rhs is present in lhs

Definition at line 609 of file string.f90.

◆ concat()

character(:) function, allocatable, public concat ( character(*), intent(in) str1,
character(*), intent(in) str2 )

Smart concatenation that removes continuation markers (&) and handles line-continuation rules.

Parameters
[in]str1first line
[in]str2second line
Returns
Concatenated string with proper continuation handling

Definition at line 435 of file string.f90.

◆ head()

character function, public head ( character(*), intent(in) str)

Returns the first non-blank character of a string.

Parameters
[in]strinput string
Returns
First character (space if empty)

Definition at line 408 of file string.f90.

◆ previous()

character(1) function, public previous ( character(*), intent(in) line,
integer, intent(inout) pos )

Returns the previous non-blank character before position pos (updates pos).

Parameters
[in]lineinput line
[in,out]poscurrent position (moved backward)
Returns
Previous non-blank character

Definition at line 532 of file string.f90.

◆ starts_with()

logical function, public starts_with ( character(*), intent(in) str,
character(*), intent(in) arg1,
integer, intent(out), optional idx )

Formatted write support for the string type.

Parameters
[in]dtvstring object
[in]unitlogical unit
[in]iotypeedit descriptor string
[in]v_listlist of values for edit descriptors
[out]iostatI/O status
[in,out]iomsgI/O message

Definition at line 393 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 204 of file string.f90.

◆ string_concat_character()

pure character(:) function, allocatable string_concat_character ( class(string), intent(in) lhs,
character(*), intent(in) rhs )
private

Concatenation of string and character expression.

Parameters
[in]lhsstring
[in]rhscharacter expression
Returns
New concatenated string.

Definition at line 295 of file string.f90.

◆ string_concat_string()

pure character(:) function, allocatable string_concat_string ( class(string), intent(in) lhs,
class(string), intent(in) rhs )
private

Concatenation of two string objects.

Parameters
[in]lhsleft-hand side string
[in]rhsright-hand side string
Returns
New concatenated string.

Definition at line 275 of file string.f90.

◆ string_eq_character()

elemental logical function string_eq_character ( class(string), intent(in) lhs,
character(*), intent(in) rhs )
private

Equality comparison between string and character expression.

Parameters
[in]lhsstring
[in]rhscharacter expression
Returns
.true. if equal, .false. otherwise.

Definition at line 343 of file string.f90.

◆ string_eq_string()

elemental logical function string_eq_string ( class(string), intent(in) lhs,
type(string), intent(in) rhs )
private

Equality comparison between two string objects.

Parameters
[in]lhsleft-hand side
[in]rhsright-hand side
Returns
.true. if the strings are equal, .false. otherwise.

Definition at line 327 of file string.f90.

◆ string_len()

elemental 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 = len(s)
! the value of l is 4
Returns
An integer corresponding to the length of the string.

Definition at line 224 of file string.f90.

◆ string_len_trim()

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

Length of the string entity without trailing blanks (len_trim).

Parameters
[in]thisstring

Examples

type(string) :: s
integer :: l
s = string('foo ')
l = len_trim(s)
! the value of l is 3
Returns
An integer corresponding to the trimmed length of the string.

Definition at line 247 of file string.f90.

◆ string_trim()

pure character(:) function, allocatable string_trim ( class(string), intent(in) this)
private

Returns a copy of the string with trailing blanks removed.

Parameters
[in]thisstring
Returns
Trimmed character string (deferred length).

Definition at line 260 of file string.f90.

◆ strings_contain_character()

logical function strings_contain_character ( type(string), dimension(:), intent(in) lhs,
character(*), intent(in) rhs )
private

Checks whether an array of string contains a given character expression.

Parameters
[in]lhsarray of string
[in]rhscharacter expression to search for
Returns
.true. if rhs is present in lhs

Definition at line 571 of file string.f90.

◆ strings_contain_string()

logical function strings_contain_string ( type(string), dimension(:), intent(in) lhs,
type(string), intent(in) rhs )
private

Checks whether an array of string contains a given string.

Parameters
[in]lhsarray of string
[in]rhsstring to search for
Returns
.true. if rhs is present in lhs

Definition at line 552 of file string.f90.

◆ tail()

character function, public tail ( character(*), intent(in) str)

Returns the last non-blank character of a string.

Parameters
[in]strinput string
Returns
Last character (space if empty)

Definition at line 420 of file string.f90.

◆ uppercase()

pure character(len_trim(str)) function, public uppercase ( character(*), intent(in) str)

Convert string to upper case (respects contents of quotes).

Parameters
[in]strinput string
Returns
Upper-case version of the string

Examples

character(*), parameter :: input = 'test'
character(:), allocatable :: output
output = uppercase(input)
if (output == 'TEST') print*, 'OK'

Definition at line 479 of file string.f90.

◆ write_formatted()

subroutine write_formatted ( class(string), intent(in) dtv,
integer, intent(in) unit,
character(*), intent(in) iotype,
integer, dimension(:), intent(in) v_list,
integer, intent(out) iostat,
character(*), intent(inout) iomsg )
private

Definition at line 371 of file string.f90.

◆ writechk()

subroutine, public writechk ( integer, intent(in) unit,
character(*), intent(in) str )

Write a long line split into chunks of size CHKSIZE with continuation (&).

Parameters
[in]unitlogical unit
[in]strstring to write

Definition at line 512 of file string.f90.