parse_name Subroutine

private elemental subroutine parse_name(self, source, error)

Get section name from a source string.

Arguments

TypeIntentOptionalAttributesName
class(section), intent(inout) :: self

Section data.

type(string), intent(in) :: source

String containing section data.

integer(kind=I4P), intent(out) :: error

Error code.


Contents

Source Code


Source Code

  elemental subroutine parse_name(self, source, error)
  !< Get section name from a source string.
  class(section), intent(inout) :: self     !< Section data.
  type(string),   intent(in)    :: source   !< String containing section data.
  integer(I4P),   intent(out)   :: error    !< Error code.
  integer(I4P)                  :: pos(1:2) !< Characters counter.

  error = ERR_SECTION_NAME
  pos(1) = index(source, "[")
  pos(2) = index(source, "]")
  if (all(pos > 0)) then
    self%sname = trim(adjustl(source%slice(pos(1)+1, pos(2)-1)))
    error = 0
  endif
  endsubroutine parse_name