Implementation of a string type to hold an arbitrary sequence of characters.
This module provides string type compatible with all Fortran instrinsic character procedures as well as overloaded operators for working with character variables.
A string type can be easily constructed by creating a new instance from a character variable or literal by invoking its constructor or by assigning it to a string type. Generally, the string type behaves similar to a deferred length character in most regards but adds memory access safety.
The specification of this module is available here.
Left-adjust the character sequence represented by the string. The length of the character sequence remains unchanged.
This method is elemental and returns a scalar character value.
Left-adjust the character sequence represented by the string. The length of the character sequence remains unchanged.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Right-adjust the character sequence represented by the string. The length of the character sequence remains unchanged.
This method is elemental and returns a scalar character value.
Right-adjust the character sequence represented by the string. The length of the character sequence remains unchanged.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Assign a character sequence to a string.
Assign a character sequence to a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(inout) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Return the character sequence represented by the string.
This method is elemental and returns a scalar character value.
Return the character sequence represented by the string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Return the character sequence represented by the string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
integer, | intent(in) | :: | pos |
Return the character sequence represented by the string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
integer, | intent(in) | :: | start | |||
integer, | intent(in) | :: | last |
Code in ASCII collating sequence.
This method is elemental and returns a default integer scalar value.
Code in ASCII collating sequence.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Character-to-integer conversion function.
This method is elemental and returns a default integer scalar value.
Character-to-integer conversion function.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Position of a substring within a string.
Returns the position of the start of the leftmost or rightmost occurrence of string substring in string, counting from one. If substring is not present in string, zero is returned.
This method is elemental and returns a default integer scalar value.
Position of a sequence of character within a character sequence. In this version both character sequences are represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
type(string_type), | intent(in) | :: | substring | |||
logical, | intent(in), | optional | :: | back |
Position of a sequence of character within a character sequence. In this version the main character sequence is represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | substring | |||
logical, | intent(in), | optional | :: | back |
Position of a sequence of character within a character sequence. In this version the sub character sequence is represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
type(string_type), | intent(in) | :: | substring | |||
logical, | intent(in), | optional | :: | back |
Returns the length of the character sequence represented by the string.
This method is elemental and returns a default integer scalar value.
Returns the length of the character sequence represented by the string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Returns the length of the character sequence without trailing spaces represented by the string.
This method is elemental and returns a default integer scalar value.
Returns the length of the character sequence without trailing spaces represented by the string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Lexically compare the order of two character sequences being greater equal, The left-hand side, the right-hand side or both character sequences can be represented by a string.
This method is elemental and returns a default logical scalar value.
Lexically compare two character sequences for being greater or equal. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Lexically compare two character sequences for being greater or equal. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Lexically compare two character sequences for being greater or equal In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Lexically compare the order of two character sequences being greater, The left-hand side, the right-hand side or both character sequences can be represented by a string.
This method is elemental and returns a default logical scalar value.
Lexically compare two character sequences for being greater. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Lexically compare two character sequences for being greater. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Lexically compare two character sequences for being greater. In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Lexically compare the order of two character sequences being less equal, The left-hand side, the right-hand side or both character sequences can be represented by a string.
This method is elemental and returns a default logical scalar value.
Lexically compare two character sequences for being less or equal. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Lexically compare two character sequences for being less or equal. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Lexically compare two character sequences for being less or equal In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Lexically compare the order of two character sequences being less, The left-hand side, the right-hand side or both character sequences can be represented by a string.
This method is elemental and returns a default logical scalar value.
Lexically compare two character sequences for being less. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Lexically compare two character sequences for being less. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Lexically compare two character sequences for being less. In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Moves the allocated character scalar from 'from' to 'to' Specifications
Moves the allocated character scalar from 'from' to 'to' No output
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(inout), | target | :: | from | ||
type(string_type), | intent(inout), | target | :: | to |
Moves the allocated character scalar from 'from' to 'to' No output
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(inout) | :: | from | |||
character(len=:), | intent(out), | allocatable | :: | to |
Moves the allocated character scalar from 'from' to 'to' No output
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=:), | intent(inout), | allocatable | :: | from | ||
type(string_type), | intent(out) | :: | to |
Moves the allocated character scalar from 'from' to 'to' No output
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=:), | intent(inout), | allocatable | :: | from | ||
character(len=:), | intent(out), | allocatable | :: | to |
Concatenate two character sequences, the left-hand side, the right-hand side or both character sequences can be represented by a string.
This operator is elemental and returns a scalar character value.
Concatenate two character sequences. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Concatenate two character sequences. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Concatenate two character sequences. In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for inequality, the left-hand side, the right-hand side or both character sequences can be represented by a string.
This operator is elemental and returns a default logical scalar value.
Compare two character sequences for inequality. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for inequality. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Compare two character sequences for inequality. In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being less, the left-hand side, the right-hand side or both character sequences can be represented by a string.
This operator is elemental and returns a default logical scalar value.
Compare two character sequences for being less. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being less. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Compare two character sequences for being less. In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being less than, the left-hand side, the right-hand side or both character sequences can be represented by a string.
This operator is elemental and returns a default logical scalar value.
Compare two character sequences for being less or equal. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being less or equal. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Compare two character sequences for being less or equal In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for equality, the left-hand side, the right-hand side or both character sequences can be represented by a string.
This operator is elemental and returns a default logical scalar value.
Compare two character sequences for equality. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for equality. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Compare two character sequences for equality. In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being greater, the left-hand side, the right-hand side or both character sequences can be represented by a string.
This operator is elemental and returns a default logical scalar value.
Compare two character sequences for being greater. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being greater. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Compare two character sequences for being greater. In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being greater than, the left-hand side, the right-hand side or both character sequences can be represented by a string.
This operator is elemental and returns a default logical scalar value.
Compare two character sequences for being greater or equal. In this version both character sequences are by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Compare two character sequences for being greater or equal. In this version the left-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | lhs | |||
character(len=*), | intent(in) | :: | rhs |
Compare two character sequences for being greater or equal In this version the right-hand side character sequences is by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | lhs | |||
type(string_type), | intent(in) | :: | rhs |
Read a character sequence from a connected unformatted unit into the string.
Read a character sequence from a connected formatted unit into the string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(inout) | :: | string | |||
integer, | intent(in) | :: | unit | |||
character(len=*), | intent(in) | :: | iotype | |||
integer, | intent(in) | :: | v_list(:) | |||
integer, | intent(out) | :: | iostat | |||
character(len=*), | intent(inout) | :: | iomsg |
Read a character sequence from a connected unformatted unit into the string.
Read a character sequence from a connected unformatted unit into the string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(inout) | :: | string | |||
integer, | intent(in) | :: | unit | |||
integer, | intent(out) | :: | iostat | |||
character(len=*), | intent(inout) | :: | iomsg |
Repeats the character sequence hold by the string by the number of specified copies.
This method is elemental and returns a scalar character value.
Repeats the character sequence hold by the string by the number of specified copies.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
integer, | intent(in) | :: | ncopies |
Reverses the character sequence hold by the input string
This method is elemental and returns a new string_type instance which holds this reverse character sequence
Reverse the character sequence hold by the input string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Scan a string for the presence of a set of characters. Scans a string for any of the characters in a set of characters.
If back is either absent or false, this function returns the position of the leftmost character of string that is in set. If back is true, the rightmost position is returned. If no character of set is found in string, the result is zero.
This method is elemental and returns a default integer scalar value.
Scan a character sequence for any of the characters in a set of characters. In this version both the character sequence and the character set are represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
type(string_type), | intent(in) | :: | set | |||
logical, | intent(in), | optional | :: | back |
Scan a character sequence for any of the characters in a set of characters. In this version the character sequences is represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
logical, | intent(in), | optional | :: | back |
Scan a character sequence for any of the characters in a set of characters. In this version the set of characters is represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
type(string_type), | intent(in) | :: | set | |||
logical, | intent(in), | optional | :: | back |
Constructor for new string instances
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in), | optional | :: | string |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int16), | intent(in) | :: | val |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | val |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | val |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int8), | intent(in) | :: | val |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical(kind=lk), | intent(in) | :: | val |
Returns the lowercase version of the character sequence hold by the input string
This method is Elemental and returns a new string_type instance which holds this lowercase character sequence
Convert the character sequence hold by the input string to lower case
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Returns the sentencecase version of the character sequence hold by the input string
This method is elemental and returns a new string_type instance which holds this sentencecase character sequence
Convert the character sequence hold by the input string to sentence case
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Returns the titlecase version of the character sequence hold by the input string
This method is Elemental and returns a new string_type instance which holds this titlecase character sequence
Convert the character sequence hold by the input string to title case
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Returns the uppercase version of the character sequence hold by the input string
This method is Elemental and returns a new string_type instance which holds this uppercase character sequence
Convert the character sequence hold by the input string to upper case
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Returns the character sequence hold by the string without trailing spaces.
This method is elemental and returns a scalar character value.
Returns the character sequence hold by the string without trailing spaces.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string |
Scan a string for the absence of a set of characters. Verifies that all the characters in string belong to the set of characters in set.
If back is either absent or false, this function returns the position of the leftmost character of string that is not in set. If back is true, the rightmost position is returned. If all characters of string are found in set, the result is zero.
This method is elemental and returns a default integer scalar value.
Verify a character sequence for the absence any of the characters in a set of characters. In this version both the character sequence and the character set are represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
type(string_type), | intent(in) | :: | set | |||
logical, | intent(in), | optional | :: | back |
Verify a character sequence for the absence any of the characters in a set of characters. In this version the character sequences is represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
logical, | intent(in), | optional | :: | back |
Verify a character sequence for the absence any of the characters in a set of characters. In this version the set of characters is represented by a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
type(string_type), | intent(in) | :: | set | |||
logical, | intent(in), | optional | :: | back |
Write the character sequence hold by the string to a connected formatted unit.
Write the character sequence hold by the string to a connected formatted unit.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
integer, | intent(in) | :: | unit | |||
character(len=*), | intent(in) | :: | iotype | |||
integer, | intent(in) | :: | v_list(:) | |||
integer, | intent(out) | :: | iostat | |||
character(len=*), | intent(inout) | :: | iomsg |
Write the character sequence hold by the string to a connected unformatted unit.
Write the character sequence hold by the string to a connected unformatted unit.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(in) | :: | string | |||
integer, | intent(in) | :: | unit | |||
integer, | intent(out) | :: | iostat | |||
character(len=*), | intent(inout) | :: | iomsg |
String type holding an arbitrary sequence of characters.
Constructor for new string instances
private elemental, module function new_string (string) | |
private elemental, module function new_string_from_integer_int16 (val) | |
private elemental, module function new_string_from_integer_int32 (val) | |
private elemental, module function new_string_from_integer_int64 (val) | |
private elemental, module function new_string_from_integer_int8 (val) | |
private elemental, module function new_string_from_logical_lk (val) |