camelcase Function

private elemental function camelcase(self, sep)

Return a string with all words capitalized without spaces.

 type(string) :: astring
 astring = 'caMeL caSe var'
 print '(L1)', astring%camelcase()//''=='CamelCaseVar'

Type Bound

string

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

character(kind=CK, len=*), intent(in), optional :: sep

Separator.

Return Value type(string)

Camel case string.


Calls

proc~~camelcase~~CallsGraph proc~camelcase stringifor_string_t::string%camelcase join join proc~camelcase->join proc~capitalize stringifor_string_t::string%capitalize proc~camelcase->proc~capitalize proc~split stringifor_string_t::string%split proc~camelcase->proc~split proc~lower stringifor_string_t::string%lower proc~capitalize->proc~lower raw raw proc~capitalize->raw proc~partition stringifor_string_t::string%partition proc~split->proc~partition proc~unique stringifor_string_t::string%unique proc~split->proc~unique proc~lower->raw proc~partition->raw proc~replace stringifor_string_t::string%replace proc~unique->proc~replace proc~replace_one_occurrence stringifor_string_t::string%replace_one_occurrence proc~replace->proc~replace_one_occurrence

Contents

Source Code


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