Parse option name from a source string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(option), | intent(inout) | :: | self | Option data. |
||
character, | intent(in) | :: | sep | Separator of option name/value. |
||
type(string), | intent(in) | :: | source | String containing option data. |
||
integer(kind=I4P), | intent(out) | :: | error | Error code. |
elemental subroutine parse_name(self, sep, source, error)
!< Parse option name from a source string.
class(option), intent(inout) :: self !< Option data.
character(*), intent(in) :: sep !< Separator of option name/value.
type(string), intent(in) :: source !< String containing option data.
integer(I4P), intent(out) :: error !< Error code.
integer(I4P) :: pos !< Characters counter.
error = ERR_OPTION_NAME
pos = index(source, sep)
if (pos > 0) then
self%oname = trim(adjustl(source%slice(1, pos-1)))
error = 0
endif
endsubroutine parse_name