NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
fstr Interface Reference

This type defines a string class, with its methods. More...

Public Member Functions

procedure writef (s, unit, iotype, v_list, iostat, iomsg)
 
procedure upper (s)
 Returns a copy of the string converted to uppercase.
 
procedure lower (s)
 Returns a copy of the string converted to lowercase.
 
procedure swapcase (s)
 Return str with case of letters swapped.
 
procedure reverse (s)
 Reverse a string.
 
procedure endswith (s, suffix)
 Return True if S starts with the specified prefix, False otherwise.
 
procedure startswith (s, prefix)
 Return True if S starts with the specified prefix, False otherwise.
 
procedure lstrip (s, chars)
 This function returns a copy of the string with leading chars removed.
 
procedure rstrip (s, chars)
 This function returns a copy of the string with trailing chars removed.
 
procedure strip (s, chars)
 This function returns a copy of the string with leading and trailing chars removed.
 
procedure count (s, sub, start, end)
 Return the number of occurrences of substring sub in string S[start:end].
 
procedure center (s, width, fillchar)
 Center a string to a specified width. The default character to fill in the centered string is a blank character.
 
procedure find (s, sub, start, end)
 Return the lowest index in S where substring sub is found.
 
procedure replace (s, old, new, count)
 Return a copy with all occurrences of substring old replaced by new.
 
generic operator (s, other)
 equal: comparison between two strings
 
generic operator (s, other)
 not_equal: comparison between two strings
 
generic operator (n, s)
 Multiply by an integer.
 
generic operator (s, n)
 Multiplication by integer.
 
generic operator (s, value)
 
generic operator (value, s)
 
generic operator (s, value)
 
 formatted (s, unit, iotype, v_list, iostat, iomsg)
 

Public Attributes

character(len=:), allocatable val
 This holds the string of characters.
 

Detailed Description

This type defines a string class, with its methods.

Member Function/Subroutine Documentation

◆ center()

procedure center ( class(fstr), intent(in) s,
integer, intent(in) width,
character(len=1), intent(in), optional fillchar )

Center a string to a specified width. The default character to fill in the centered string is a blank character.

Parameters
[in]sOriginal string
[in]widthTotal width of centered string
[in]fillcharPadding character (default to space)
Returns
A centered string of length width.

◆ count()

procedure count ( class(fstr), intent(in) s,
character(len=*), intent(in) sub,
integer, intent(in), optional start,
integer, intent(in), optional end )

Return the number of occurrences of substring sub in string S[start:end].

Parameters
[in]sOriginal string
[in]subsubstring to count
[in]startinitial position to consider
[in]endfinal position to consider
Returns
Number of occurrences of sub in S

◆ endswith()

procedure endswith ( class(fstr), intent(in) s,
character(len=*), intent(in) suffix )

Return True if S starts with the specified prefix, False otherwise.

Note
that differs from python method in that does not accept a tuple
Parameters
[in]sOriginal string
[in]suffixsubstring to test
Returns
.True. if S ends with sub.

◆ find()

procedure find ( class(fstr), intent(in) s,
character(len=*), intent(in) sub,
integer, intent(in), optional start,
integer, intent(in), optional end )

Return the lowest index in S where substring sub is found.

Returns
position where found
Parameters
[in]soriginal string
[in]subsubstring to find
[in]startinitial position to search
[in]endfinal position to search

◆ formatted()

formatted ( class(fstr), intent(in) s,
integer, intent(in) unit,
character(*), intent(in) iotype,
integer, dimension(:), intent(in) v_list,
integer, intent(out) iostat,
character(*), intent(inout) iomsg )
Parameters
[in]sObject to write.
[in]unitInternal unit to write to.
[in]iotypeLISTDIRECTED or DTxxx
[in]v_listparameters from fmt spec.
[out]iostatnon zero on error, etc.
[in,out]iomsgdefine if iostat non zero.

◆ lower()

procedure lower ( class(fstr), intent(in) s)

Returns a copy of the string converted to lowercase.

Parameters
[in]sOriginal string
Returns
String converted to uppercase

◆ lstrip()

procedure lstrip ( class(fstr), intent(in) s,
character(len=*), intent(in), optional chars )

This function returns a copy of the string with leading chars removed.

If chars is not present all blank: spaces (achar(32)) and tabs (achar(9)) are removed.

Note
that when used with no chars argument differs from intrinsic trim in that it will also strip "tab" characters
Parameters
[in]sOriginal string
[in]charschars to remove from S
Returns
String with chars removed

