From 85b1e04a22e7564b702aa27c5f6467ad4d5f4416 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 15 Feb 2019 18:18:54 +0100 Subject: Re-organizing shr_ structs. --- src/shared/struct/map/shr_map_marker.erl | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/shared/struct/map/shr_map_marker.erl (limited to 'src/shared/struct/map/shr_map_marker.erl') diff --git a/src/shared/struct/map/shr_map_marker.erl b/src/shared/struct/map/shr_map_marker.erl new file mode 100644 index 0000000..35ba195 --- /dev/null +++ b/src/shared/struct/map/shr_map_marker.erl @@ -0,0 +1,52 @@ +-module(shr_map_marker). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type name() :: binary(). +-type type() :: 'none'. +-type collection() :: orddict:orddict(name(), type()). + +-export_type([name/0, type/0, collection/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + get/2, + empty_collection/0 + ] +). + +-export +( + [ + decode_collection/1, + encode_collection/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec get (name(), collection()) -> ('not_found' | {'ok', type()}). +get (Name, Collection) -> + case orddict:find(Name, Collection) of + error -> not_found; + Other -> Other + end. + +-spec empty_collection () -> collection(). +empty_collection () -> orddict:new(). + +-spec encode_collection (collection()) -> list(any()). +encode_collection (_Collection) -> []. + +-spec decode_collection (map()) -> collection(). +decode_collection (_Map) -> orddict:new(). -- cgit v1.2.3-70-g09d2