opentelemetry-erlang-contrib/instrumentation/opentelemetry_grpcbox/test/route_guide_pb.erl

2729 lines
103 KiB
Erlang
Raw Normal View History

%% -*- coding: utf-8 -*-
%% @private
%% Automatically generated, do not edit
%% Generated by gpb_compile version 4.7.3
-module(route_guide_pb).
-export([encode_msg/2, encode_msg/3]).
-export([decode_msg/2, decode_msg/3]).
-export([merge_msgs/3, merge_msgs/4]).
-export([verify_msg/2, verify_msg/3]).
-export([get_msg_defs/0]).
-export([get_msg_names/0]).
-export([get_group_names/0]).
-export([get_msg_or_group_names/0]).
-export([get_enum_names/0]).
-export([find_msg_def/1, fetch_msg_def/1]).
-export([find_enum_def/1, fetch_enum_def/1]).
-export([enum_symbol_by_value/2, enum_value_by_symbol/2]).
-export([get_service_names/0]).
-export([get_service_def/1]).
-export([get_rpc_names/1]).
-export([find_rpc_def/2, fetch_rpc_def/2]).
-export([fqbin_to_service_name/1]).
-export([service_name_to_fqbin/1]).
-export([fqbins_to_service_and_rpc_name/2]).
-export([service_and_rpc_name_to_fqbins/2]).
-export([fqbin_to_msg_name/1]).
-export([msg_name_to_fqbin/1]).
-export([fqbin_to_enum_name/1]).
-export([enum_name_to_fqbin/1]).
-export([get_package_name/0]).
-export([uses_packages/0]).
-export([source_basename/0]).
-export([get_all_source_basenames/0]).
-export([get_all_proto_names/0]).
-export([get_msg_containment/1]).
-export([get_pkg_containment/1]).
-export([get_service_containment/1]).
-export([get_rpc_containment/1]).
-export([get_enum_containment/1]).
-export([get_proto_by_msg_name_as_fqbin/1]).
-export([get_proto_by_service_name_as_fqbin/1]).
-export([get_proto_by_enum_name_as_fqbin/1]).
-export([get_protos_by_pkg_name_as_fqbin/1]).
-export([descriptor/0, descriptor/1]).
-export([gpb_version_as_string/0, gpb_version_as_list/0]).
%% enumerated types
-export_type([]).
%% message types
-type empty() ::
#{
}.
-type point() ::
#{latitude => integer(), % = 1, 32 bits
longitude => integer() % = 2, 32 bits
}.
-type rectangle() ::
#{lo => point(), % = 1
hi => point() % = 2
}.
-type feature() ::
#{name => iodata(), % = 1
location => point() % = 2
}.
-type route_note() ::
#{location => point(), % = 1
message => iodata() % = 2
}.
-type route_summary() ::
#{point_count => integer(), % = 1, 32 bits
feature_count => integer(), % = 2, 32 bits
distance => integer(), % = 3, 32 bits
elapsed_time => integer() % = 4, 32 bits
}.
-export_type(['empty'/0, 'point'/0, 'rectangle'/0, 'feature'/0, 'route_note'/0, 'route_summary'/0]).
-spec encode_msg(empty() | point() | rectangle() | feature() | route_note() | route_summary(), atom()) -> binary().
encode_msg(Msg, MsgName) when is_atom(MsgName) ->
encode_msg(Msg, MsgName, []).
-spec encode_msg(empty() | point() | rectangle() | feature() | route_note() | route_summary(), atom(), list()) -> binary().
encode_msg(Msg, MsgName, Opts) ->
case proplists:get_bool(verify, Opts) of
true -> verify_msg(Msg, MsgName, Opts);
false -> ok
end,
TrUserData = proplists:get_value(user_data, Opts),
case MsgName of
empty ->
encode_msg_empty(id(Msg, TrUserData), TrUserData);
point ->
encode_msg_point(id(Msg, TrUserData), TrUserData);
rectangle ->
encode_msg_rectangle(id(Msg, TrUserData), TrUserData);
feature ->
encode_msg_feature(id(Msg, TrUserData), TrUserData);
route_note ->
encode_msg_route_note(id(Msg, TrUserData), TrUserData);
route_summary ->
encode_msg_route_summary(id(Msg, TrUserData),
TrUserData)
end.
encode_msg_empty(_Msg, _TrUserData) -> <<>>.
encode_msg_point(Msg, TrUserData) ->
encode_msg_point(Msg, <<>>, TrUserData).
encode_msg_point(#{} = M, Bin, TrUserData) ->
B1 = case M of
#{latitude := F1} ->
begin
TrF1 = id(F1, TrUserData),
if TrF1 =:= 0 -> Bin;
true ->
e_type_int32(TrF1, <<Bin/binary, 8>>, TrUserData)
end
end;
_ -> Bin
end,
case M of
#{longitude := F2} ->
begin
TrF2 = id(F2, TrUserData),
if TrF2 =:= 0 -> B1;
true ->
e_type_int32(TrF2, <<B1/binary, 16>>, TrUserData)
end
end;
_ -> B1
end.
encode_msg_rectangle(Msg, TrUserData) ->
encode_msg_rectangle(Msg, <<>>, TrUserData).
encode_msg_rectangle(#{} = M, Bin, TrUserData) ->
B1 = case M of
#{lo := F1} ->
begin
TrF1 = id(F1, TrUserData),
if TrF1 =:= undefined -> Bin;
true ->
e_mfield_rectangle_lo(TrF1,
<<Bin/binary, 10>>,
TrUserData)
end
end;
_ -> Bin
end,
case M of
#{hi := F2} ->
begin
TrF2 = id(F2, TrUserData),
if TrF2 =:= undefined -> B1;
true ->
e_mfield_rectangle_hi(TrF2,
<<B1/binary, 18>>,
TrUserData)
end
end;
_ -> B1
end.
encode_msg_feature(Msg, TrUserData) ->
encode_msg_feature(Msg, <<>>, TrUserData).
encode_msg_feature(#{} = M, Bin, TrUserData) ->
B1 = case M of
#{name := F1} ->
begin
TrF1 = id(F1, TrUserData),
case is_empty_string(TrF1) of
true -> Bin;
false ->
e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData)
end
end;
_ -> Bin
end,
case M of
#{location := F2} ->
begin
TrF2 = id(F2, TrUserData),
if TrF2 =:= undefined -> B1;
true ->
e_mfield_feature_location(TrF2,
<<B1/binary, 18>>,
TrUserData)
end
end;
_ -> B1
end.
encode_msg_route_note(Msg, TrUserData) ->
encode_msg_route_note(Msg, <<>>, TrUserData).
encode_msg_route_note(#{} = M, Bin, TrUserData) ->
B1 = case M of
#{location := F1} ->
begin
TrF1 = id(F1, TrUserData),
if TrF1 =:= undefined -> Bin;
true ->
e_mfield_route_note_location(TrF1,
<<Bin/binary, 10>>,
TrUserData)
end
end;
_ -> Bin
end,
case M of
#{message := F2} ->
begin
TrF2 = id(F2, TrUserData),
case is_empty_string(TrF2) of
true -> B1;
false ->
e_type_string(TrF2, <<B1/binary, 18>>, TrUserData)
end
end;
_ -> B1
end.
encode_msg_route_summary(Msg, TrUserData) ->
encode_msg_route_summary(Msg, <<>>, TrUserData).
encode_msg_route_summary(#{} = M, Bin, TrUserData) ->
B1 = case M of
#{point_count := F1} ->
begin
TrF1 = id(F1, TrUserData),
if TrF1 =:= 0 -> Bin;
true ->
e_type_int32(TrF1, <<Bin/binary, 8>>, TrUserData)
end
end;
_ -> Bin
end,
B2 = case M of
#{feature_count := F2} ->
begin
TrF2 = id(F2, TrUserData),
if TrF2 =:= 0 -> B1;
true ->
e_type_int32(TrF2, <<B1/binary, 16>>, TrUserData)
end
end;
_ -> B1
end,
B3 = case M of
#{distance := F3} ->
begin
TrF3 = id(F3, TrUserData),
if TrF3 =:= 0 -> B2;
true ->
e_type_int32(TrF3, <<B2/binary, 24>>, TrUserData)
end
end;
_ -> B2
end,
case M of
#{elapsed_time := F4} ->
begin
TrF4 = id(F4, TrUserData),
if TrF4 =:= 0 -> B3;
true ->
e_type_int32(TrF4, <<B3/binary, 32>>, TrUserData)
end
end;
_ -> B3
end.
e_mfield_rectangle_lo(Msg, Bin, TrUserData) ->
SubBin = encode_msg_point(Msg, <<>>, TrUserData),
Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>.
e_mfield_rectangle_hi(Msg, Bin, TrUserData) ->
SubBin = encode_msg_point(Msg, <<>>, TrUserData),
Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>.
e_mfield_feature_location(Msg, Bin, TrUserData) ->
SubBin = encode_msg_point(Msg, <<>>, TrUserData),
Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>.
e_mfield_route_note_location(Msg, Bin, TrUserData) ->
SubBin = encode_msg_point(Msg, <<>>, TrUserData),
Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>.
-compile({nowarn_unused_function,e_type_sint/3}).
e_type_sint(Value, Bin, _TrUserData) when Value >= 0 ->
e_varint(Value * 2, Bin);
e_type_sint(Value, Bin, _TrUserData) ->
e_varint(Value * -2 - 1, Bin).
-compile({nowarn_unused_function,e_type_int32/3}).
e_type_int32(Value, Bin, _TrUserData)
when 0 =< Value, Value =< 127 ->
<<Bin/binary, Value>>;
e_type_int32(Value, Bin, _TrUserData) ->
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
e_varint(N, Bin).
-compile({nowarn_unused_function,e_type_int64/3}).
e_type_int64(Value, Bin, _TrUserData)
when 0 =< Value, Value =< 127 ->
<<Bin/binary, Value>>;
e_type_int64(Value, Bin, _TrUserData) ->
<<N:64/unsigned-native>> = <<Value:64/signed-native>>,
e_varint(N, Bin).
-compile({nowarn_unused_function,e_type_bool/3}).
e_type_bool(true, Bin, _TrUserData) ->
<<Bin/binary, 1>>;
e_type_bool(false, Bin, _TrUserData) ->
<<Bin/binary, 0>>;
e_type_bool(1, Bin, _TrUserData) -> <<Bin/binary, 1>>;
e_type_bool(0, Bin, _TrUserData) -> <<Bin/binary, 0>>.
-compile({nowarn_unused_function,e_type_string/3}).
e_type_string(S, Bin, _TrUserData) ->
Utf8 = unicode:characters_to_binary(S),
Bin2 = e_varint(byte_size(Utf8), Bin),
<<Bin2/binary, Utf8/binary>>.
-compile({nowarn_unused_function,e_type_bytes/3}).
e_type_bytes(Bytes, Bin, _TrUserData)
when is_binary(Bytes) ->
Bin2 = e_varint(byte_size(Bytes), Bin),
<<Bin2/binary, Bytes/binary>>;
e_type_bytes(Bytes, Bin, _TrUserData)
when is_list(Bytes) ->
BytesBin = iolist_to_binary(Bytes),
Bin2 = e_varint(byte_size(BytesBin), Bin),
<<Bin2/binary, BytesBin/binary>>.
-compile({nowarn_unused_function,e_type_fixed32/3}).
e_type_fixed32(Value, Bin, _TrUserData) ->
<<Bin/binary, Value:32/little>>.
-compile({nowarn_unused_function,e_type_sfixed32/3}).
e_type_sfixed32(Value, Bin, _TrUserData) ->
<<Bin/binary, Value:32/little-signed>>.
-compile({nowarn_unused_function,e_type_fixed64/3}).
e_type_fixed64(Value, Bin, _TrUserData) ->
<<Bin/binary, Value:64/little>>.
-compile({nowarn_unused_function,e_type_sfixed64/3}).
e_type_sfixed64(Value, Bin, _TrUserData) ->
<<Bin/binary, Value:64/little-signed>>.
-compile({nowarn_unused_function,e_type_float/3}).
e_type_float(V, Bin, _) when is_number(V) ->
<<Bin/binary, V:32/little-float>>;
e_type_float(infinity, Bin, _) ->
<<Bin/binary, 0:16, 128, 127>>;
e_type_float('-infinity', Bin, _) ->
<<Bin/binary, 0:16, 128, 255>>;
e_type_float(nan, Bin, _) ->
<<Bin/binary, 0:16, 192, 127>>.
-compile({nowarn_unused_function,e_type_double/3}).
e_type_double(V, Bin, _) when is_number(V) ->
<<Bin/binary, V:64/little-float>>;
e_type_double(infinity, Bin, _) ->
<<Bin/binary, 0:48, 240, 127>>;
e_type_double('-infinity', Bin, _) ->
<<Bin/binary, 0:48, 240, 255>>;
e_type_double(nan, Bin, _) ->
<<Bin/binary, 0:48, 248, 127>>.
-compile({nowarn_unused_function,e_varint/3}).
e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin).
-compile({nowarn_unused_function,e_varint/2}).
e_varint(N, Bin) when N =< 127 -> <<Bin/binary, N>>;
e_varint(N, Bin) ->
Bin2 = <<Bin/binary, (N band 127 bor 128)>>,
e_varint(N bsr 7, Bin2).
is_empty_string("") -> true;
is_empty_string(<<>>) -> true;
is_empty_string(L) when is_list(L) ->
not string_has_chars(L);
is_empty_string(B) when is_binary(B) -> false.
string_has_chars([C | _]) when is_integer(C) -> true;
string_has_chars([H | T]) ->
case string_has_chars(H) of
true -> true;
false -> string_has_chars(T)
end;
string_has_chars(B)
when is_binary(B), byte_size(B) =/= 0 ->
true;
string_has_chars(C) when is_integer(C) -> true;
string_has_chars(<<>>) -> false;
string_has_chars([]) -> false.
decode_msg(Bin, MsgName) when is_binary(Bin) ->
decode_msg(Bin, MsgName, []).
decode_msg(Bin, MsgName, Opts) when is_binary(Bin) ->
TrUserData = proplists:get_value(user_data, Opts),
decode_msg_1_catch(Bin, MsgName, TrUserData).
-ifdef('OTP_RELEASE').
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-else.
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
try decode_msg_2_doit(MsgName, Bin, TrUserData)
catch Class:Reason ->
StackTrace = erlang:get_stacktrace(),
error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
end.
-endif.
decode_msg_2_doit(empty, Bin, TrUserData) ->
id(decode_msg_empty(Bin, TrUserData), TrUserData);
decode_msg_2_doit(point, Bin, TrUserData) ->
id(decode_msg_point(Bin, TrUserData), TrUserData);
decode_msg_2_doit(rectangle, Bin, TrUserData) ->
id(decode_msg_rectangle(Bin, TrUserData), TrUserData);
decode_msg_2_doit(feature, Bin, TrUserData) ->
id(decode_msg_feature(Bin, TrUserData), TrUserData);
decode_msg_2_doit(route_note, Bin, TrUserData) ->
id(decode_msg_route_note(Bin, TrUserData), TrUserData);
decode_msg_2_doit(route_summary, Bin, TrUserData) ->
id(decode_msg_route_summary(Bin, TrUserData),
TrUserData).
decode_msg_empty(Bin, TrUserData) ->
dfp_read_field_def_empty(Bin, 0, 0, TrUserData).
dfp_read_field_def_empty(<<>>, 0, 0, _) -> #{};
dfp_read_field_def_empty(Other, Z1, Z2, TrUserData) ->
dg_read_field_def_empty(Other, Z1, Z2, TrUserData).
dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N,
Acc, TrUserData)
when N < 32 - 7 ->
dg_read_field_def_empty(Rest,
N + 7,
X bsl N + Acc,
TrUserData);
dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N,
Acc, TrUserData) ->
Key = X bsl N + Acc,
case Key band 7 of
0 -> skip_varint_empty(Rest, 0, 0, TrUserData);
1 -> skip_64_empty(Rest, 0, 0, TrUserData);
2 ->
skip_length_delimited_empty(Rest, 0, 0, TrUserData);
3 -> skip_group_empty(Rest, Key bsr 3, 0, TrUserData);
5 -> skip_32_empty(Rest, 0, 0, TrUserData)
end;
dg_read_field_def_empty(<<>>, 0, 0, _) -> #{}.
skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2,
TrUserData) ->
skip_varint_empty(Rest, Z1, Z2, TrUserData);
skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2,
TrUserData) ->
dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData).
skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>,
N, Acc, TrUserData)
when N < 57 ->
skip_length_delimited_empty(Rest,
N + 7,
X bsl N + Acc,
TrUserData);
skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>,
N, Acc, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_empty(Rest2, 0, 0, TrUserData).
skip_group_empty(Bin, FNum, Z2, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_empty(Rest, 0, Z2, TrUserData).
skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2,
TrUserData) ->
dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData).
skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2,
TrUserData) ->
dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData).
decode_msg_point(Bin, TrUserData) ->
dfp_read_field_def_point(Bin,
0,
0,
id(0, TrUserData),
id(0, TrUserData),
TrUserData).
dfp_read_field_def_point(<<8, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
d_field_point_latitude(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_point(<<16, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
d_field_point_longitude(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_point(<<>>, 0, 0, F@_1, F@_2, _) ->
#{latitude => F@_1, longitude => F@_2};
dfp_read_field_def_point(Other, Z1, Z2, F@_1, F@_2,
TrUserData) ->
dg_read_field_def_point(Other,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
dg_read_field_def_point(<<1:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData)
when N < 32 - 7 ->
dg_read_field_def_point(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
dg_read_field_def_point(<<0:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 ->
d_field_point_latitude(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
16 ->
d_field_point_longitude(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
_ ->
case Key band 7 of
0 ->
skip_varint_point(Rest, 0, 0, F@_1, F@_2, TrUserData);
1 -> skip_64_point(Rest, 0, 0, F@_1, F@_2, TrUserData);
2 ->
skip_length_delimited_point(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
3 ->
skip_group_point(Rest,
Key bsr 3,
0,
F@_1,
F@_2,
TrUserData);
5 -> skip_32_point(Rest, 0, 0, F@_1, F@_2, TrUserData)
end
end;
dg_read_field_def_point(<<>>, 0, 0, F@_1, F@_2, _) ->
#{latitude => F@_1, longitude => F@_2}.
d_field_point_latitude(<<1:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_point_latitude(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_point_latitude(<<0:1, X:7, Rest/binary>>, N,
Acc, _, F@_2, TrUserData) ->
{NewFValue, RestF} = {begin
<<Res:32/signed-native>> = <<(X bsl N +
Acc):32/unsigned-native>>,
id(Res, TrUserData)
end,
Rest},
dfp_read_field_def_point(RestF,
0,
0,
NewFValue,
F@_2,
TrUserData).
d_field_point_longitude(<<1:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_point_longitude(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_point_longitude(<<0:1, X:7, Rest/binary>>, N,
Acc, F@_1, _, TrUserData) ->
{NewFValue, RestF} = {begin
<<Res:32/signed-native>> = <<(X bsl N +
Acc):32/unsigned-native>>,
id(Res, TrUserData)
end,
Rest},
dfp_read_field_def_point(RestF,
0,
0,
F@_1,
NewFValue,
TrUserData).
skip_varint_point(<<1:1, _:7, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
skip_varint_point(Rest, Z1, Z2, F@_1, F@_2, TrUserData);
skip_varint_point(<<0:1, _:7, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
dfp_read_field_def_point(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_length_delimited_point(<<1:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
skip_length_delimited_point(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
skip_length_delimited_point(<<0:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_point(Rest2,
0,
0,
F@_1,
F@_2,
TrUserData).
skip_group_point(Bin, FNum, Z2, F@_1, F@_2,
TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_point(Rest,
0,
Z2,
F@_1,
F@_2,
TrUserData).
skip_32_point(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2,
TrUserData) ->
dfp_read_field_def_point(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_64_point(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2,
TrUserData) ->
dfp_read_field_def_point(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
decode_msg_rectangle(Bin, TrUserData) ->
dfp_read_field_def_rectangle(Bin,
0,
0,
id('$undef', TrUserData),
id('$undef', TrUserData),
TrUserData).
dfp_read_field_def_rectangle(<<10, Rest/binary>>, Z1,
Z2, F@_1, F@_2, TrUserData) ->
d_field_rectangle_lo(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_rectangle(<<18, Rest/binary>>, Z1,
Z2, F@_1, F@_2, TrUserData) ->
d_field_rectangle_hi(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_rectangle(<<>>, 0, 0, F@_1, F@_2,
_) ->
S1 = #{},
S2 = if F@_1 == '$undef' -> S1;
true -> S1#{lo => F@_1}
end,
if F@_2 == '$undef' -> S2;
true -> S2#{hi => F@_2}
end;
dfp_read_field_def_rectangle(Other, Z1, Z2, F@_1, F@_2,
TrUserData) ->
dg_read_field_def_rectangle(Other,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
dg_read_field_def_rectangle(<<1:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData)
when N < 32 - 7 ->
dg_read_field_def_rectangle(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
dg_read_field_def_rectangle(<<0:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData) ->
Key = X bsl N + Acc,
case Key of
10 ->
d_field_rectangle_lo(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
18 ->
d_field_rectangle_hi(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
_ ->
case Key band 7 of
0 ->
skip_varint_rectangle(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
1 ->
skip_64_rectangle(Rest, 0, 0, F@_1, F@_2, TrUserData);
2 ->
skip_length_delimited_rectangle(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
3 ->
skip_group_rectangle(Rest,
Key bsr 3,
0,
F@_1,
F@_2,
TrUserData);
5 ->
skip_32_rectangle(Rest, 0, 0, F@_1, F@_2, TrUserData)
end
end;
dg_read_field_def_rectangle(<<>>, 0, 0, F@_1, F@_2,
_) ->
S1 = #{},
S2 = if F@_1 == '$undef' -> S1;
true -> S1#{lo => F@_1}
end,
if F@_2 == '$undef' -> S2;
true -> S2#{hi => F@_2}
end.
d_field_rectangle_lo(<<1:1, X:7, Rest/binary>>, N, Acc,
F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_rectangle_lo(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_rectangle_lo(<<0:1, X:7, Rest/binary>>, N, Acc,
Prev, F@_2, TrUserData) ->
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bs:Len/binary, Rest2/binary>> = Rest,
{id(decode_msg_point(Bs, TrUserData), TrUserData),
Rest2}
end,
dfp_read_field_def_rectangle(RestF,
0,
0,
if Prev == '$undef' -> NewFValue;
true ->
merge_msg_point(Prev,
NewFValue,
TrUserData)
end,
F@_2,
TrUserData).
d_field_rectangle_hi(<<1:1, X:7, Rest/binary>>, N, Acc,
F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_rectangle_hi(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_rectangle_hi(<<0:1, X:7, Rest/binary>>, N, Acc,
F@_1, Prev, TrUserData) ->
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bs:Len/binary, Rest2/binary>> = Rest,
{id(decode_msg_point(Bs, TrUserData), TrUserData),
Rest2}
end,
dfp_read_field_def_rectangle(RestF,
0,
0,
F@_1,
if Prev == '$undef' -> NewFValue;
true ->
merge_msg_point(Prev,
NewFValue,
TrUserData)
end,
TrUserData).
skip_varint_rectangle(<<1:1, _:7, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
skip_varint_rectangle(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
skip_varint_rectangle(<<0:1, _:7, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
dfp_read_field_def_rectangle(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_length_delimited_rectangle(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
skip_length_delimited_rectangle(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
skip_length_delimited_rectangle(<<0:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_rectangle(Rest2,
0,
0,
F@_1,
F@_2,
TrUserData).
skip_group_rectangle(Bin, FNum, Z2, F@_1, F@_2,
TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_rectangle(Rest,
0,
Z2,
F@_1,
F@_2,
TrUserData).
skip_32_rectangle(<<_:32, Rest/binary>>, Z1, Z2, F@_1,
F@_2, TrUserData) ->
dfp_read_field_def_rectangle(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_64_rectangle(<<_:64, Rest/binary>>, Z1, Z2, F@_1,
F@_2, TrUserData) ->
dfp_read_field_def_rectangle(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
decode_msg_feature(Bin, TrUserData) ->
dfp_read_field_def_feature(Bin,
0,
0,
id(<<>>, TrUserData),
id('$undef', TrUserData),
TrUserData).
dfp_read_field_def_feature(<<10, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
d_field_feature_name(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_feature(<<18, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
d_field_feature_location(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_feature(<<>>, 0, 0, F@_1, F@_2, _) ->
S1 = #{name => F@_1},
if F@_2 == '$undef' -> S1;
true -> S1#{location => F@_2}
end;
dfp_read_field_def_feature(Other, Z1, Z2, F@_1, F@_2,
TrUserData) ->
dg_read_field_def_feature(Other,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
dg_read_field_def_feature(<<1:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData)
when N < 32 - 7 ->
dg_read_field_def_feature(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
dg_read_field_def_feature(<<0:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData) ->
Key = X bsl N + Acc,
case Key of
10 ->
d_field_feature_name(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
18 ->
d_field_feature_location(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
_ ->
case Key band 7 of
0 ->
skip_varint_feature(Rest, 0, 0, F@_1, F@_2, TrUserData);
1 ->
skip_64_feature(Rest, 0, 0, F@_1, F@_2, TrUserData);
2 ->
skip_length_delimited_feature(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
3 ->
skip_group_feature(Rest,
Key bsr 3,
0,
F@_1,
F@_2,
TrUserData);
5 -> skip_32_feature(Rest, 0, 0, F@_1, F@_2, TrUserData)
end
end;
dg_read_field_def_feature(<<>>, 0, 0, F@_1, F@_2, _) ->
S1 = #{name => F@_1},
if F@_2 == '$undef' -> S1;
true -> S1#{location => F@_2}
end.
d_field_feature_name(<<1:1, X:7, Rest/binary>>, N, Acc,
F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_feature_name(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_feature_name(<<0:1, X:7, Rest/binary>>, N, Acc,
_, F@_2, TrUserData) ->
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bytes:Len/binary, Rest2/binary>> = Rest,
{id(binary:copy(Bytes), TrUserData), Rest2}
end,
dfp_read_field_def_feature(RestF,
0,
0,
NewFValue,
F@_2,
TrUserData).
d_field_feature_location(<<1:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_feature_location(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_feature_location(<<0:1, X:7, Rest/binary>>, N,
Acc, F@_1, Prev, TrUserData) ->
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bs:Len/binary, Rest2/binary>> = Rest,
{id(decode_msg_point(Bs, TrUserData), TrUserData),
Rest2}
end,
dfp_read_field_def_feature(RestF,
0,
0,
F@_1,
if Prev == '$undef' -> NewFValue;
true ->
merge_msg_point(Prev,
NewFValue,
TrUserData)
end,
TrUserData).
skip_varint_feature(<<1:1, _:7, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
skip_varint_feature(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
skip_varint_feature(<<0:1, _:7, Rest/binary>>, Z1, Z2,
F@_1, F@_2, TrUserData) ->
dfp_read_field_def_feature(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_length_delimited_feature(<<1:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
skip_length_delimited_feature(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
skip_length_delimited_feature(<<0:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_feature(Rest2,
0,
0,
F@_1,
F@_2,
TrUserData).
skip_group_feature(Bin, FNum, Z2, F@_1, F@_2,
TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_feature(Rest,
0,
Z2,
F@_1,
F@_2,
TrUserData).
skip_32_feature(<<_:32, Rest/binary>>, Z1, Z2, F@_1,
F@_2, TrUserData) ->
dfp_read_field_def_feature(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_64_feature(<<_:64, Rest/binary>>, Z1, Z2, F@_1,
F@_2, TrUserData) ->
dfp_read_field_def_feature(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
decode_msg_route_note(Bin, TrUserData) ->
dfp_read_field_def_route_note(Bin,
0,
0,
id('$undef', TrUserData),
id(<<>>, TrUserData),
TrUserData).
dfp_read_field_def_route_note(<<10, Rest/binary>>, Z1,
Z2, F@_1, F@_2, TrUserData) ->
d_field_route_note_location(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_route_note(<<18, Rest/binary>>, Z1,
Z2, F@_1, F@_2, TrUserData) ->
d_field_route_note_message(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
dfp_read_field_def_route_note(<<>>, 0, 0, F@_1, F@_2,
_) ->
S1 = #{message => F@_2},
if F@_1 == '$undef' -> S1;
true -> S1#{location => F@_1}
end;
dfp_read_field_def_route_note(Other, Z1, Z2, F@_1, F@_2,
TrUserData) ->
dg_read_field_def_route_note(Other,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
dg_read_field_def_route_note(<<1:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData)
when N < 32 - 7 ->
dg_read_field_def_route_note(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
dg_read_field_def_route_note(<<0:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData) ->
Key = X bsl N + Acc,
case Key of
10 ->
d_field_route_note_location(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
18 ->
d_field_route_note_message(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
_ ->
case Key band 7 of
0 ->
skip_varint_route_note(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
1 ->
skip_64_route_note(Rest, 0, 0, F@_1, F@_2, TrUserData);
2 ->
skip_length_delimited_route_note(Rest,
0,
0,
F@_1,
F@_2,
TrUserData);
3 ->
skip_group_route_note(Rest,
Key bsr 3,
0,
F@_1,
F@_2,
TrUserData);
5 ->
skip_32_route_note(Rest, 0, 0, F@_1, F@_2, TrUserData)
end
end;
dg_read_field_def_route_note(<<>>, 0, 0, F@_1, F@_2,
_) ->
S1 = #{message => F@_2},
if F@_1 == '$undef' -> S1;
true -> S1#{location => F@_1}
end.
d_field_route_note_location(<<1:1, X:7, Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_route_note_location(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_route_note_location(<<0:1, X:7, Rest/binary>>,
N, Acc, Prev, F@_2, TrUserData) ->
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bs:Len/binary, Rest2/binary>> = Rest,
{id(decode_msg_point(Bs, TrUserData), TrUserData),
Rest2}
end,
dfp_read_field_def_route_note(RestF,
0,
0,
if Prev == '$undef' -> NewFValue;
true ->
merge_msg_point(Prev,
NewFValue,
TrUserData)
end,
F@_2,
TrUserData).
d_field_route_note_message(<<1:1, X:7, Rest/binary>>, N,
Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
d_field_route_note_message(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
d_field_route_note_message(<<0:1, X:7, Rest/binary>>, N,
Acc, F@_1, _, TrUserData) ->
{NewFValue, RestF} = begin
Len = X bsl N + Acc,
<<Bytes:Len/binary, Rest2/binary>> = Rest,
{id(binary:copy(Bytes), TrUserData), Rest2}
end,
dfp_read_field_def_route_note(RestF,
0,
0,
F@_1,
NewFValue,
TrUserData).
skip_varint_route_note(<<1:1, _:7, Rest/binary>>, Z1,
Z2, F@_1, F@_2, TrUserData) ->
skip_varint_route_note(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData);
skip_varint_route_note(<<0:1, _:7, Rest/binary>>, Z1,
Z2, F@_1, F@_2, TrUserData) ->
dfp_read_field_def_route_note(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_length_delimited_route_note(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData)
when N < 57 ->
skip_length_delimited_route_note(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
TrUserData);
skip_length_delimited_route_note(<<0:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_route_note(Rest2,
0,
0,
F@_1,
F@_2,
TrUserData).
skip_group_route_note(Bin, FNum, Z2, F@_1, F@_2,
TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_route_note(Rest,
0,
Z2,
F@_1,
F@_2,
TrUserData).
skip_32_route_note(<<_:32, Rest/binary>>, Z1, Z2, F@_1,
F@_2, TrUserData) ->
dfp_read_field_def_route_note(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
skip_64_route_note(<<_:64, Rest/binary>>, Z1, Z2, F@_1,
F@_2, TrUserData) ->
dfp_read_field_def_route_note(Rest,
Z1,
Z2,
F@_1,
F@_2,
TrUserData).
decode_msg_route_summary(Bin, TrUserData) ->
dfp_read_field_def_route_summary(Bin,
0,
0,
id(0, TrUserData),
id(0, TrUserData),
id(0, TrUserData),
id(0, TrUserData),
TrUserData).
dfp_read_field_def_route_summary(<<8, Rest/binary>>, Z1,
Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
d_field_route_summary_point_count(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
dfp_read_field_def_route_summary(<<16, Rest/binary>>,
Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
d_field_route_summary_feature_count(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
dfp_read_field_def_route_summary(<<24, Rest/binary>>,
Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
d_field_route_summary_distance(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
dfp_read_field_def_route_summary(<<32, Rest/binary>>,
Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
d_field_route_summary_elapsed_time(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
dfp_read_field_def_route_summary(<<>>, 0, 0, F@_1, F@_2,
F@_3, F@_4, _) ->
#{point_count => F@_1, feature_count => F@_2,
distance => F@_3, elapsed_time => F@_4};
dfp_read_field_def_route_summary(Other, Z1, Z2, F@_1,
F@_2, F@_3, F@_4, TrUserData) ->
dg_read_field_def_route_summary(Other,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData).
dg_read_field_def_route_summary(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
when N < 32 - 7 ->
dg_read_field_def_route_summary(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
dg_read_field_def_route_summary(<<0:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 ->
d_field_route_summary_point_count(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
16 ->
d_field_route_summary_feature_count(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
24 ->
d_field_route_summary_distance(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
32 ->
d_field_route_summary_elapsed_time(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
_ ->
case Key band 7 of
0 ->
skip_varint_route_summary(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
1 ->
skip_64_route_summary(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
2 ->
skip_length_delimited_route_summary(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
3 ->
skip_group_route_summary(Rest,
Key bsr 3,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
5 ->
skip_32_route_summary(Rest,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData)
end
end;
dg_read_field_def_route_summary(<<>>, 0, 0, F@_1, F@_2,
F@_3, F@_4, _) ->
#{point_count => F@_1, feature_count => F@_2,
distance => F@_3, elapsed_time => F@_4}.
d_field_route_summary_point_count(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
when N < 57 ->
d_field_route_summary_point_count(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
d_field_route_summary_point_count(<<0:1, X:7,
Rest/binary>>,
N, Acc, _, F@_2, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = {begin
<<Res:32/signed-native>> = <<(X bsl N +
Acc):32/unsigned-native>>,
id(Res, TrUserData)
end,
Rest},
dfp_read_field_def_route_summary(RestF,
0,
0,
NewFValue,
F@_2,
F@_3,
F@_4,
TrUserData).
d_field_route_summary_feature_count(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
when N < 57 ->
d_field_route_summary_feature_count(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
d_field_route_summary_feature_count(<<0:1, X:7,
Rest/binary>>,
N, Acc, F@_1, _, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = {begin
<<Res:32/signed-native>> = <<(X bsl N +
Acc):32/unsigned-native>>,
id(Res, TrUserData)
end,
Rest},
dfp_read_field_def_route_summary(RestF,
0,
0,
F@_1,
NewFValue,
F@_3,
F@_4,
TrUserData).
d_field_route_summary_distance(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
when N < 57 ->
d_field_route_summary_distance(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
d_field_route_summary_distance(<<0:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, _, F@_4, TrUserData) ->
{NewFValue, RestF} = {begin
<<Res:32/signed-native>> = <<(X bsl N +
Acc):32/unsigned-native>>,
id(Res, TrUserData)
end,
Rest},
dfp_read_field_def_route_summary(RestF,
0,
0,
F@_1,
F@_2,
NewFValue,
F@_4,
TrUserData).
d_field_route_summary_elapsed_time(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
when N < 57 ->
d_field_route_summary_elapsed_time(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
d_field_route_summary_elapsed_time(<<0:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, _, TrUserData) ->
{NewFValue, RestF} = {begin
<<Res:32/signed-native>> = <<(X bsl N +
Acc):32/unsigned-native>>,
id(Res, TrUserData)
end,
Rest},
dfp_read_field_def_route_summary(RestF,
0,
0,
F@_1,
F@_2,
F@_3,
NewFValue,
TrUserData).
skip_varint_route_summary(<<1:1, _:7, Rest/binary>>, Z1,
Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
skip_varint_route_summary(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
skip_varint_route_summary(<<0:1, _:7, Rest/binary>>, Z1,
Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
dfp_read_field_def_route_summary(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData).
skip_length_delimited_route_summary(<<1:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
when N < 57 ->
skip_length_delimited_route_summary(Rest,
N + 7,
X bsl N + Acc,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData);
skip_length_delimited_route_summary(<<0:1, X:7,
Rest/binary>>,
N, Acc, F@_1, F@_2, F@_3, F@_4,
TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_route_summary(Rest2,
0,
0,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData).
skip_group_route_summary(Bin, FNum, Z2, F@_1, F@_2,
F@_3, F@_4, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_route_summary(Rest,
0,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData).
skip_32_route_summary(<<_:32, Rest/binary>>, Z1, Z2,
F@_1, F@_2, F@_3, F@_4, TrUserData) ->
dfp_read_field_def_route_summary(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData).
skip_64_route_summary(<<_:64, Rest/binary>>, Z1, Z2,
F@_1, F@_2, F@_3, F@_4, TrUserData) ->
dfp_read_field_def_route_summary(Rest,
Z1,
Z2,
F@_1,
F@_2,
F@_3,
F@_4,
TrUserData).
read_group(Bin, FieldNum) ->
{NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum),
<<Group:NumBytes/binary, _:EndTagLen/binary, Rest/binary>> = Bin,
{Group, Rest}.
%% Like skipping over fields, but record the total length,
%% Each field is <(FieldNum bsl 3) bor FieldType> ++ <FieldValue>
%% Record the length because varints may be non-optimally encoded.
%%
%% Groups can be nested, but assume the same FieldNum cannot be nested
%% because group field numbers are shared with the rest of the fields
%% numbers. Thus we can search just for an group-end with the same
%% field number.
%%
%% (The only time the same group field number could occur would
%% be in a nested sub message, but then it would be inside a
%% length-delimited entry, which we skip-read by length.)
read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum)
when N < (32-7) ->
read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum);
read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen,
FieldNum) ->
Key = X bsl N + Acc,
TagLen1 = TagLen + 1,
case {Key bsr 3, Key band 7} of
{FieldNum, 4} -> % 4 = group_end
{NumBytes, TagLen1};
{_, 0} -> % 0 = varint
read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum);
{_, 1} -> % 1 = bits64
<<_:64, Tl2/binary>> = Tl,
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum);
{_, 2} -> % 2 = length_delimited
read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum);
{_, 3} -> % 3 = group_start
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
{_, 4} -> % 4 = group_end
read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
{_, 5} -> % 5 = bits32
<<_:32, Tl2/binary>> = Tl,
read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum)
end.
read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum)
when N < (64-7) ->
read_gr_vi(Tl, N+7, NumBytes+1, FieldNum);
read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) ->
read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum).
read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum)
when N < (64-7) ->
read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum);
read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) ->
Len = X bsl N + Acc,
NumBytes1 = NumBytes + 1,
<<_:Len/binary, Tl2/binary>> = Tl,
read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum).
merge_msgs(Prev, New, MsgName) when is_atom(MsgName) ->
merge_msgs(Prev, New, MsgName, []).
merge_msgs(Prev, New, MsgName, Opts) ->
TrUserData = proplists:get_value(user_data, Opts),
case MsgName of
empty -> merge_msg_empty(Prev, New, TrUserData);
point -> merge_msg_point(Prev, New, TrUserData);
rectangle -> merge_msg_rectangle(Prev, New, TrUserData);
feature -> merge_msg_feature(Prev, New, TrUserData);
route_note ->
merge_msg_route_note(Prev, New, TrUserData);
route_summary ->
merge_msg_route_summary(Prev, New, TrUserData)
end.
-compile({nowarn_unused_function,merge_msg_empty/3}).
merge_msg_empty(_Prev, New, _TrUserData) -> New.
-compile({nowarn_unused_function,merge_msg_point/3}).
merge_msg_point(PMsg, NMsg, _) ->
S1 = #{},
S2 = case {PMsg, NMsg} of
{_, #{latitude := NFlatitude}} ->
S1#{latitude => NFlatitude};
{#{latitude := PFlatitude}, _} ->
S1#{latitude => PFlatitude};
_ -> S1
end,
case {PMsg, NMsg} of
{_, #{longitude := NFlongitude}} ->
S2#{longitude => NFlongitude};
{#{longitude := PFlongitude}, _} ->
S2#{longitude => PFlongitude};
_ -> S2
end.
-compile({nowarn_unused_function,merge_msg_rectangle/3}).
merge_msg_rectangle(PMsg, NMsg, TrUserData) ->
S1 = #{},
S2 = case {PMsg, NMsg} of
{#{lo := PFlo}, #{lo := NFlo}} ->
S1#{lo => merge_msg_point(PFlo, NFlo, TrUserData)};
{_, #{lo := NFlo}} -> S1#{lo => NFlo};
{#{lo := PFlo}, _} -> S1#{lo => PFlo};
{_, _} -> S1
end,
case {PMsg, NMsg} of
{#{hi := PFhi}, #{hi := NFhi}} ->
S2#{hi => merge_msg_point(PFhi, NFhi, TrUserData)};
{_, #{hi := NFhi}} -> S2#{hi => NFhi};
{#{hi := PFhi}, _} -> S2#{hi => PFhi};
{_, _} -> S2
end.
-compile({nowarn_unused_function,merge_msg_feature/3}).
merge_msg_feature(PMsg, NMsg, TrUserData) ->
S1 = #{},
S2 = case {PMsg, NMsg} of
{_, #{name := NFname}} -> S1#{name => NFname};
{#{name := PFname}, _} -> S1#{name => PFname};
_ -> S1
end,
case {PMsg, NMsg} of
{#{location := PFlocation},
#{location := NFlocation}} ->
S2#{location =>
merge_msg_point(PFlocation, NFlocation, TrUserData)};
{_, #{location := NFlocation}} ->
S2#{location => NFlocation};
{#{location := PFlocation}, _} ->
S2#{location => PFlocation};
{_, _} -> S2
end.
-compile({nowarn_unused_function,merge_msg_route_note/3}).
merge_msg_route_note(PMsg, NMsg, TrUserData) ->
S1 = #{},
S2 = case {PMsg, NMsg} of
{#{location := PFlocation},
#{location := NFlocation}} ->
S1#{location =>
merge_msg_point(PFlocation, NFlocation, TrUserData)};
{_, #{location := NFlocation}} ->
S1#{location => NFlocation};
{#{location := PFlocation}, _} ->
S1#{location => PFlocation};
{_, _} -> S1
end,
case {PMsg, NMsg} of
{_, #{message := NFmessage}} ->
S2#{message => NFmessage};
{#{message := PFmessage}, _} ->
S2#{message => PFmessage};
_ -> S2
end.
-compile({nowarn_unused_function,merge_msg_route_summary/3}).
merge_msg_route_summary(PMsg, NMsg, _) ->
S1 = #{},
S2 = case {PMsg, NMsg} of
{_, #{point_count := NFpoint_count}} ->
S1#{point_count => NFpoint_count};
{#{point_count := PFpoint_count}, _} ->
S1#{point_count => PFpoint_count};
_ -> S1
end,
S3 = case {PMsg, NMsg} of
{_, #{feature_count := NFfeature_count}} ->
S2#{feature_count => NFfeature_count};
{#{feature_count := PFfeature_count}, _} ->
S2#{feature_count => PFfeature_count};
_ -> S2
end,
S4 = case {PMsg, NMsg} of
{_, #{distance := NFdistance}} ->
S3#{distance => NFdistance};
{#{distance := PFdistance}, _} ->
S3#{distance => PFdistance};
_ -> S3
end,
case {PMsg, NMsg} of
{_, #{elapsed_time := NFelapsed_time}} ->
S4#{elapsed_time => NFelapsed_time};
{#{elapsed_time := PFelapsed_time}, _} ->
S4#{elapsed_time => PFelapsed_time};
_ -> S4
end.
verify_msg(Msg, MsgName) when is_atom(MsgName) ->
verify_msg(Msg, MsgName, []).
verify_msg(Msg, MsgName, Opts) ->
TrUserData = proplists:get_value(user_data, Opts),
case MsgName of
empty -> v_msg_empty(Msg, [MsgName], TrUserData);
point -> v_msg_point(Msg, [MsgName], TrUserData);
rectangle ->
v_msg_rectangle(Msg, [MsgName], TrUserData);
feature -> v_msg_feature(Msg, [MsgName], TrUserData);
route_note ->
v_msg_route_note(Msg, [MsgName], TrUserData);
route_summary ->
v_msg_route_summary(Msg, [MsgName], TrUserData);
_ -> mk_type_error(not_a_known_message, Msg, [])
end.
-compile({nowarn_unused_function,v_msg_empty/3}).
-dialyzer({nowarn_function,v_msg_empty/3}).
v_msg_empty(#{} = M, Path, _) ->
lists:foreach(fun (OtherKey) ->
mk_type_error({extraneous_key, OtherKey}, M, Path)
end,
maps:keys(M)),
ok;
v_msg_empty(M, Path, _TrUserData) when is_map(M) ->
mk_type_error({missing_fields,
[] -- maps:keys(M),
empty},
M,
Path);
v_msg_empty(X, Path, _TrUserData) ->
mk_type_error({expected_msg, empty}, X, Path).
-compile({nowarn_unused_function,v_msg_point/3}).
-dialyzer({nowarn_function,v_msg_point/3}).
v_msg_point(#{} = M, Path, TrUserData) ->
case M of
#{latitude := F1} ->
v_type_int32(F1, [latitude | Path], TrUserData);
_ -> ok
end,
case M of
#{longitude := F2} ->
v_type_int32(F2, [longitude | Path], TrUserData);
_ -> ok
end,
lists:foreach(fun (latitude) -> ok;
(longitude) -> ok;
(OtherKey) ->
mk_type_error({extraneous_key, OtherKey}, M, Path)
end,
maps:keys(M)),
ok;
v_msg_point(M, Path, _TrUserData) when is_map(M) ->
mk_type_error({missing_fields,
[] -- maps:keys(M),
point},
M,
Path);
v_msg_point(X, Path, _TrUserData) ->
mk_type_error({expected_msg, point}, X, Path).
-compile({nowarn_unused_function,v_msg_rectangle/3}).
-dialyzer({nowarn_function,v_msg_rectangle/3}).
v_msg_rectangle(#{} = M, Path, TrUserData) ->
case M of
#{lo := F1} -> v_msg_point(F1, [lo | Path], TrUserData);
_ -> ok
end,
case M of
#{hi := F2} -> v_msg_point(F2, [hi | Path], TrUserData);
_ -> ok
end,
lists:foreach(fun (lo) -> ok;
(hi) -> ok;
(OtherKey) ->
mk_type_error({extraneous_key, OtherKey}, M, Path)
end,
maps:keys(M)),
ok;
v_msg_rectangle(M, Path, _TrUserData) when is_map(M) ->
mk_type_error({missing_fields,
[] -- maps:keys(M),
rectangle},
M,
Path);
v_msg_rectangle(X, Path, _TrUserData) ->
mk_type_error({expected_msg, rectangle}, X, Path).
-compile({nowarn_unused_function,v_msg_feature/3}).
-dialyzer({nowarn_function,v_msg_feature/3}).
v_msg_feature(#{} = M, Path, TrUserData) ->
case M of
#{name := F1} ->
v_type_string(F1, [name | Path], TrUserData);
_ -> ok
end,
case M of
#{location := F2} ->
v_msg_point(F2, [location | Path], TrUserData);
_ -> ok
end,
lists:foreach(fun (name) -> ok;
(location) -> ok;
(OtherKey) ->
mk_type_error({extraneous_key, OtherKey}, M, Path)
end,
maps:keys(M)),
ok;
v_msg_feature(M, Path, _TrUserData) when is_map(M) ->
mk_type_error({missing_fields,
[] -- maps:keys(M),
feature},
M,
Path);
v_msg_feature(X, Path, _TrUserData) ->
mk_type_error({expected_msg, feature}, X, Path).
-compile({nowarn_unused_function,v_msg_route_note/3}).
-dialyzer({nowarn_function,v_msg_route_note/3}).
v_msg_route_note(#{} = M, Path, TrUserData) ->
case M of
#{location := F1} ->
v_msg_point(F1, [location | Path], TrUserData);
_ -> ok
end,
case M of
#{message := F2} ->
v_type_string(F2, [message | Path], TrUserData);
_ -> ok
end,
lists:foreach(fun (location) -> ok;
(message) -> ok;
(OtherKey) ->
mk_type_error({extraneous_key, OtherKey}, M, Path)
end,
maps:keys(M)),
ok;
v_msg_route_note(M, Path, _TrUserData) when is_map(M) ->
mk_type_error({missing_fields,
[] -- maps:keys(M),
route_note},
M,
Path);
v_msg_route_note(X, Path, _TrUserData) ->
mk_type_error({expected_msg, route_note}, X, Path).
-compile({nowarn_unused_function,v_msg_route_summary/3}).
-dialyzer({nowarn_function,v_msg_route_summary/3}).
v_msg_route_summary(#{} = M, Path, TrUserData) ->
case M of
#{point_count := F1} ->
v_type_int32(F1, [point_count | Path], TrUserData);
_ -> ok
end,
case M of
#{feature_count := F2} ->
v_type_int32(F2, [feature_count | Path], TrUserData);
_ -> ok
end,
case M of
#{distance := F3} ->
v_type_int32(F3, [distance | Path], TrUserData);
_ -> ok
end,
case M of
#{elapsed_time := F4} ->
v_type_int32(F4, [elapsed_time | Path], TrUserData);
_ -> ok
end,
lists:foreach(fun (point_count) -> ok;
(feature_count) -> ok;
(distance) -> ok;
(elapsed_time) -> ok;
(OtherKey) ->
mk_type_error({extraneous_key, OtherKey}, M, Path)
end,
maps:keys(M)),
ok;
v_msg_route_summary(M, Path, _TrUserData)
when is_map(M) ->
mk_type_error({missing_fields,
[] -- maps:keys(M),
route_summary},
M,
Path);
v_msg_route_summary(X, Path, _TrUserData) ->
mk_type_error({expected_msg, route_summary}, X, Path).
-compile({nowarn_unused_function,v_type_int32/3}).
-dialyzer({nowarn_function,v_type_int32/3}).
v_type_int32(N, _Path, _TrUserData)
when -2147483648 =< N, N =< 2147483647 ->
ok;
v_type_int32(N, Path, _TrUserData) when is_integer(N) ->
mk_type_error({value_out_of_range, int32, signed, 32},
N,
Path);
v_type_int32(X, Path, _TrUserData) ->
mk_type_error({bad_integer, int32, signed, 32},
X,
Path).
-compile({nowarn_unused_function,v_type_string/3}).
-dialyzer({nowarn_function,v_type_string/3}).
v_type_string(S, Path, _TrUserData)
when is_list(S); is_binary(S) ->
try unicode:characters_to_binary(S) of
B when is_binary(B) -> ok;
{error, _, _} ->
mk_type_error(bad_unicode_string, S, Path)
catch
error:badarg ->
mk_type_error(bad_unicode_string, S, Path)
end;
v_type_string(X, Path, _TrUserData) ->
mk_type_error(bad_unicode_string, X, Path).
-compile({nowarn_unused_function,mk_type_error/3}).
-spec mk_type_error(_, _, list()) -> no_return().
mk_type_error(Error, ValueSeen, Path) ->
Path2 = prettify_path(Path),
erlang:error({gpb_type_error,
{Error, [{value, ValueSeen}, {path, Path2}]}}).
-compile({nowarn_unused_function,prettify_path/1}).
-dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
prettify_path(PathR) ->
list_to_atom(lists:append(lists:join(".",
lists:map(fun atom_to_list/1,
lists:reverse(PathR))))).
-compile({nowarn_unused_function,id/2}).
-compile({inline,id/2}).
id(X, _TrUserData) -> X.
-compile({nowarn_unused_function,v_ok/3}).
-compile({inline,v_ok/3}).
v_ok(_Value, _Path, _TrUserData) -> ok.
-compile({nowarn_unused_function,m_overwrite/3}).
-compile({inline,m_overwrite/3}).
m_overwrite(_Prev, New, _TrUserData) -> New.
-compile({nowarn_unused_function,cons/3}).
-compile({inline,cons/3}).
cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
-compile({nowarn_unused_function,lists_reverse/2}).
-compile({inline,lists_reverse/2}).
'lists_reverse'(L, _TrUserData) -> lists:reverse(L).
-compile({nowarn_unused_function,'erlang_++'/3}).
-compile({inline,'erlang_++'/3}).
'erlang_++'(A, B, _TrUserData) -> A ++ B.
get_msg_defs() ->
[{{msg, empty}, []},
{{msg, point},
[#{name => latitude, fnum => 1, rnum => 2,
type => int32, occurrence => optional, opts => []},
#{name => longitude, fnum => 2, rnum => 3,
type => int32, occurrence => optional, opts => []}]},
{{msg, rectangle},
[#{name => lo, fnum => 1, rnum => 2,
type => {msg, point}, occurrence => optional,
opts => []},
#{name => hi, fnum => 2, rnum => 3,
type => {msg, point}, occurrence => optional,
opts => []}]},
{{msg, feature},
[#{name => name, fnum => 1, rnum => 2, type => string,
occurrence => optional, opts => []},
#{name => location, fnum => 2, rnum => 3,
type => {msg, point}, occurrence => optional,
opts => []}]},
{{msg, route_note},
[#{name => location, fnum => 1, rnum => 2,
type => {msg, point}, occurrence => optional,
opts => []},
#{name => message, fnum => 2, rnum => 3, type => string,
occurrence => optional, opts => []}]},
{{msg, route_summary},
[#{name => point_count, fnum => 1, rnum => 2,
type => int32, occurrence => optional, opts => []},
#{name => feature_count, fnum => 2, rnum => 3,
type => int32, occurrence => optional, opts => []},
#{name => distance, fnum => 3, rnum => 4, type => int32,
occurrence => optional, opts => []},
#{name => elapsed_time, fnum => 4, rnum => 5,
type => int32, occurrence => optional, opts => []}]}].
get_msg_names() ->
[empty,
point,
rectangle,
feature,
route_note,
route_summary].
get_group_names() -> [].
get_msg_or_group_names() ->
[empty,
point,
rectangle,
feature,
route_note,
route_summary].
get_enum_names() -> [].
fetch_msg_def(MsgName) ->
case find_msg_def(MsgName) of
Fs when is_list(Fs) -> Fs;
error -> erlang:error({no_such_msg, MsgName})
end.
-spec fetch_enum_def(_) -> no_return().
fetch_enum_def(EnumName) ->
erlang:error({no_such_enum, EnumName}).
find_msg_def(empty) -> [];
find_msg_def(point) ->
[#{name => latitude, fnum => 1, rnum => 2,
type => int32, occurrence => optional, opts => []},
#{name => longitude, fnum => 2, rnum => 3,
type => int32, occurrence => optional, opts => []}];
find_msg_def(rectangle) ->
[#{name => lo, fnum => 1, rnum => 2,
type => {msg, point}, occurrence => optional,
opts => []},
#{name => hi, fnum => 2, rnum => 3,
type => {msg, point}, occurrence => optional,
opts => []}];
find_msg_def(feature) ->
[#{name => name, fnum => 1, rnum => 2, type => string,
occurrence => optional, opts => []},
#{name => location, fnum => 2, rnum => 3,
type => {msg, point}, occurrence => optional,
opts => []}];
find_msg_def(route_note) ->
[#{name => location, fnum => 1, rnum => 2,
type => {msg, point}, occurrence => optional,
opts => []},
#{name => message, fnum => 2, rnum => 3, type => string,
occurrence => optional, opts => []}];
find_msg_def(route_summary) ->
[#{name => point_count, fnum => 1, rnum => 2,
type => int32, occurrence => optional, opts => []},
#{name => feature_count, fnum => 2, rnum => 3,
type => int32, occurrence => optional, opts => []},
#{name => distance, fnum => 3, rnum => 4, type => int32,
occurrence => optional, opts => []},
#{name => elapsed_time, fnum => 4, rnum => 5,
type => int32, occurrence => optional, opts => []}];
find_msg_def(_) -> error.
find_enum_def(_) -> error.
-spec enum_symbol_by_value(_, _) -> no_return().
enum_symbol_by_value(E, V) ->
erlang:error({no_enum_defs, E, V}).
-spec enum_value_by_symbol(_, _) -> no_return().
enum_value_by_symbol(E, V) ->
erlang:error({no_enum_defs, E, V}).
get_service_names() -> ['routeguide.RouteGuide'].
get_service_def('routeguide.RouteGuide') ->
{{service, 'routeguide.RouteGuide'},
[#{name => 'GetFeature', input => point,
output => feature, input_stream => false,
output_stream => false, opts => []},
#{name => 'ListFeatures', input => rectangle,
output => feature, input_stream => false,
output_stream => true, opts => []},
#{name => 'RecordRoute', input => point,
output => route_summary, input_stream => true,
output_stream => false, opts => []},
#{name => 'RouteChat', input => route_note,
output => route_note, input_stream => true,
output_stream => true, opts => []},
#{name => 'GenerateError', input => empty,
output => empty, input_stream => false,
output_stream => false, opts => []},
#{name => 'StreamingGenerateError', input => empty,
output => empty, input_stream => false,
output_stream => true, opts => []}]};
get_service_def(_) -> error.
get_rpc_names('routeguide.RouteGuide') ->
['GetFeature',
'ListFeatures',
'RecordRoute',
'RouteChat',
'GenerateError',
'StreamingGenerateError'];
get_rpc_names(_) -> error.
find_rpc_def('routeguide.RouteGuide', RpcName) ->
'find_rpc_def_routeguide.RouteGuide'(RpcName);
find_rpc_def(_, _) -> error.
'find_rpc_def_routeguide.RouteGuide'('GetFeature') ->
#{name => 'GetFeature', input => point,
output => feature, input_stream => false,
output_stream => false, opts => []};
'find_rpc_def_routeguide.RouteGuide'('ListFeatures') ->
#{name => 'ListFeatures', input => rectangle,
output => feature, input_stream => false,
output_stream => true, opts => []};
'find_rpc_def_routeguide.RouteGuide'('RecordRoute') ->
#{name => 'RecordRoute', input => point,
output => route_summary, input_stream => true,
output_stream => false, opts => []};
'find_rpc_def_routeguide.RouteGuide'('RouteChat') ->
#{name => 'RouteChat', input => route_note,
output => route_note, input_stream => true,
output_stream => true, opts => []};
'find_rpc_def_routeguide.RouteGuide'('GenerateError') ->
#{name => 'GenerateError', input => empty,
output => empty, input_stream => false,
output_stream => false, opts => []};
'find_rpc_def_routeguide.RouteGuide'('StreamingGenerateError') ->
#{name => 'StreamingGenerateError', input => empty,
output => empty, input_stream => false,
output_stream => true, opts => []};
'find_rpc_def_routeguide.RouteGuide'(_) -> error.
fetch_rpc_def(ServiceName, RpcName) ->
case find_rpc_def(ServiceName, RpcName) of
Def when is_map(Def) -> Def;
error ->
erlang:error({no_such_rpc, ServiceName, RpcName})
end.
%% Convert a a fully qualified (ie with package name) service name
%% as a binary to a service name as an atom.
fqbin_to_service_name(<<"routeguide.RouteGuide">>) ->
'routeguide.RouteGuide';
fqbin_to_service_name(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a service name as an atom to a fully qualified
%% (ie with package name) name as a binary.
service_name_to_fqbin('routeguide.RouteGuide') ->
<<"routeguide.RouteGuide">>;
service_name_to_fqbin(X) ->
error({gpb_error, {badservice, X}}).
%% Convert a a fully qualified (ie with package name) service name
%% and an rpc name, both as binaries to a service name and an rpc
%% name, as atoms.
fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"GetFeature">>) ->
{'routeguide.RouteGuide', 'GetFeature'};
fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"ListFeatures">>) ->
{'routeguide.RouteGuide', 'ListFeatures'};
fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"RecordRoute">>) ->
{'routeguide.RouteGuide', 'RecordRoute'};
fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"RouteChat">>) ->
{'routeguide.RouteGuide', 'RouteChat'};
fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"GenerateError">>) ->
{'routeguide.RouteGuide', 'GenerateError'};
fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"StreamingGenerateError">>) ->
{'routeguide.RouteGuide', 'StreamingGenerateError'};
fqbins_to_service_and_rpc_name(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
%% Convert a service name and an rpc name, both as atoms,
%% to a fully qualified (ie with package name) service name and
%% an rpc name as binaries.
service_and_rpc_name_to_fqbins('routeguide.RouteGuide',
'GetFeature') ->
{<<"routeguide.RouteGuide">>, <<"GetFeature">>};
service_and_rpc_name_to_fqbins('routeguide.RouteGuide',
'ListFeatures') ->
{<<"routeguide.RouteGuide">>, <<"ListFeatures">>};
service_and_rpc_name_to_fqbins('routeguide.RouteGuide',
'RecordRoute') ->
{<<"routeguide.RouteGuide">>, <<"RecordRoute">>};
service_and_rpc_name_to_fqbins('routeguide.RouteGuide',
'RouteChat') ->
{<<"routeguide.RouteGuide">>, <<"RouteChat">>};
service_and_rpc_name_to_fqbins('routeguide.RouteGuide',
'GenerateError') ->
{<<"routeguide.RouteGuide">>, <<"GenerateError">>};
service_and_rpc_name_to_fqbins('routeguide.RouteGuide',
'StreamingGenerateError') ->
{<<"routeguide.RouteGuide">>, <<"StreamingGenerateError">>};
service_and_rpc_name_to_fqbins(S, R) ->
error({gpb_error, {badservice_or_rpc, {S, R}}}).
fqbin_to_msg_name(<<"routeguide.Empty">>) -> empty;
fqbin_to_msg_name(<<"routeguide.Point">>) -> point;
fqbin_to_msg_name(<<"routeguide.Rectangle">>) -> rectangle;
fqbin_to_msg_name(<<"routeguide.Feature">>) -> feature;
fqbin_to_msg_name(<<"routeguide.RouteNote">>) -> route_note;
fqbin_to_msg_name(<<"routeguide.RouteSummary">>) -> route_summary;
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
msg_name_to_fqbin(empty) -> <<"routeguide.Empty">>;
msg_name_to_fqbin(point) -> <<"routeguide.Point">>;
msg_name_to_fqbin(rectangle) -> <<"routeguide.Rectangle">>;
msg_name_to_fqbin(feature) -> <<"routeguide.Feature">>;
msg_name_to_fqbin(route_note) -> <<"routeguide.RouteNote">>;
msg_name_to_fqbin(route_summary) -> <<"routeguide.RouteSummary">>;
msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}).
-spec fqbin_to_enum_name(_) -> no_return().
fqbin_to_enum_name(E) ->
error({gpb_error, {badenum, E}}).
-spec enum_name_to_fqbin(_) -> no_return().
enum_name_to_fqbin(E) ->
error({gpb_error, {badenum, E}}).
get_package_name() -> routeguide.
%% Whether or not the message names
%% are prepended with package name or not.
uses_packages() -> true.
source_basename() -> "route_guide.proto".
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned with extension,
%% see get_all_proto_names/0 for a version that returns
%% the basenames sans extension
get_all_source_basenames() -> ["route_guide.proto"].
%% Retrieve all proto file names, also imported ones.
%% The order is top-down. The first element is always the main
%% source file. The files are returned sans .proto extension,
%% to make it easier to use them with the various get_xyz_containment
%% functions.
get_all_proto_names() -> ["route_guide"].
get_msg_containment("route_guide") ->
[empty,
feature,
point,
rectangle,
route_note,
route_summary];
get_msg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_pkg_containment("route_guide") -> routeguide;
get_pkg_containment(P) ->
error({gpb_error, {badproto, P}}).
get_service_containment("route_guide") ->
['routeguide.RouteGuide'];
get_service_containment(P) ->
error({gpb_error, {badproto, P}}).
get_rpc_containment("route_guide") ->
[{'routeguide.RouteGuide', 'GetFeature'},
{'routeguide.RouteGuide', 'ListFeatures'},
{'routeguide.RouteGuide', 'RecordRoute'},
{'routeguide.RouteGuide', 'RouteChat'},
{'routeguide.RouteGuide', 'GenerateError'},
{'routeguide.RouteGuide', 'StreamingGenerateError'}];
get_rpc_containment(P) ->
error({gpb_error, {badproto, P}}).
get_enum_containment("route_guide") -> [];
get_enum_containment(P) ->
error({gpb_error, {badproto, P}}).
get_proto_by_msg_name_as_fqbin(<<"routeguide.Point">>) ->
"route_guide";
get_proto_by_msg_name_as_fqbin(<<"routeguide.RouteNote">>) ->
"route_guide";
get_proto_by_msg_name_as_fqbin(<<"routeguide.Rectangle">>) ->
"route_guide";
get_proto_by_msg_name_as_fqbin(<<"routeguide.Feature">>) ->
"route_guide";
get_proto_by_msg_name_as_fqbin(<<"routeguide.RouteSummary">>) ->
"route_guide";
get_proto_by_msg_name_as_fqbin(<<"routeguide.Empty">>) ->
"route_guide";
get_proto_by_msg_name_as_fqbin(E) ->
error({gpb_error, {badmsg, E}}).
get_proto_by_service_name_as_fqbin(<<"routeguide.RouteGuide">>) ->
"route_guide";
get_proto_by_service_name_as_fqbin(E) ->
error({gpb_error, {badservice, E}}).
-spec get_proto_by_enum_name_as_fqbin(_) -> no_return().
get_proto_by_enum_name_as_fqbin(E) ->
error({gpb_error, {badenum, E}}).
get_protos_by_pkg_name_as_fqbin(<<"routeguide">>) ->
["route_guide"];
get_protos_by_pkg_name_as_fqbin(E) ->
error({gpb_error, {badpkg, E}}).
descriptor() ->
<<10, 160, 6, 10, 28, 114, 111, 117, 116, 101, 103, 117,
105, 100, 101, 47, 114, 111, 117, 116, 101, 95, 103,
117, 105, 100, 101, 46, 112, 114, 111, 116, 111, 18, 10,
114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 34, 7,
10, 5, 69, 109, 112, 116, 121, 34, 60, 10, 7, 70, 101,
97, 116, 117, 114, 101, 18, 12, 10, 4, 110, 97, 109,
101, 24, 1, 32, 1, 40, 9, 18, 35, 10, 8, 108, 111, 99,
97, 116, 105, 111, 110, 24, 2, 32, 1, 40, 11, 50, 17,
46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101,
46, 80, 111, 105, 110, 116, 34, 44, 10, 5, 80, 111, 105,
110, 116, 18, 16, 10, 8, 108, 97, 116, 105, 116, 117,
100, 101, 24, 1, 32, 1, 40, 5, 18, 17, 10, 9, 108, 111,
110, 103, 105, 116, 117, 100, 101, 24, 2, 32, 1, 40, 5,
34, 73, 10, 9, 82, 101, 99, 116, 97, 110, 103, 108, 101,
18, 29, 10, 2, 108, 111, 24, 1, 32, 1, 40, 11, 50, 17,
46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101,
46, 80, 111, 105, 110, 116, 18, 29, 10, 2, 104, 105, 24,
2, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101,
103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 34,
65, 10, 9, 82, 111, 117, 116, 101, 78, 111, 116, 101,
18, 35, 10, 8, 108, 111, 99, 97, 116, 105, 111, 110, 24,
1, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101,
103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 18,
15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32,
1, 40, 9, 34, 98, 10, 12, 82, 111, 117, 116, 101, 83,
117, 109, 109, 97, 114, 121, 18, 19, 10, 11, 112, 111,
105, 110, 116, 95, 99, 111, 117, 110, 116, 24, 1, 32, 1,
40, 5, 18, 21, 10, 13, 102, 101, 97, 116, 117, 114, 101,
95, 99, 111, 117, 110, 116, 24, 2, 32, 1, 40, 5, 18, 16,
10, 8, 100, 105, 115, 116, 97, 110, 99, 101, 24, 3, 32,
1, 40, 5, 18, 20, 10, 12, 101, 108, 97, 112, 115, 101,
100, 95, 116, 105, 109, 101, 24, 4, 32, 1, 40, 5, 50,
132, 3, 10, 10, 82, 111, 117, 116, 101, 71, 117, 105,
100, 101, 18, 56, 10, 10, 71, 101, 116, 70, 101, 97,
116, 117, 114, 101, 18, 17, 46, 114, 111, 117, 116, 101,
103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 26,
19, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100,
101, 46, 70, 101, 97, 116, 117, 114, 101, 40, 0, 48, 0,
18, 62, 10, 12, 76, 105, 115, 116, 70, 101, 97, 116,
117, 114, 101, 115, 18, 21, 46, 114, 111, 117, 116, 101,
103, 117, 105, 100, 101, 46, 82, 101, 99, 116, 97, 110,
103, 108, 101, 26, 19, 46, 114, 111, 117, 116, 101, 103,
117, 105, 100, 101, 46, 70, 101, 97, 116, 117, 114, 101,
40, 0, 48, 0, 18, 62, 10, 11, 82, 101, 99, 111, 114,
100, 82, 111, 117, 116, 101, 18, 17, 46, 114, 111, 117,
116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105,
110, 116, 26, 24, 46, 114, 111, 117, 116, 101, 103, 117,
105, 100, 101, 46, 82, 111, 117, 116, 101, 83, 117, 109,
109, 97, 114, 121, 40, 0, 48, 0, 18, 61, 10, 9, 82, 111,
117, 116, 101, 67, 104, 97, 116, 18, 21, 46, 114, 111,
117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111,
117, 116, 101, 78, 111, 116, 101, 26, 21, 46, 114, 111,
117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111,
117, 116, 101, 78, 111, 116, 101, 40, 0, 48, 0, 18, 57,
10, 13, 71, 101, 110, 101, 114, 97, 116, 101, 69, 114,
114, 111, 114, 18, 17, 46, 114, 111, 117, 116, 101, 103,
117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 26, 17,
46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101,
46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 66, 10,
22, 83, 116, 114, 101, 97, 109, 105, 110, 103, 71, 101,
110, 101, 114, 97, 116, 101, 69, 114, 114, 111, 114, 18,
17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100,
101, 46, 69, 109, 112, 116, 121, 26, 17, 46, 114, 111,
117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109,
112, 116, 121, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116,
111, 51>>.
descriptor("route_guide") ->
<<10, 28, 114, 111, 117, 116, 101, 103, 117, 105, 100,
101, 47, 114, 111, 117, 116, 101, 95, 103, 117, 105,
100, 101, 46, 112, 114, 111, 116, 111, 18, 10, 114, 111,
117, 116, 101, 103, 117, 105, 100, 101, 34, 7, 10, 5,
69, 109, 112, 116, 121, 34, 60, 10, 7, 70, 101, 97, 116,
117, 114, 101, 18, 12, 10, 4, 110, 97, 109, 101, 24, 1,
32, 1, 40, 9, 18, 35, 10, 8, 108, 111, 99, 97, 116, 105,
111, 110, 24, 2, 32, 1, 40, 11, 50, 17, 46, 114, 111,
117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111,
105, 110, 116, 34, 44, 10, 5, 80, 111, 105, 110, 116,
18, 16, 10, 8, 108, 97, 116, 105, 116, 117, 100, 101,
24, 1, 32, 1, 40, 5, 18, 17, 10, 9, 108, 111, 110, 103,
105, 116, 117, 100, 101, 24, 2, 32, 1, 40, 5, 34, 73,
10, 9, 82, 101, 99, 116, 97, 110, 103, 108, 101, 18, 29,
10, 2, 108, 111, 24, 1, 32, 1, 40, 11, 50, 17, 46, 114,
111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80,
111, 105, 110, 116, 18, 29, 10, 2, 104, 105, 24, 2, 32,
1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103,
117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 34, 65,
10, 9, 82, 111, 117, 116, 101, 78, 111, 116, 101, 18,
35, 10, 8, 108, 111, 99, 97, 116, 105, 111, 110, 24, 1,
32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103,
117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 18, 15,
10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1,
40, 9, 34, 98, 10, 12, 82, 111, 117, 116, 101, 83, 117,
109, 109, 97, 114, 121, 18, 19, 10, 11, 112, 111, 105,
110, 116, 95, 99, 111, 117, 110, 116, 24, 1, 32, 1, 40,
5, 18, 21, 10, 13, 102, 101, 97, 116, 117, 114, 101, 95,
99, 111, 117, 110, 116, 24, 2, 32, 1, 40, 5, 18, 16, 10,
8, 100, 105, 115, 116, 97, 110, 99, 101, 24, 3, 32, 1,
40, 5, 18, 20, 10, 12, 101, 108, 97, 112, 115, 101, 100,
95, 116, 105, 109, 101, 24, 4, 32, 1, 40, 5, 50, 132, 3,
10, 10, 82, 111, 117, 116, 101, 71, 117, 105, 100, 101,
18, 56, 10, 10, 71, 101, 116, 70, 101, 97, 116, 117,
114, 101, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117,
105, 100, 101, 46, 80, 111, 105, 110, 116, 26, 19, 46,
114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46,
70, 101, 97, 116, 117, 114, 101, 40, 0, 48, 0, 18, 62,
10, 12, 76, 105, 115, 116, 70, 101, 97, 116, 117, 114,
101, 115, 18, 21, 46, 114, 111, 117, 116, 101, 103, 117,
105, 100, 101, 46, 82, 101, 99, 116, 97, 110, 103, 108,
101, 26, 19, 46, 114, 111, 117, 116, 101, 103, 117, 105,
100, 101, 46, 70, 101, 97, 116, 117, 114, 101, 40, 0,
48, 0, 18, 62, 10, 11, 82, 101, 99, 111, 114, 100, 82,
111, 117, 116, 101, 18, 17, 46, 114, 111, 117, 116, 101,
103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 26,
24, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100,
101, 46, 82, 111, 117, 116, 101, 83, 117, 109, 109, 97,
114, 121, 40, 0, 48, 0, 18, 61, 10, 9, 82, 111, 117,
116, 101, 67, 104, 97, 116, 18, 21, 46, 114, 111, 117,
116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117,
116, 101, 78, 111, 116, 101, 26, 21, 46, 114, 111, 117,
116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117,
116, 101, 78, 111, 116, 101, 40, 0, 48, 0, 18, 57, 10,
13, 71, 101, 110, 101, 114, 97, 116, 101, 69, 114, 114,
111, 114, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117,
105, 100, 101, 46, 69, 109, 112, 116, 121, 26, 17, 46,
114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46,
69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 66, 10, 22,
83, 116, 114, 101, 97, 109, 105, 110, 103, 71, 101, 110,
101, 114, 97, 116, 101, 69, 114, 114, 111, 114, 18, 17,
46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101,
46, 69, 109, 112, 116, 121, 26, 17, 46, 114, 111, 117,
116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112,
116, 121, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111,
51>>;
descriptor(X) -> error({gpb_error, {badname, X}}).
gpb_version_as_string() ->
"4.7.3".
gpb_version_as_list() ->
[4,7,3].