format_uuid Function

private function format_uuid(uuid_in)

Convert an array of 1-byte integers into UUID format: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Arguments

Type IntentOptional Attributes Name
integer(kind=c_signed_char), intent(in), dimension(16) :: uuid_in

Return Value character(len=uuid_len)


Contents

Source Code


Source Code

  function format_uuid(uuid_in)
    character(len=uuid_len) :: format_uuid
    character(2), dimension(0:15) :: uuid_as_hex
    character(32) :: uuid_unformatted
    integer(c_signed_char), dimension(16), intent(in) :: uuid_in
    integer :: i

    uuid_as_hex = c_signed_char_to_hex(uuid_in)

    do i = 0, 15
      uuid_unformatted(2*i+1:2*i+2) = uuid_as_hex(i)
    end do

    format_uuid = &
         uuid_unformatted(1:8) // "-" // uuid_unformatted(9:12) // "-" // &
         uuid_unformatted(13:16) // "-" // uuid_unformatted(17:20) // "-" //&
         uuid_unformatted(21:)
  end function format_uuid