camelcase Function

private elemental function camelcase(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~~camelcase~2~~CallsGraph proc~camelcase~2 string%camelcase none~join~8 string%join proc~camelcase~2->none~join~8 proc~capitalize~2 string%capitalize proc~camelcase~2->proc~capitalize~2 proc~split~2 string%split proc~camelcase~2->proc~split~2 proc~join_characters~2 string%join_characters none~join~8->proc~join_characters~2 proc~join_strings~2 string%join_strings none~join~8->proc~join_strings~2 proc~lower~2 string%lower proc~capitalize~2->proc~lower~2 proc~partition~2 string%partition proc~split~2->proc~partition~2 proc~unique~2 string%unique proc~split~2->proc~unique~2 proc~replace~2 string%replace proc~unique~2->proc~replace~2 proc~replace_one_occurrence~2 string%replace_one_occurrence proc~replace~2->proc~replace_one_occurrence~2

Source Code

   elemental function camelcase(self, sep)
   !< Return a string with all words capitalized without spaces.
   !<
   !< @note Multiple subsequent separators are collapsed to one occurence.
   !<
   !<```fortran
   !< type(string) :: astring
   !< astring = 'caMeL caSe var'
   !< print '(L1)', astring%camelcase()//''=='CamelCaseVar'
   !<```
   !=> T <<<
   class(string),             intent(in)           :: self      !< The string.
   character(kind=CK, len=*), intent(in), optional :: sep       !< Separator.
   type(string)                                    :: camelcase !< Camel case string.
   type(string), allocatable                       :: tokens(:) !< String tokens.

   if (allocated(self%raw)) then
     call self%split(tokens=tokens, sep=sep)
     tokens = tokens%capitalize()
     camelcase = camelcase%join(array=tokens)
   endif
   endfunction camelcase