-
Notifications
You must be signed in to change notification settings - Fork 1
Advanced Usage
Now that you've gone through the quickstart tutorial, here is a more fleshed out guide on the details of this library.
The user must be aware that Fortran does not support unsigned integers, while MessagePack uses them routinely in its specification. This library has utilities to deal with them, but in specific circumstances the user must deal with them on their own. See the Integer Format Family for more details.
The binary & extension format family store values with the signed byte type, whereas they are truly unsigned.
The msgpack class will attempt to identify whether the host system is little endian or big endian during run-time. This library does not support other endian architectures.
This library supports the timestamp format, and custom user extensions via registration of callbacks.
All data types extend from mp_value_type. mp_arr_type and mp_map_type rely on mp_value_type_ptr to store messagepack values of any kind.
type :: mp_value_type_ptr
class(mp_value_type), allocatable :: obj
end typemessagepack exports these logical functions for checking which format family that a mp_value_type object truly is:
function is_nil(obj) result(res) ! @returns whether the object is `mp_nil_type`
function is_bool(obj) result(res) ! @returns whether the object is `mp_bool_type`
function is_int(obj) result(res) ! @returns whether the object is a `mp_int_type`
function is_float(obj) result(res) ! @returns whether the object is a `mp_float_type`
function is_str(obj) result(res) ! @returns whether the object is a `mp_str_type`
function is_bin(obj) result(res) ! @returns whether the object is a `mp_bin_type`
function is_arr(obj) result(res) ! @returns whether the object is a `mp_arr_type`
function is_map(obj) result(res) ! @returns whether the object is a `mp_map_type`
function is_ext(obj) result(res) ! @returns whether the object is a `mp_ext_type`
function is_timestamp(obj) result(res) ! @returns whether the object is a `mp_timestamp_type`type, extends(mp_value_type) :: mp_nil_type
! nothing here
...
end typetype, extends(mp_value_type) :: mp_bool_type
logical :: value
...
end typetype, extends(mp_value_type) :: mp_int_type
integer(kind=int64) :: value
logical :: unsigned_64 = .false.
...
end typetype, extends(mp_value_type) :: mp_float_type
real(kind=real64) :: f64value
real(kind=real32) :: f32value
logical :: is_64 = .true.
...
end typetype, extends(mp_value_type) :: mp_str_type
character(:), allocatable :: value
...
end typetype, extends(mp_value_type) :: mp_bin_type
byte, allocatable, dimension(:) :: values
...
end typetype, extends(mp_value_type) :: mp_arr_type
class(mp_value_type_ptr), allocatable, dimension(:) :: values
...
end typetype, extends(mp_value_type) :: mp_map_type
class(mp_value_type_ptr), allocatable, dimension(:) :: keys
class(mp_value_type_ptr), allocatable, dimension(:) :: values
integer(kind=int64) :: ne
...
end typetype, extends(mp_value_type) :: mp_ext_type
integer :: exttype
byte, allocatable, dimension(:) :: values
...
end typetype, extends(mp_value_type) :: mp_timestamp_type
integer(kind=int64) :: seconds
integer(kind=int64) :: nanoseconds
...
end type