startcase Function

private elemental function startcase(self, sep)

Type Bound

string

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self
character(kind=CK, len=*), intent(in), optional :: sep

Return Value type(string)


Calls

proc~~startcase~~CallsGraph proc~startcase string%startcase none~join string%join proc~startcase->none~join proc~capitalize string%capitalize proc~startcase->proc~capitalize proc~split string%split proc~startcase->proc~split proc~join_characters string%join_characters none~join->proc~join_characters proc~join_strings string%join_strings none~join->proc~join_strings proc~lower string%lower proc~capitalize->proc~lower proc~partition string%partition proc~split->proc~partition proc~unique string%unique proc~split->proc~unique proc~replace string%replace proc~unique->proc~replace proc~replace_one_occurrence string%replace_one_occurrence proc~replace->proc~replace_one_occurrence

Called by

proc~~startcase~~CalledByGraph proc~startcase string%startcase program~volatile_doctest~1242 volatile_doctest program~volatile_doctest~1242->proc~startcase program~volatile_doctest~556 volatile_doctest program~volatile_doctest~556->proc~startcase

Source Code

   elemental function startcase(self, sep)
   !< Return a string with all words capitalized, e.g. title case.
   !<
   !< @note Multiple subsequent separators are collapsed to one occurence.
   !<
   !<```fortran
   !< type(string) :: astring
   !< logical      :: test_passed(1)
   !< astring = 'the Quick Brown fox Jumps over the Lazy Dog.'
   !< test_passed(1) = astring%startcase()//''=='The Quick Brown Fox Jumps Over The Lazy Dog.'
   !< print '(L1)', all(test_passed)
   !<```
   !=> T <<<
   class(string),             intent(in)           :: self      !< The string.
   character(kind=CK, len=*), intent(in), optional :: sep       !< Separator.
   type(string)                                    :: startcase !< Start case string.
   character(kind=CK, len=:), allocatable          :: sep_      !< Separator, default value.
   type(string), allocatable                       :: tokens(:) !< String tokens.

   if (allocated(self%raw)) then
      sep_ = SPACE ; if (present(sep)) sep_ = sep
      call self%split(tokens=tokens, sep=sep_)
      tokens = tokens%capitalize()
      startcase = startcase%join(array=tokens, sep=sep_)
   endif
   endfunction startcase