◆ operator() [1/7]

generic operator ( integer, intent(in) n,
class(fstr), intent(in) s )

Multiply by an integer.

Parameters
[in]sOriginal string
[in]nnumber of repetitions
Returns
String multiplied n times

◆ operator() [2/7]

generic operator ( class(fstr), intent(in) s,
integer, intent(in) n )

Multiplication by integer.

Parameters
[in]sOriginal string
[in]nnumber of repetitions
Returns
String multiplied n times

◆ operator() [3/7]

generic operator ( class(fstr), intent(in) s,
class(fstr), intent(in) other )

equal: comparison between two strings

Returns
.True. if equal, .False. if not
Parameters
[in]sLeft-side of comparison
[in]otherRight-side of comparison

◆ operator() [4/7]

generic operator ( class(fstr), intent(in) s,
class(fstr), intent(in) other )

not_equal: comparison between two strings

Returns
.False. if equal, .True. if not
Parameters
[in]sLeft-side of comparison
[in]otherRight-side of comparison

◆ operator() [5/7]

generic operator ( class(fstr), intent(in) s,
class(fstr), intent(in) value )
Parameters
[in]sfirst string
[in]valueSecond string
Returns
Joined string

◆ operator() [6/7]

generic operator ( class(fstr), intent(in) s,
character(len=*), intent(in) value )
Parameters
[in]sFirst string
[in]valueSecond string
Returns
Joined string

◆ operator() [7/7]

generic operator ( character(len=*), intent(in) value,
class(fstr), intent(in) s )
Parameters
[in]sFirst string
[in]valueSecond string
Returns
Joined string

◆ replace()

procedure replace ( class(fstr), intent(in) s,
character(len=*), intent(in) old,
character(len=*), intent(in) new,
integer, intent(in), optional count )

Return a copy with all occurrences of substring old replaced by new.

Parameters
[in]soriginal string
[in]oldsubstring to replace
[in]newsubstring to substitute from old
[in]countMaximum number of occurrences to replace
Returns
New string created

◆ reverse()

procedure reverse ( class(fstr), intent(in) s)

Reverse a string.

Parameters
[in]sOriginal string
Returns
Reversed string

◆ rstrip()

procedure rstrip ( class(fstr), intent(in) s,
character(len=*), intent(in), optional chars )

This function returns a copy of the string with trailing chars removed.

If chars is not present all blank: spaces (achar(32)) and tabs (achar(9)) are removed.

Note
that when used with no chars argument differs from intrinsic trim in that it will also strip "tab" characters
Parameters
[in]sOriginal string
[in]charschars to remove from S
Returns
String with chars removed

◆ startswith()

procedure startswith ( class(fstr), intent(in) s,
character(len=*), intent(in) prefix )

Return True if S starts with the specified prefix, False otherwise.

Note
that differs from python method in that does not accept a tuple as prefix
Parameters
[in]sOriginal string
[in]prefixsubstring to test
Returns
True if S starts with prefix

◆ strip()

procedure strip ( class(fstr), intent(in) s,
character(len=*), intent(in), optional chars )

This function returns a copy of the string with leading and trailing chars removed.

If chars is not present all blank: spaces (achar(32)) and tabs (achar(9)) are removed.

Note
that when used with no chars argument differs from intrinsic trim in that it will also strip "tab" characters
Parameters
[in]sOriginal string
[in]charschars to remove from S
Returns
String with chars removed

◆ swapcase()

procedure swapcase ( class(fstr), intent(in) s)

Return str with case of letters swapped.

Parameters
[in]sOriginal string
Returns
String with cases swapped

◆ upper()

procedure upper ( class(fstr), intent(in) s)

Returns a copy of the string converted to uppercase.

Parameters
[in]sOriginal string
Returns
String converted to uppercase

◆ writef()

procedure writef ( class(fstr), intent(in) s,
integer, intent(in) unit,
character(*), intent(in) iotype,
integer, dimension(:), intent(in) v_list,
integer, intent(out) iostat,
character(*), intent(inout) iomsg )
Parameters
[in]sObject to write.
[in]unitInternal unit to write to.
[in]iotypeLISTDIRECTED or DTxxx
[in]v_listparameters from fmt spec.
[out]iostatnon zero on error, etc.
[in,out]iomsgdefine if iostat non zero.

The documentation for this interface was generated from the following file: