decode Function

private elemental function decode(self, codec) result(decoded)

Arguments

TypeIntentOptionalAttributesName
class(string), intent(in) :: self
character(kind=CK,len=*), intent(in) :: codec

Return Value type(string)


Calls

proc~~decode~~CallsGraph proc~decode decode interface~b64_decode b64_decode proc~decode->interface~b64_decode proc~b64_decode_r4 b64_decode_R4 interface~b64_decode->proc~b64_decode_r4 proc~b64_decode_i2 b64_decode_I2 interface~b64_decode->proc~b64_decode_i2 proc~b64_decode_i8 b64_decode_I8 interface~b64_decode->proc~b64_decode_i8 proc~b64_decode_r8_a b64_decode_R8_a interface~b64_decode->proc~b64_decode_r8_a proc~b64_decode_i4 b64_decode_I4 interface~b64_decode->proc~b64_decode_i4 proc~b64_decode_i1 b64_decode_I1 interface~b64_decode->proc~b64_decode_i1 proc~b64_decode_string b64_decode_string interface~b64_decode->proc~b64_decode_string proc~b64_decode_r8 b64_decode_R8 interface~b64_decode->proc~b64_decode_r8 proc~b64_decode_r4_a b64_decode_R4_a interface~b64_decode->proc~b64_decode_r4_a proc~b64_decode_i8_a b64_decode_I8_a interface~b64_decode->proc~b64_decode_i8_a proc~b64_decode_i4_a b64_decode_I4_a interface~b64_decode->proc~b64_decode_i4_a proc~b64_decode_i2_a b64_decode_I2_a interface~b64_decode->proc~b64_decode_i2_a proc~b64_decode_i1_a b64_decode_I1_a interface~b64_decode->proc~b64_decode_i1_a proc~b64_decode_string_a b64_decode_string_a interface~b64_decode->proc~b64_decode_string_a proc~decode_bits decode_bits proc~b64_decode_r4->proc~decode_bits proc~b64_decode_i2->proc~decode_bits proc~b64_decode_i8->proc~decode_bits proc~b64_decode_r8_a->proc~decode_bits proc~b64_decode_i4->proc~decode_bits proc~b64_decode_i1->proc~decode_bits proc~b64_decode_string->proc~decode_bits interface~byte_size byte_size proc~b64_decode_string->interface~byte_size proc~b64_decode_r8->proc~decode_bits proc~b64_decode_r4_a->proc~decode_bits proc~b64_decode_i8_a->proc~decode_bits proc~b64_decode_i4_a->proc~decode_bits proc~b64_decode_i2_a->proc~decode_bits proc~b64_decode_i1_a->proc~decode_bits proc~b64_decode_string_a->proc~decode_bits proc~b64_decode_string_a->interface~byte_size proc~byte_size_i1p byte_size_I1P interface~byte_size->proc~byte_size_i1p proc~byte_size_r4p byte_size_R4P interface~byte_size->proc~byte_size_r4p proc~byte_size_i4p byte_size_I4P interface~byte_size->proc~byte_size_i4p proc~byte_size_i8p byte_size_I8P interface~byte_size->proc~byte_size_i8p proc~byte_size_r8p byte_size_R8P interface~byte_size->proc~byte_size_r8p proc~byte_size_i2p byte_size_I2P interface~byte_size->proc~byte_size_i2p proc~byte_size_chr byte_size_chr interface~byte_size->proc~byte_size_chr

Contents

Source Code


Source Code

   elemental function decode(self, codec) result(decoded)
   !< Return a string decoded accordingly the codec.
   !<
   !< @note Only BASE64 codec is currently available.
   !<
   !<```fortran
   !< type(string) :: astring
   !< astring = 'SG93IGFyZSB5b3U/'
   !< print '(L1)', astring%decode(codec='base64')//''=='How are you?'
   !<```
   !=> T <<<
   class(string),             intent(in) :: self    !< The string.
   character(kind=CK, len=*), intent(in) :: codec   !< Encoding codec.
   type(string)                          :: decoded !< Decoded string.
   type(string)                          :: codec_u !< Encoding codec in upper case string.

   if (allocated(self%raw)) then
     decoded = self
     codec_u = codec
     select case(codec_u%upper()//'')
     case('BASE64')
       call b64_decode(code=self%raw, s=decoded%raw)
     endselect
     decoded = decoded%strip(remove_nulls=.true.)
   endif
   endfunction decode