1
%% Generated by the Erlang ASN.1 BER-compiler version, utilizing bit-syntax:1.3.1.4
2
%% Purpose: encoder and decoder to the types in mod P-Record
5
-include("P-Record.hrl").
6
-define('RT_PER',asn1rt_per_bin).
7
-export([encoding_rule/0]).
9
'enc_PersonnelRecord'/1,
10
'enc_ChildInformation'/1,
12
'enc_EmployeeNumber'/1,
17
'dec_PersonnelRecord'/2,
18
'dec_ChildInformation'/2,
20
'dec_EmployeeNumber'/2,
30
-export([encode/2,decode/2,encode_disp/2,decode_disp/2]).
36
case catch ?RT_PER:complete(encode_disp(Type,Data)) of
37
{'EXIT',{error,Reason}} ->
40
{error,{asn1,Reason}};
48
case catch decode_disp(Type,Data) of
49
{'EXIT',{error,Reason}} ->
52
{error,{asn1,Reason}};
59
encode_disp('PersonnelRecord',Data) -> 'enc_PersonnelRecord'(Data);
60
encode_disp('ChildInformation',Data) -> 'enc_ChildInformation'(Data);
61
encode_disp('Name',Data) -> 'enc_Name'(Data);
62
encode_disp('EmployeeNumber',Data) -> 'enc_EmployeeNumber'(Data);
63
encode_disp('Date',Data) -> 'enc_Date'(Data);
64
encode_disp(Type,Data) -> exit({error,{asn1,{undefined_type,Type}}}).
67
decode_disp('PersonnelRecord',Data) -> 'dec_PersonnelRecord'(Data,mandatory);
68
decode_disp('ChildInformation',Data) -> 'dec_ChildInformation'(Data,mandatory);
69
decode_disp('Name',Data) -> 'dec_Name'(Data,mandatory);
70
decode_disp('EmployeeNumber',Data) -> 'dec_EmployeeNumber'(Data,mandatory);
71
decode_disp('Date',Data) -> 'dec_Date'(Data,mandatory);
72
decode_disp(Type,Data) -> exit({error,{asn1,{undefined_type,Type}}}).
78
'enc_PersonnelRecord'(Val) ->
79
{Val1,Opt} = ?RT_PER:fixoptionals([{children,6}],Val),
81
?RT_PER:setoptionals(Opt),
83
%% attribute number 1 with type Externaltypereference6P-RecordName
84
'enc_Name'(?RT_PER:cindex(2,Val1,name)),
86
%% attribute number 2 with type VisibleString
87
?RT_PER:encode_VisibleString([],?RT_PER:cindex(3,Val1,title)),
89
%% attribute number 3 with type INTEGER
90
?RT_PER:encode_integer([],?RT_PER:cindex(4,Val1,number)),
92
%% attribute number 4 with type VisibleString
93
?RT_PER:encode_VisibleString([],?RT_PER:cindex(5,Val1,dateOfHire)),
95
%% attribute number 5 with type Externaltypereference10P-RecordName
96
'enc_Name'(?RT_PER:cindex(6,Val1,nameOfSpouse)),
97
case ?RT_PER:cindex(7,Val1,children) of
101
%% attribute number 6 with type SEQUENCE OF
102
'enc_PersonnelRecord_children'(?RT_PER:cindex(7,Val1,children))
105
'enc_PersonnelRecord_children'({'PersonnelRecord_children',Val}) ->
106
'enc_PersonnelRecord_children'(Val);
108
'enc_PersonnelRecord_children'(Val) ->
111
?RT_PER:encode_length(undefined,length(Val)),
112
'enc_PersonnelRecord_children_components'(Val, [])
114
'enc_PersonnelRecord_children_components'([], Acc) -> lists:reverse(Acc);
116
'enc_PersonnelRecord_children_components'([H|T], Acc) ->
117
'enc_PersonnelRecord_children_components'(T, ['enc_ChildInformation'(H)
121
'dec_PersonnelRecord_children'(Bytes,Telltype) ->
123
{Num,Bytes1} = ?RT_PER:decode_length(Bytes,undefined),
124
'dec_PersonnelRecord_children_components'(Num, Bytes1, Telltype, []).
125
'dec_PersonnelRecord_children_components'(0, Bytes, Telltype, Acc) ->
126
{lists:reverse(Acc), Bytes};
127
'dec_PersonnelRecord_children_components'(Num, Bytes, Telltype, Acc) ->
128
{Term,Remain} = 'P-Record':'dec_ChildInformation'(Bytes,Telltype),
129
'dec_PersonnelRecord_children_components'(Num-1, Remain, Telltype, [Term|Acc]).
132
'dec_PersonnelRecord'(Bytes,Telltype) ->
133
{Opt,Bytes1} = ?RT_PER:getoptionals(Bytes,1),
134
%% attribute number 1 with type Name
135
{Term1,Bytes2} = 'dec_Name'(Bytes1,telltype),
137
%% attribute number 2 with type VisibleString
138
{Term2,Bytes3} = ?RT_PER:decode_VisibleString(Bytes2,[]),
140
%% attribute number 3 with type INTEGER
141
{Term3,Bytes4} = ?RT_PER:decode_integer(Bytes3,[]),
143
%% attribute number 4 with type VisibleString
144
{Term4,Bytes5} = ?RT_PER:decode_VisibleString(Bytes4,[]),
146
%% attribute number 5 with type Name
147
{Term5,Bytes6} = 'dec_Name'(Bytes5,telltype),
149
%% attribute number 6 with type SEQUENCE OF
150
{Term6,Bytes7} = case element(1,Opt) of
151
1 ->'dec_PersonnelRecord_children'(Bytes6, Telltype);
155
{{'PersonnelRecord',Term1,Term2,Term3,Term4,Term5,Term6},Bytes7}.
157
'enc_ChildInformation'(Val) ->
158
{Val1,Opt} = ?RT_PER:fixoptionals([{name,1},{dateOfBirth,2}],Val),
160
?RT_PER:setoptionals(Opt),
161
case ?RT_PER:cindex(2,Val1,name) of
165
%% attribute number 1 with type Externaltypereference15P-RecordName
166
'enc_Name'(?RT_PER:cindex(2,Val1,name))
168
case ?RT_PER:cindex(3,Val1,dateOfBirth) of
172
%% attribute number 2 with type VisibleString
173
?RT_PER:encode_VisibleString([],?RT_PER:cindex(3,Val1,dateOfBirth))
177
'dec_ChildInformation'(Bytes,Telltype) ->
178
{Opt,Bytes1} = ?RT_PER:getoptionals(Bytes,2),
179
%% attribute number 1 with type Name
180
{Term1,Bytes2} = case element(1,Opt) of
181
1 ->'dec_Name'(Bytes1,telltype);
182
0 ->{asn1_NOVALUE,Bytes1}
186
%% attribute number 2 with type VisibleString
187
{Term2,Bytes3} = case element(2,Opt) of
188
1 ->?RT_PER:decode_VisibleString(Bytes2,[]);
189
0 ->{asn1_NOVALUE,Bytes2}
192
{{'ChildInformation',Term1,Term2},Bytes3}.
195
Val1 = ?RT_PER:list_to_record('Name', Val),
198
%% attribute number 1 with type VisibleString
199
?RT_PER:encode_VisibleString([],?RT_PER:cindex(2,Val1,givenName)),
201
%% attribute number 2 with type VisibleString
202
?RT_PER:encode_VisibleString([],?RT_PER:cindex(3,Val1,initial)),
204
%% attribute number 3 with type VisibleString
205
?RT_PER:encode_VisibleString([],?RT_PER:cindex(4,Val1,familyName))].
208
'dec_Name'(Bytes,Telltype) ->
210
%% attribute number 1 with type VisibleString
211
{Term1,Bytes1} = ?RT_PER:decode_VisibleString(Bytes,[]),
213
%% attribute number 2 with type VisibleString
214
{Term2,Bytes2} = ?RT_PER:decode_VisibleString(Bytes1,[]),
216
%% attribute number 3 with type VisibleString
217
{Term3,Bytes3} = ?RT_PER:decode_VisibleString(Bytes2,[]),
218
{{'Name',Term1,Term2,Term3},Bytes3}.
221
'enc_EmployeeNumber'({'EmployeeNumber',Val}) ->
222
'enc_EmployeeNumber'(Val);
224
'enc_EmployeeNumber'(Val) ->
225
?RT_PER:encode_integer([],Val).
228
'dec_EmployeeNumber'(Bytes,Telltype) ->
229
?RT_PER:decode_integer(Bytes,[]).
232
'enc_Date'({'Date',Val}) ->
236
?RT_PER:encode_VisibleString([],Val).
239
'dec_Date'(Bytes,Telltype) ->
240
?RT_PER:decode_VisibleString(Bytes,[]).
243
{'PersonnelRecord',{'Name',{74,111,104,110},[80],[83,109,105,116,104]},[68,105,114,101,99,116,111,114],51,[49,57,55,49,48,57,49,55],{'Name',{77,97,114,121},[84],[83,109,105,116,104]},[{'ChildInformation',{'Name',[82,97,108,112,104],[84],[83,109,105,116,104]},[49,57,53,55,49,49,49,49]},{'ChildInformation',{'Name',[83,117,115,97,110],[66],[74,111,110,101,115]},[49,57,53,57,48,55,49,55]}]}.