Packages
evision
0.1.32
1.0.1-rc.0
1.0.0
1.0.0-rc.0
0.2.17
0.2.17-rc2
0.2.17-rc1
0.2.16
0.2.16-pre.2
0.2.16-pre
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.2-rc2
0.2.1
0.2.0
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.32
retired
0.1.31
0.1.30
0.1.29
0.1.28
0.1.27
0.1.26
0.1.26-rc3
0.1.26-rc2
0.1.26-rc1
0.1.26-rc0
0.1.25
0.1.24
0.1.23
0.1.22
0.1.21
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
OpenCV-Erlang/Elixir binding.
Retired package: Release invalid - incorrect source files
Current section
Files
Jump to
Current section
Files
src/evision_internal_structurise.erl
-module(evision_internal_structurise).
-export([to_struct/1, from_struct/1]).
to_struct(Ret) when is_map(Ret) ->
case maps:is_key(class, Ret) of
true ->
Class = maps:get(class, Ret),
Module = list_to_atom(string:to_lower(io_lib:fwrite("evision_~s", [Class]))),
case erlang:function_exported(Module, '__to_struct__', 1) of
true ->
Module:'__to_struct__'(Ret);
false ->
Ret
end;
false ->
Ret
end;
to_struct(Tuple) when is_tuple(Tuple) ->
List = [to_struct(element(I, Tuple)) || I <- lists:seq(1, tuple_size(Tuple))],
list_to_tuple(List);
to_struct(List) when is_list(List) ->
lists:map(fun (X) -> to_struct(X) end, List);
to_struct(PassThrough) ->
PassThrough.
from_struct(MaybeRecord) when is_tuple(MaybeRecord), tuple_size(MaybeRecord) > 0, is_atom(element(1, MaybeRecord)) ->
RecordName = element(1, MaybeRecord),
case erlang:function_exported(RecordName, '__from_struct__', 1) of
true ->
RecordName:'__from_struct__'(MaybeRecord);
false ->
List = [to_struct(element(I, MaybeRecord)) || I <- lists:seq(1, tuple_size(MaybeRecord))],
list_to_tuple(List)
end;
from_struct(Tuple) when is_tuple(Tuple) ->
List = [to_struct(element(I, Tuple)) || I <- lists:seq(1, tuple_size(Tuple))],
list_to_tuple(List);
from_struct(List) when is_list(List) ->
lists:map(fun (X) -> from_struct(X) end, List);
from_struct(PassThrough) ->
PassThrough.