erlang自定义二进制协议
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

842 lines
30 KiB

5 years ago
5 years ago
  1. -module(protoMsg).
  2. -compile([nowarn_unused_vars]).
  3. -export([encode/1, decode/1, encodeRec/1, decodeBin/2]).
  4. -define(min8, -128).
  5. -define(max8, 127).
  6. -define(min16, -32768).
  7. -define(max16, 32767).
  8. -define(min32, -2147483648).
  9. -define(max32, 2147483647).
  10. -define(min64, -9223372036854775808).
  11. -define(max64, 9223372036854775807).
  12. -define(minF32, -3.4E+38).
  13. -define(maxF32, 3.4E+38).
  14. -define(minF64, -1.797E-308).
  15. -define(maxF64, 1.797E+308).
  16. -define(int8(V), <<V:8>>).
  17. -define(uint8(V), <<V:8>>).
  18. -define(int16(V), <<V:16/big>>).
  19. -define(uint16(V), <<V:16/big>>).
  20. -define(int32(V), <<V:32/big>>).
  21. -define(uint32(V), <<V:32/big>>).
  22. -define(int64(V), <<V:64/big>>).
  23. -define(uint64(V), <<V:64/big>>).
  24. -define(integer(V), (integer(V))).
  25. -define(number(V), (number(V))).
  26. -define(string(V), (string(V))).
  27. -define(float(V), <<V:32/big-float>>).
  28. -define(double(V), <<V:64/big-float>>).
  29. -define(bool(V), (case V of true -> <<1:8>>; _ -> <<0:8>> end)).
  30. -define(record(V), (case V of undefined -> [<<0:8>>]; V -> [<<1:8>>, encodeRec(V)] end)).
  31. -define(list_bool(List), [<<(length(List)):16/big>>, [?bool(V) || V <- List]]).
  32. -define(list_int8(List), [<<(length(List)):16/big>>, [?int8(V) || V <- List]]).
  33. -define(list_uint8(List), [<<(length(List)):16/big>>, [?uint8(V) || V <- List]]).
  34. -define(list_int16(List), [<<(length(List)):16/big>>, [?int16(V) || V <- List]]).
  35. -define(list_uint16(List), [<<(length(List)):16/big>>, [?uint16(V) || V <- List]]).
  36. -define(list_int32(List), [<<(length(List)):16/big>>, [?int32(V) || V <- List]]).
  37. -define(list_uint32(List), [<<(length(List)):16/big>>, [?uint32(V) || V <- List]]).
  38. -define(list_int64(List), [<<(length(List)):16/big>>, [?int64(V) || V <- List]]).
  39. -define(list_uint64(List), [<<(length(List)):16/big>>, [?uint64(V) || V <- List]]).
  40. -define(list_float(List), [<<(length(List)):16/big>>, [?float(V) || V <- List]]).
  41. -define(list_double(List), [<<(length(List)):16/big>>, [?double(V) || V <- List]]).
  42. -define(list_integer(List), [<<(length(List)):16/big>>, [integer(V) || V <- List]]).
  43. -define(list_number(List), [<<(length(List)):16/big>>, [number(V) || V <- List]]).
  44. -define(list_string(List), [<<(length(List)):16/big>>, [string(V) || V <- List]]).
  45. -define(list_record(List), [<<(length(List)):16/big>>, [encodeRec(V) || V <- List]]).
  46. -define(BinaryShareSize, 65).
  47. -define(BinaryCopyRatio, 1.2).
  48. integer(V) ->
  49. if
  50. V >= ?min8 andalso V =< ?max8 ->
  51. <<8:8, <<V:8>>/binary>>;
  52. V >= ?min16 andalso V =< ?max16 ->
  53. <<16:8, <<V:16/big>>/binary>>;
  54. V >= ?min32 andalso V =< ?max32 ->
  55. <<32:8, <<V:32/big>>/binary>>;
  56. V >= ?min64 andalso V =< ?max64 ->
  57. <<64:8, <<V:64/big>>/binary>>;
  58. true ->
  59. throw(exceeded_the_integer)
  60. end.
  61. number(V) ->
  62. if
  63. erlang:is_integer(V) ->
  64. if
  65. V >= ?min8 andalso V =< ?max8 ->
  66. <<8:8, <<V:8>>/binary>>;
  67. V >= ?min16 andalso V =< ?max16 ->
  68. <<16:8, <<V:16/big>>/binary>>;
  69. V >= ?min32 andalso V =< ?max32 ->
  70. <<32:8, <<V:32/big>>/binary>>;
  71. V >= ?min64 andalso V =< ?max64 ->
  72. <<64:8, <<V:64/big>>/binary>>;
  73. true ->
  74. throw(exceeded_the_integer)
  75. end;
  76. erlang:is_float(V) ->
  77. if
  78. V >= ?minF32 andalso V =< ?maxF32 ->
  79. <<33:8, <<V:32/big-float>>/binary>>;
  80. V >= ?minF64 andalso V =< ?maxF64 ->
  81. <<65:8, <<V:64/big-float>>/binary>>;
  82. true ->
  83. throw(exceeded_the_float)
  84. end;
  85. true ->
  86. throw(is_not_number)
  87. end.
  88. string(Str) when is_binary(Str) ->
  89. [<<(byte_size(Str)):16/big>>, Str];
  90. string(Str) ->
  91. Str2 = unicode:characters_to_binary(Str, utf8),
  92. [<<(byte_size(Str2)):16/big>>, Str2].
  93. decode(Bin) ->
  94. <<MsgId:16/big, MsgBin/binary>> = Bin,
  95. decodeBin(MsgId, MsgBin).
  96. deIntegerList(0, MsgBin, RetList) ->
  97. {lists:reverse(RetList), MsgBin};
  98. deIntegerList(N, MsgBin, RetList) ->
  99. <<IntBits:8, Int:IntBits/big-signed, LeftBin/binary>> = MsgBin,
  100. deIntegerList(N - 1, LeftBin, [Int | RetList]).
  101. deNumberList(0, MsgBin, RetList) ->
  102. {lists:reverse(RetList), MsgBin};
  103. deNumberList(N, MsgBin, RetList) ->
  104. <<NumBits:8, NumBin/binary>> = MsgBin,
  105. case NumBits of
  106. 33 ->
  107. <<Float:32/big-float, LeftBin/binary>> = NumBin,
  108. deNumberList(N - 1, LeftBin, [Float | RetList]);
  109. 65 ->
  110. <<Float:64/big-float, LeftBin/binary>> = NumBin,
  111. deNumberList(N - 1, LeftBin, [Float | RetList]);
  112. _ ->
  113. <<Int:NumBits/big-signed, LeftBin/binary>> = NumBin,
  114. deNumberList(N - 1, LeftBin, [Int | RetList])
  115. end.
  116. deStringList(0, MsgBin, _RefSize, RetList) ->
  117. {lists:reverse(RetList), MsgBin};
  118. deStringList(N, MsgBin, RefSize, RetList) ->
  119. <<Len:16/big, StrBin:Len/binary-unit:8, LeftBin/binary>> = MsgBin,
  120. case Len < ?BinaryShareSize of
  121. true ->
  122. deStringList(N - 1, LeftBin, RefSize, [StrBin | RetList]);
  123. _ ->
  124. case RefSize / Len > ?BinaryCopyRatio of
  125. true ->
  126. StrBinCopy = binary:copy(StrBin),
  127. deStringList(N - 1, LeftBin, RefSize, [StrBinCopy | RetList]);
  128. _ ->
  129. deStringList(N - 1, LeftBin, RefSize, [StrBin | RetList])
  130. end
  131. end.
  132. deRecordList(0, _MsgId, MsgBin, RetList) ->
  133. {lists:reverse(RetList), MsgBin};
  134. deRecordList(N, MsgId, MsgBin, RetList) ->
  135. {Tuple, LeftBin} = decodeRec(MsgId, MsgBin),
  136. deRecordList(N - 1, MsgId, LeftBin, [Tuple | RetList]).
  137. encodeRec({test, V1}) ->
  138. [?string(V1)];
  139. encodeRec({phoneNumber, V1, V2}) ->
  140. [?record(V1), ?int32(V2)];
  141. encodeRec({person, V1, V2, V3, V4}) ->
  142. [?string(V1), ?int32(V2), ?string(V3), ?list_record(V4)];
  143. encodeRec({union, V1, V2}) ->
  144. [?string(V1), ?int32(V2)];
  145. encodeRec(_) ->
  146. [].
  147. encode({test, V1}) ->
  148. [<<1:16/big-unsigned>>, ?string(V1)];
  149. encode({phoneNumber, V1, V2}) ->
  150. [<<2:16/big-unsigned>>, ?record(V1), ?int32(V2)];
  151. encode({person, V1, V2, V3, V4}) ->
  152. [<<3:16/big-unsigned>>, ?string(V1), ?int32(V2), ?string(V3), ?list_record(V4)];
  153. encode({addressBook, V1, V2}) ->
  154. [<<4:16/big-unsigned>>, ?list_record(V1), ?list_record(V2)];
  155. encode({union, V1, V2}) ->
  156. [<<5:16/big-unsigned>>, ?string(V1), ?int32(V2)];
  157. encode({tbool, V1}) ->
  158. [<<6:16/big-unsigned>>, ?bool(V1)];
  159. encode({tint8, V1, V2}) ->
  160. [<<7:16/big-unsigned>>, ?int8(V1), ?int8(V2)];
  161. encode({tuint8, V1, V2}) ->
  162. [<<8:16/big-unsigned>>, ?uint8(V1), ?uint8(V2)];
  163. encode({tint16, V1, V2}) ->
  164. [<<9:16/big-unsigned>>, ?int16(V1), ?int16(V2)];
  165. encode({tuint16, V1, V2}) ->
  166. [<<10:16/big-unsigned>>, ?uint16(V1), ?uint16(V2)];
  167. encode({tint32, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10}) ->
  168. [<<11:16/big-unsigned>>, ?int32(V1), ?int32(V2), ?int32(V3), ?int32(V4), ?int32(V5), ?int32(V6), ?int32(V7), ?int32(V8), ?int32(V9), ?int32(V10)];
  169. encode({tuint32, V1, V2}) ->
  170. [<<12:16/big-unsigned>>, ?uint32(V1), ?uint32(V2)];
  171. encode({tint64, V1, V2}) ->
  172. [<<13:16/big-unsigned>>, ?int64(V1), ?int64(V2)];
  173. encode({tuint64, V1, V2}) ->
  174. [<<14:16/big-unsigned>>, ?uint64(V1), ?uint64(V2)];
  175. encode({tinteger, V1, V2, V3, V4, V5, V6, V7, V8}) ->
  176. [<<15:16/big-unsigned>>, ?integer(V1), ?integer(V2), ?integer(V3), ?integer(V4), ?integer(V5), ?integer(V6), ?integer(V7), ?integer(V8)];
  177. encode({tnumber, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10}) ->
  178. [<<16:16/big-unsigned>>, ?number(V1), ?number(V2), ?number(V3), ?number(V4), ?number(V5), ?number(V6), ?number(V7), ?number(V8), ?number(V9), ?number(V10)];
  179. encode({tfloat, V1, V2}) ->
  180. [<<17:16/big-unsigned>>, ?float(V1), ?float(V2)];
  181. encode({tdouble, V1, V2}) ->
  182. [<<18:16/big-unsigned>>, ?double(V1), ?double(V2)];
  183. encode({tstring, V1, V2}) ->
  184. [<<19:16/big-unsigned>>, ?string(V1), ?string(V2)];
  185. encode({tlistbool, V1}) ->
  186. [<<20:16/big-unsigned>>, ?list_bool(V1)];
  187. encode({tlistint8, V1}) ->
  188. [<<21:16/big-unsigned>>, ?list_int8(V1)];
  189. encode({tlistuint8, V1}) ->
  190. [<<22:16/big-unsigned>>, ?list_uint8(V1)];
  191. encode({tlistint16, V1}) ->
  192. [<<23:16/big-unsigned>>, ?list_int16(V1)];
  193. encode({tlistuint16, V1}) ->
  194. [<<24:16/big-unsigned>>, ?list_uint16(V1)];
  195. encode({tlistint32, V1}) ->
  196. [<<25:16/big-unsigned>>, ?list_int32(V1)];
  197. encode({tlistuint32, V1}) ->
  198. [<<26:16/big-unsigned>>, ?list_uint32(V1)];
  199. encode({tlistint64, V1}) ->
  200. [<<27:16/big-unsigned>>, ?list_int64(V1)];
  201. encode({tlistuint64, V1}) ->
  202. [<<28:16/big-unsigned>>, ?list_uint64(V1)];
  203. encode({tlistinteger, V1}) ->
  204. [<<29:16/big-unsigned>>, ?list_integer(V1)];
  205. encode({tlistnumber, V1}) ->
  206. [<<30:16/big-unsigned>>, ?list_number(V1)];
  207. encode({tlistfloat, V1}) ->
  208. [<<31:16/big-unsigned>>, ?list_float(V1)];
  209. encode({tlistdouble, V1}) ->
  210. [<<32:16/big-unsigned>>, ?list_double(V1)];
  211. encode({tliststring, V1}) ->
  212. [<<33:16/big-unsigned>>, ?list_string(V1)];
  213. encode({tlistunion, V1}) ->
  214. [<<34:16/big-unsigned>>, ?list_record(V1)];
  215. encode({allType, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18, V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36, V37, V38, V39, V40, V41, V42, V43, V44, V45, V46, V47, V48, V49, V50, V51, V52, V53, V54, V55}) ->
  216. [<<35:16/big-unsigned>>, ?bool(V1), ?int8(V2), ?uint8(V3), ?int16(V4), ?uint16(V5), ?int32(V6), ?uint32(V7), ?int64(V8), ?uint64(V9), ?integer(V10), ?integer(V11), ?integer(V12), ?integer(V13), ?integer(V14), ?integer(V15), ?integer(V16), ?integer(V17), ?number(V18), ?number(V19), ?number(V20), ?number(V21), ?number(V22), ?number(V23), ?number(V24), ?number(V25), ?number(V26), ?number(V27), ?float(V28), ?double(V29), ?string(V30), ?string(V31), ?record(V32), ?list_bool(V33), ?list_int8(V34), ?list_uint8(V35), ?list_int16(V36), ?list_uint16(V37), ?list_int32(V38), ?list_uint32(V39), ?list_int64(V40), ?list_uint64(V41), ?list_integer(V42), ?list_integer(V43), ?list_integer(V44), ?list_integer(V45), ?list_number(V46), ?list_number(V47), ?list_number(V48), ?list_number(V49), ?list_number(V50), ?list_number(V51), ?list_float(V52), ?list_double(V53), ?list_string(V54), ?list_record(V55)];
  217. encode({person1, V1, V2, V3, V4}) ->
  218. [<<1001:16/big-unsigned>>, ?string(V1), ?int32(V2), ?string(V3), ?list_record(V4)];
  219. encode(_) ->
  220. [].
  221. decodeRec(1, LeftBin0) ->
  222. RefSize = binary:referenced_byte_size(LeftBin0),
  223. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  224. case Len1 < ?BinaryShareSize of
  225. true ->
  226. V1 = TemStrV1;
  227. _ ->
  228. case RefSize / Len1 > ?BinaryCopyRatio of
  229. true ->
  230. V1 = binary:copy(TemStrV1);
  231. _ ->
  232. V1 = TemStrV1
  233. end
  234. end,
  235. MsgRec = {test, V1},
  236. {MsgRec, LeftBin1};
  237. decodeRec(2, LeftBin0) ->
  238. <<IsUndef1:8/big-unsigned, LeftBin1/binary>> = LeftBin0,
  239. case IsUndef1 of
  240. 0 ->
  241. V1 = undefined,
  242. LeftBin2 = LeftBin1 ;
  243. _ ->
  244. {V1, LeftBin2} = decodeRec(1, LeftBin1)
  245. end,
  246. <<V2:32/big-signed, LeftBin3/binary>> = LeftBin2,
  247. MsgRec = {phoneNumber, V1, V2},
  248. {MsgRec, LeftBin3};
  249. decodeRec(3, LeftBin0) ->
  250. RefSize = binary:referenced_byte_size(LeftBin0),
  251. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  252. case Len1 < ?BinaryShareSize of
  253. true ->
  254. V1 = TemStrV1;
  255. _ ->
  256. case RefSize / Len1 > ?BinaryCopyRatio of
  257. true ->
  258. V1 = binary:copy(TemStrV1);
  259. _ ->
  260. V1 = TemStrV1
  261. end
  262. end,
  263. <<V2:32/big-signed, LeftBin2/binary>> = LeftBin1,
  264. <<Len2:16/big-unsigned, TemStrV3:Len2/binary, LeftBin3/binary>> = LeftBin2,
  265. case Len2 < ?BinaryShareSize of
  266. true ->
  267. V3 = TemStrV3;
  268. _ ->
  269. case RefSize / Len2 > ?BinaryCopyRatio of
  270. true ->
  271. V3 = binary:copy(TemStrV3);
  272. _ ->
  273. V3 = TemStrV3
  274. end
  275. end,
  276. <<Len3:16/big-unsigned, LeftBin4/binary>> = LeftBin3,
  277. {V4, LeftBin5} = deRecordList(Len3, 2, LeftBin4, []),
  278. MsgRec = {person, V1, V2, V3, V4},
  279. {MsgRec, LeftBin5};
  280. decodeRec(5, LeftBin0) ->
  281. RefSize = binary:referenced_byte_size(LeftBin0),
  282. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  283. case Len1 < ?BinaryShareSize of
  284. true ->
  285. V1 = TemStrV1;
  286. _ ->
  287. case RefSize / Len1 > ?BinaryCopyRatio of
  288. true ->
  289. V1 = binary:copy(TemStrV1);
  290. _ ->
  291. V1 = TemStrV1
  292. end
  293. end,
  294. <<V2:32/big-signed, LeftBin2/binary>> = LeftBin1,
  295. MsgRec = {union, V1, V2},
  296. {MsgRec, LeftBin2};
  297. decodeRec(_, _) ->
  298. {{}, <<>>}.
  299. decodeBin(1, LeftBin0) ->
  300. RefSize = binary:referenced_byte_size(LeftBin0),
  301. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  302. case Len1 < ?BinaryShareSize of
  303. true ->
  304. V1 = TemStrV1;
  305. _ ->
  306. case RefSize / Len1 > ?BinaryCopyRatio of
  307. true ->
  308. V1 = binary:copy(TemStrV1);
  309. _ ->
  310. V1 = TemStrV1
  311. end
  312. end,
  313. {test, V1};
  314. decodeBin(2, LeftBin0) ->
  315. <<IsUndef1:8/big-unsigned, LeftBin1/binary>> = LeftBin0,
  316. case IsUndef1 of
  317. 0 ->
  318. V1 = undefined,
  319. LeftBin2 = LeftBin1 ;
  320. _ ->
  321. {V1, LeftBin2} = decodeRec(1, LeftBin1)
  322. end,
  323. <<V2:32/big-signed, LeftBin3/binary>> = LeftBin2,
  324. {phoneNumber, V1, V2};
  325. decodeBin(3, LeftBin0) ->
  326. RefSize = binary:referenced_byte_size(LeftBin0),
  327. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  328. case Len1 < ?BinaryShareSize of
  329. true ->
  330. V1 = TemStrV1;
  331. _ ->
  332. case RefSize / Len1 > ?BinaryCopyRatio of
  333. true ->
  334. V1 = binary:copy(TemStrV1);
  335. _ ->
  336. V1 = TemStrV1
  337. end
  338. end,
  339. <<V2:32/big-signed, LeftBin2/binary>> = LeftBin1,
  340. <<Len2:16/big-unsigned, TemStrV3:Len2/binary, LeftBin3/binary>> = LeftBin2,
  341. case Len2 < ?BinaryShareSize of
  342. true ->
  343. V3 = TemStrV3;
  344. _ ->
  345. case RefSize / Len2 > ?BinaryCopyRatio of
  346. true ->
  347. V3 = binary:copy(TemStrV3);
  348. _ ->
  349. V3 = TemStrV3
  350. end
  351. end,
  352. <<Len3:16/big-unsigned, LeftBin4/binary>> = LeftBin3,
  353. {V4, LeftBin5} = deRecordList(Len3, 2, LeftBin4, []),
  354. {person, V1, V2, V3, V4};
  355. decodeBin(4, LeftBin0) ->
  356. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  357. {V1, LeftBin2} = deRecordList(Len1, 3, LeftBin1, []),
  358. <<Len2:16/big-unsigned, LeftBin3/binary>> = LeftBin2,
  359. {V2, LeftBin4} = deRecordList(Len2, 3, LeftBin3, []),
  360. {addressBook, V1, V2};
  361. decodeBin(5, LeftBin0) ->
  362. RefSize = binary:referenced_byte_size(LeftBin0),
  363. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  364. case Len1 < ?BinaryShareSize of
  365. true ->
  366. V1 = TemStrV1;
  367. _ ->
  368. case RefSize / Len1 > ?BinaryCopyRatio of
  369. true ->
  370. V1 = binary:copy(TemStrV1);
  371. _ ->
  372. V1 = TemStrV1
  373. end
  374. end,
  375. <<V2:32/big-signed, LeftBin2/binary>> = LeftBin1,
  376. {union, V1, V2};
  377. decodeBin(6, LeftBin0) ->
  378. <<Bool1:8/big-unsigned, LeftBin1/binary>> = LeftBin0,
  379. V1 = Bool1 =:= 1,
  380. {tbool, V1};
  381. decodeBin(7, LeftBin0) ->
  382. <<V1:8/big-signed, V2:8/big-signed, LeftBin1/binary>> = LeftBin0,
  383. {tint8, V1, V2};
  384. decodeBin(8, LeftBin0) ->
  385. <<V1:8/big-unsigned, V2:8/big-unsigned, LeftBin1/binary>> = LeftBin0,
  386. {tuint8, V1, V2};
  387. decodeBin(9, LeftBin0) ->
  388. <<V1:16/big-signed, V2:16/big-signed, LeftBin1/binary>> = LeftBin0,
  389. {tint16, V1, V2};
  390. decodeBin(10, LeftBin0) ->
  391. <<V1:16/big-unsigned, V2:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  392. {tuint16, V1, V2};
  393. decodeBin(11, LeftBin0) ->
  394. <<V1:32/big-signed, V2:32/big-signed, V3:32/big-signed, V4:32/big-signed, V5:32/big-signed, V6:32/big-signed, V7:32/big-signed, V8:32/big-signed, V9:32/big-signed, V10:32/big-signed, LeftBin1/binary>> = LeftBin0,
  395. {tint32, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10};
  396. decodeBin(12, LeftBin0) ->
  397. <<V1:32/big-unsigned, V2:32/big-unsigned, LeftBin1/binary>> = LeftBin0,
  398. {tuint32, V1, V2};
  399. decodeBin(13, LeftBin0) ->
  400. <<V1:64/big-signed, V2:64/big-signed, LeftBin1/binary>> = LeftBin0,
  401. {tint64, V1, V2};
  402. decodeBin(14, LeftBin0) ->
  403. <<V1:64/big-unsigned, V2:64/big-unsigned, LeftBin1/binary>> = LeftBin0,
  404. {tuint64, V1, V2};
  405. decodeBin(15, LeftBin0) ->
  406. <<IntBits1:8, V1:IntBits1/big-signed, IntBits2:8, V2:IntBits2/big-signed, IntBits3:8, V3:IntBits3/big-signed, IntBits4:8, V4:IntBits4/big-signed, IntBits5:8, V5:IntBits5/big-signed, IntBits6:8, V6:IntBits6/big-signed, IntBits7:8, V7:IntBits7/big-signed, IntBits8:8, V8:IntBits8/big-signed, LeftBin1/binary>> = LeftBin0,
  407. {tinteger, V1, V2, V3, V4, V5, V6, V7, V8};
  408. decodeBin(16, LeftBin0) ->
  409. <<NumBits1:8, LeftBin1/binary>> = LeftBin0,
  410. case NumBits1 of
  411. 33->
  412. <<V1:32/big-float, LeftBin2/binary>> = LeftBin1;
  413. 65 ->
  414. <<V1:64/big-float, LeftBin2/binary>> = LeftBin1;
  415. _ ->
  416. <<V1:NumBits1/big-signed, LeftBin2/binary>> = LeftBin1
  417. end,
  418. <<NumBits2:8, LeftBin3/binary>> = LeftBin2,
  419. case NumBits2 of
  420. 33->
  421. <<V2:32/big-float, LeftBin4/binary>> = LeftBin3;
  422. 65 ->
  423. <<V2:64/big-float, LeftBin4/binary>> = LeftBin3;
  424. _ ->
  425. <<V2:NumBits2/big-signed, LeftBin4/binary>> = LeftBin3
  426. end,
  427. <<NumBits3:8, LeftBin5/binary>> = LeftBin4,
  428. case NumBits3 of
  429. 33->
  430. <<V3:32/big-float, LeftBin6/binary>> = LeftBin5;
  431. 65 ->
  432. <<V3:64/big-float, LeftBin6/binary>> = LeftBin5;
  433. _ ->
  434. <<V3:NumBits3/big-signed, LeftBin6/binary>> = LeftBin5
  435. end,
  436. <<NumBits4:8, LeftBin7/binary>> = LeftBin6,
  437. case NumBits4 of
  438. 33->
  439. <<V4:32/big-float, LeftBin8/binary>> = LeftBin7;
  440. 65 ->
  441. <<V4:64/big-float, LeftBin8/binary>> = LeftBin7;
  442. _ ->
  443. <<V4:NumBits4/big-signed, LeftBin8/binary>> = LeftBin7
  444. end,
  445. <<NumBits5:8, LeftBin9/binary>> = LeftBin8,
  446. case NumBits5 of
  447. 33->
  448. <<V5:32/big-float, LeftBin10/binary>> = LeftBin9;
  449. 65 ->
  450. <<V5:64/big-float, LeftBin10/binary>> = LeftBin9;
  451. _ ->
  452. <<V5:NumBits5/big-signed, LeftBin10/binary>> = LeftBin9
  453. end,
  454. <<NumBits6:8, LeftBin11/binary>> = LeftBin10,
  455. case NumBits6 of
  456. 33->
  457. <<V6:32/big-float, LeftBin12/binary>> = LeftBin11;
  458. 65 ->
  459. <<V6:64/big-float, LeftBin12/binary>> = LeftBin11;
  460. _ ->
  461. <<V6:NumBits6/big-signed, LeftBin12/binary>> = LeftBin11
  462. end,
  463. <<NumBits7:8, LeftBin13/binary>> = LeftBin12,
  464. case NumBits7 of
  465. 33->
  466. <<V7:32/big-float, LeftBin14/binary>> = LeftBin13;
  467. 65 ->
  468. <<V7:64/big-float, LeftBin14/binary>> = LeftBin13;
  469. _ ->
  470. <<V7:NumBits7/big-signed, LeftBin14/binary>> = LeftBin13
  471. end,
  472. <<NumBits8:8, LeftBin15/binary>> = LeftBin14,
  473. case NumBits8 of
  474. 33->
  475. <<V8:32/big-float, LeftBin16/binary>> = LeftBin15;
  476. 65 ->
  477. <<V8:64/big-float, LeftBin16/binary>> = LeftBin15;
  478. _ ->
  479. <<V8:NumBits8/big-signed, LeftBin16/binary>> = LeftBin15
  480. end,
  481. <<NumBits9:8, LeftBin17/binary>> = LeftBin16,
  482. case NumBits9 of
  483. 33->
  484. <<V9:32/big-float, LeftBin18/binary>> = LeftBin17;
  485. 65 ->
  486. <<V9:64/big-float, LeftBin18/binary>> = LeftBin17;
  487. _ ->
  488. <<V9:NumBits9/big-signed, LeftBin18/binary>> = LeftBin17
  489. end,
  490. <<NumBits10:8, LeftBin19/binary>> = LeftBin18,
  491. case NumBits10 of
  492. 33->
  493. <<V10:32/big-float, LeftBin20/binary>> = LeftBin19;
  494. 65 ->
  495. <<V10:64/big-float, LeftBin20/binary>> = LeftBin19;
  496. _ ->
  497. <<V10:NumBits10/big-signed, LeftBin20/binary>> = LeftBin19
  498. end,
  499. {tnumber, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10};
  500. decodeBin(17, LeftBin0) ->
  501. <<V1:32/big-float, V2:32/big-float, LeftBin1/binary>> = LeftBin0,
  502. {tfloat, V1, V2};
  503. decodeBin(18, LeftBin0) ->
  504. <<V1:64/big-float, V2:64/big-float, LeftBin1/binary>> = LeftBin0,
  505. {tdouble, V1, V2};
  506. decodeBin(19, LeftBin0) ->
  507. RefSize = binary:referenced_byte_size(LeftBin0),
  508. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  509. case Len1 < ?BinaryShareSize of
  510. true ->
  511. V1 = TemStrV1;
  512. _ ->
  513. case RefSize / Len1 > ?BinaryCopyRatio of
  514. true ->
  515. V1 = binary:copy(TemStrV1);
  516. _ ->
  517. V1 = TemStrV1
  518. end
  519. end,
  520. <<Len2:16/big-unsigned, TemStrV2:Len2/binary, LeftBin2/binary>> = LeftBin1,
  521. case Len2 < ?BinaryShareSize of
  522. true ->
  523. V2 = TemStrV2;
  524. _ ->
  525. case RefSize / Len2 > ?BinaryCopyRatio of
  526. true ->
  527. V2 = binary:copy(TemStrV2);
  528. _ ->
  529. V2 = TemStrV2
  530. end
  531. end,
  532. {tstring, V1, V2};
  533. decodeBin(20, LeftBin0) ->
  534. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  535. <<ListBin1:Len1/big-binary-unit:8, LeftBin2/binary>> = LeftBin1,
  536. V1 = [TemV =:= 1 || <<TemV:8/big-unsigned>> <= ListBin1],
  537. {tlistbool, V1};
  538. decodeBin(21, LeftBin0) ->
  539. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  540. <<ListBin1:Len1/big-binary-unit:8, LeftBin2/binary>> = LeftBin1,
  541. V1 = [TemV || <<TemV:8/big-signed>> <= ListBin1],
  542. {tlistint8, V1};
  543. decodeBin(22, LeftBin0) ->
  544. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  545. <<ListBin1:Len1/big-binary-unit:8, LeftBin2/binary>> = LeftBin1,
  546. V1 = [TemV || <<TemV:8/big-unsigned>> <= ListBin1],
  547. {tlistuint8, V1};
  548. decodeBin(23, LeftBin0) ->
  549. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  550. <<ListBin1:Len1/big-binary-unit:16, LeftBin2/binary>> = LeftBin1,
  551. V1 = [TemV || <<TemV:16/big-signed>> <= ListBin1],
  552. {tlistint16, V1};
  553. decodeBin(24, LeftBin0) ->
  554. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  555. <<ListBin1:Len1/big-binary-unit:16, LeftBin2/binary>> = LeftBin1,
  556. V1 = [TemV || <<TemV:16/big-unsigned>> <= ListBin1],
  557. {tlistuint16, V1};
  558. decodeBin(25, LeftBin0) ->
  559. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  560. <<ListBin1:Len1/big-binary-unit:32, LeftBin2/binary>> = LeftBin1,
  561. V1 = [TemV || <<TemV:32/big-signed>> <= ListBin1],
  562. {tlistint32, V1};
  563. decodeBin(26, LeftBin0) ->
  564. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  565. <<ListBin1:Len1/big-binary-unit:32, LeftBin2/binary>> = LeftBin1,
  566. V1 = [TemV || <<TemV:32/big-unsigned>> <= ListBin1],
  567. {tlistuint32, V1};
  568. decodeBin(27, LeftBin0) ->
  569. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  570. <<ListBin1:Len1/big-binary-unit:64, LeftBin2/binary>> = LeftBin1,
  571. V1 = [TemV || <<TemV:64/big-signed>> <= ListBin1],
  572. {tlistint64, V1};
  573. decodeBin(28, LeftBin0) ->
  574. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  575. <<ListBin1:Len1/big-binary-unit:64, LeftBin2/binary>> = LeftBin1,
  576. V1 = [TemV || <<TemV:64/big-unsigned>> <= ListBin1],
  577. {tlistuint64, V1};
  578. decodeBin(29, LeftBin0) ->
  579. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  580. {V1, LeftBin2} = deIntegerList(Len1, LeftBin1, []),
  581. {tlistinteger, V1};
  582. decodeBin(30, LeftBin0) ->
  583. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  584. {V1, LeftBin2} = deNumberList(Len1, LeftBin1, []),
  585. {tlistnumber, V1};
  586. decodeBin(31, LeftBin0) ->
  587. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  588. <<ListBin1:Len1/big-binary-unit:32, LeftBin2/binary>> = LeftBin1,
  589. V1 = [TemV || <<TemV:32/big-float>> <= ListBin1],
  590. {tlistfloat, V1};
  591. decodeBin(32, LeftBin0) ->
  592. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  593. <<ListBin1:Len1/big-binary-unit:64, LeftBin2/binary>> = LeftBin1,
  594. V1 = [TemV || <<TemV:64/big-float>> <= ListBin1],
  595. {tlistdouble, V1};
  596. decodeBin(33, LeftBin0) ->
  597. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  598. RefSize = binary:referenced_byte_size(LeftBin0),
  599. {V1, LeftBin2} = deStringList(Len1, LeftBin1, RefSize, []),
  600. {tliststring, V1};
  601. decodeBin(34, LeftBin0) ->
  602. <<Len1:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
  603. {V1, LeftBin2} = deRecordList(Len1, 5, LeftBin1, []),
  604. {tlistunion, V1};
  605. decodeBin(35, LeftBin0) ->
  606. <<Bool1:8/big-unsigned, LeftBin1/binary>> = LeftBin0,
  607. V1 = Bool1 =:= 1,
  608. <<V2:8/big-signed, V3:8/big-unsigned, V4:16/big-signed, V5:16/big-unsigned, V6:32/big-signed, V7:32/big-unsigned, V8:64/big-signed, V9:64/big-unsigned, IntBits1:8, V10:IntBits1/big-signed, IntBits2:8, V11:IntBits2/big-signed, IntBits3:8, V12:IntBits3/big-signed, IntBits4:8, V13:IntBits4/big-signed, IntBits5:8, V14:IntBits5/big-signed, IntBits6:8, V15:IntBits6/big-signed, IntBits7:8, V16:IntBits7/big-signed, IntBits8:8, V17:IntBits8/big-signed, LeftBin2/binary>> = LeftBin1,
  609. <<NumBits1:8, LeftBin3/binary>> = LeftBin2,
  610. case NumBits1 of
  611. 33->
  612. <<V18:32/big-float, LeftBin4/binary>> = LeftBin3;
  613. 65 ->
  614. <<V18:64/big-float, LeftBin4/binary>> = LeftBin3;
  615. _ ->
  616. <<V18:NumBits1/big-signed, LeftBin4/binary>> = LeftBin3
  617. end,
  618. <<NumBits2:8, LeftBin5/binary>> = LeftBin4,
  619. case NumBits2 of
  620. 33->
  621. <<V19:32/big-float, LeftBin6/binary>> = LeftBin5;
  622. 65 ->
  623. <<V19:64/big-float, LeftBin6/binary>> = LeftBin5;
  624. _ ->
  625. <<V19:NumBits2/big-signed, LeftBin6/binary>> = LeftBin5
  626. end,
  627. <<NumBits3:8, LeftBin7/binary>> = LeftBin6,
  628. case NumBits3 of
  629. 33->
  630. <<V20:32/big-float, LeftBin8/binary>> = LeftBin7;
  631. 65 ->
  632. <<V20:64/big-float, LeftBin8/binary>> = LeftBin7;
  633. _ ->
  634. <<V20:NumBits3/big-signed, LeftBin8/binary>> = LeftBin7
  635. end,
  636. <<NumBits4:8, LeftBin9/binary>> = LeftBin8,
  637. case NumBits4 of
  638. 33->
  639. <<V21:32/big-float, LeftBin10/binary>> = LeftBin9;
  640. 65 ->
  641. <<V21:64/big-float, LeftBin10/binary>> = LeftBin9;
  642. _ ->
  643. <<V21:NumBits4/big-signed, LeftBin10/binary>> = LeftBin9
  644. end,
  645. <<NumBits5:8, LeftBin11/binary>> = LeftBin10,
  646. case NumBits5 of
  647. 33->
  648. <<V22:32/big-float, LeftBin12/binary>> = LeftBin11;
  649. 65 ->
  650. <<V22:64/big-float, LeftBin12/binary>> = LeftBin11;
  651. _ ->
  652. <<V22:NumBits5/big-signed, LeftBin12/binary>> = LeftBin11
  653. end,
  654. <<NumBits6:8, LeftBin13/binary>> = LeftBin12,
  655. case NumBits6 of
  656. 33->
  657. <<V23:32/big-float, LeftBin14/binary>> = LeftBin13;
  658. 65 ->
  659. <<V23:64/big-float, LeftBin14/binary>> = LeftBin13;
  660. _ ->
  661. <<V23:NumBits6/big-signed, LeftBin14/binary>> = LeftBin13
  662. end,
  663. <<NumBits7:8, LeftBin15/binary>> = LeftBin14,
  664. case NumBits7 of
  665. 33->
  666. <<V24:32/big-float, LeftBin16/binary>> = LeftBin15;
  667. 65 ->
  668. <<V24:64/big-float, LeftBin16/binary>> = LeftBin15;
  669. _ ->
  670. <<V24:NumBits7/big-signed, LeftBin16/binary>> = LeftBin15
  671. end,
  672. <<NumBits8:8, LeftBin17/binary>> = LeftBin16,
  673. case NumBits8 of
  674. 33->
  675. <<V25:32/big-float, LeftBin18/binary>> = LeftBin17;
  676. 65 ->
  677. <<V25:64/big-float, LeftBin18/binary>> = LeftBin17;
  678. _ ->
  679. <<V25:NumBits8/big-signed, LeftBin18/binary>> = LeftBin17
  680. end,
  681. <<NumBits9:8, LeftBin19/binary>> = LeftBin18,
  682. case NumBits9 of
  683. 33->
  684. <<V26:32/big-float, LeftBin20/binary>> = LeftBin19;
  685. 65 ->
  686. <<V26:64/big-float, LeftBin20/binary>> = LeftBin19;
  687. _ ->
  688. <<V26:NumBits9/big-signed, LeftBin20/binary>> = LeftBin19
  689. end,
  690. <<NumBits10:8, LeftBin21/binary>> = LeftBin20,
  691. case NumBits10 of
  692. 33->
  693. <<V27:32/big-float, LeftBin22/binary>> = LeftBin21;
  694. 65 ->
  695. <<V27:64/big-float, LeftBin22/binary>> = LeftBin21;
  696. _ ->
  697. <<V27:NumBits10/big-signed, LeftBin22/binary>> = LeftBin21
  698. end,
  699. <<V28:32/big-float, V29:64/big-float, LeftBin23/binary>> = LeftBin22,
  700. RefSize = binary:referenced_byte_size(LeftBin0),
  701. <<Len1:16/big-unsigned, TemStrV30:Len1/binary, LeftBin24/binary>> = LeftBin23,
  702. case Len1 < ?BinaryShareSize of
  703. true ->
  704. V30 = TemStrV30;
  705. _ ->
  706. case RefSize / Len1 > ?BinaryCopyRatio of
  707. true ->
  708. V30 = binary:copy(TemStrV30);
  709. _ ->
  710. V30 = TemStrV30
  711. end
  712. end,
  713. <<Len2:16/big-unsigned, TemStrV31:Len2/binary, LeftBin25/binary>> = LeftBin24,
  714. case Len2 < ?BinaryShareSize of
  715. true ->
  716. V31 = TemStrV31;
  717. _ ->
  718. case RefSize / Len2 > ?BinaryCopyRatio of
  719. true ->
  720. V31 = binary:copy(TemStrV31);
  721. _ ->
  722. V31 = TemStrV31
  723. end
  724. end,
  725. <<IsUndef1:8/big-unsigned, LeftBin26/binary>> = LeftBin25,
  726. case IsUndef1 of
  727. 0 ->
  728. V32 = undefined,
  729. LeftBin27 = LeftBin26 ;
  730. _ ->
  731. {V32, LeftBin27} = decodeRec(5, LeftBin26)
  732. end,
  733. <<Len3:16/big-unsigned, LeftBin28/binary>> = LeftBin27,
  734. <<ListBin1:Len3/big-binary-unit:8, LeftBin29/binary>> = LeftBin28,
  735. V33 = [TemV =:= 1 || <<TemV:8/big-unsigned>> <= ListBin1],
  736. <<Len4:16/big-unsigned, LeftBin30/binary>> = LeftBin29,
  737. <<ListBin2:Len4/big-binary-unit:8, LeftBin31/binary>> = LeftBin30,
  738. V34 = [TemV || <<TemV:8/big-signed>> <= ListBin2],
  739. <<Len5:16/big-unsigned, LeftBin32/binary>> = LeftBin31,
  740. <<ListBin3:Len5/big-binary-unit:8, LeftBin33/binary>> = LeftBin32,
  741. V35 = [TemV || <<TemV:8/big-unsigned>> <= ListBin3],
  742. <<Len6:16/big-unsigned, LeftBin34/binary>> = LeftBin33,
  743. <<ListBin4:Len6/big-binary-unit:16, LeftBin35/binary>> = LeftBin34,
  744. V36 = [TemV || <<TemV:16/big-signed>> <= ListBin4],
  745. <<Len7:16/big-unsigned, LeftBin36/binary>> = LeftBin35,
  746. <<ListBin5:Len7/big-binary-unit:16, LeftBin37/binary>> = LeftBin36,
  747. V37 = [TemV || <<TemV:16/big-unsigned>> <= ListBin5],
  748. <<Len8:16/big-unsigned, LeftBin38/binary>> = LeftBin37,
  749. <<ListBin6:Len8/big-binary-unit:32, LeftBin39/binary>> = LeftBin38,
  750. V38 = [TemV || <<TemV:32/big-signed>> <= ListBin6],
  751. <<Len9:16/big-unsigned, LeftBin40/binary>> = LeftBin39,
  752. <<ListBin7:Len9/big-binary-unit:32, LeftBin41/binary>> = LeftBin40,
  753. V39 = [TemV || <<TemV:32/big-unsigned>> <= ListBin7],
  754. <<Len10:16/big-unsigned, LeftBin42/binary>> = LeftBin41,
  755. <<ListBin8:Len10/big-binary-unit:64, LeftBin43/binary>> = LeftBin42,
  756. V40 = [TemV || <<TemV:64/big-signed>> <= ListBin8],
  757. <<Len11:16/big-unsigned, LeftBin44/binary>> = LeftBin43,
  758. <<ListBin9:Len11/big-binary-unit:64, LeftBin45/binary>> = LeftBin44,
  759. V41 = [TemV || <<TemV:64/big-unsigned>> <= ListBin9],
  760. <<Len12:16/big-unsigned, LeftBin46/binary>> = LeftBin45,
  761. {V42, LeftBin47} = deIntegerList(Len12, LeftBin46, []),
  762. <<Len13:16/big-unsigned, LeftBin48/binary>> = LeftBin47,
  763. {V43, LeftBin49} = deIntegerList(Len13, LeftBin48, []),
  764. <<Len14:16/big-unsigned, LeftBin50/binary>> = LeftBin49,
  765. {V44, LeftBin51} = deIntegerList(Len14, LeftBin50, []),
  766. <<Len15:16/big-unsigned, LeftBin52/binary>> = LeftBin51,
  767. {V45, LeftBin53} = deIntegerList(Len15, LeftBin52, []),
  768. <<Len16:16/big-unsigned, LeftBin54/binary>> = LeftBin53,
  769. {V46, LeftBin55} = deNumberList(Len16, LeftBin54, []),
  770. <<Len17:16/big-unsigned, LeftBin56/binary>> = LeftBin55,
  771. {V47, LeftBin57} = deNumberList(Len17, LeftBin56, []),
  772. <<Len18:16/big-unsigned, LeftBin58/binary>> = LeftBin57,
  773. {V48, LeftBin59} = deNumberList(Len18, LeftBin58, []),
  774. <<Len19:16/big-unsigned, LeftBin60/binary>> = LeftBin59,
  775. {V49, LeftBin61} = deNumberList(Len19, LeftBin60, []),
  776. <<Len20:16/big-unsigned, LeftBin62/binary>> = LeftBin61,
  777. {V50, LeftBin63} = deNumberList(Len20, LeftBin62, []),
  778. <<Len21:16/big-unsigned, LeftBin64/binary>> = LeftBin63,
  779. {V51, LeftBin65} = deNumberList(Len21, LeftBin64, []),
  780. <<Len22:16/big-unsigned, LeftBin66/binary>> = LeftBin65,
  781. <<ListBin20:Len22/big-binary-unit:32, LeftBin67/binary>> = LeftBin66,
  782. V52 = [TemV || <<TemV:32/big-float>> <= ListBin20],
  783. <<Len23:16/big-unsigned, LeftBin68/binary>> = LeftBin67,
  784. <<ListBin21:Len23/big-binary-unit:64, LeftBin69/binary>> = LeftBin68,
  785. V53 = [TemV || <<TemV:64/big-float>> <= ListBin21],
  786. <<Len24:16/big-unsigned, LeftBin70/binary>> = LeftBin69,
  787. {V54, LeftBin71} = deStringList(Len24, LeftBin70, RefSize, []),
  788. <<Len25:16/big-unsigned, LeftBin72/binary>> = LeftBin71,
  789. {V55, LeftBin73} = deRecordList(Len25, 5, LeftBin72, []),
  790. {allType, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18, V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36, V37, V38, V39, V40, V41, V42, V43, V44, V45, V46, V47, V48, V49, V50, V51, V52, V53, V54, V55};
  791. decodeBin(1001, LeftBin0) ->
  792. RefSize = binary:referenced_byte_size(LeftBin0),
  793. <<Len1:16/big-unsigned, TemStrV1:Len1/binary, LeftBin1/binary>> = LeftBin0,
  794. case Len1 < ?BinaryShareSize of
  795. true ->
  796. V1 = TemStrV1;
  797. _ ->
  798. case RefSize / Len1 > ?BinaryCopyRatio of
  799. true ->
  800. V1 = binary:copy(TemStrV1);
  801. _ ->
  802. V1 = TemStrV1
  803. end
  804. end,
  805. <<V2:32/big-signed, LeftBin2/binary>> = LeftBin1,
  806. <<Len2:16/big-unsigned, TemStrV3:Len2/binary, LeftBin3/binary>> = LeftBin2,
  807. case Len2 < ?BinaryShareSize of
  808. true ->
  809. V3 = TemStrV3;
  810. _ ->
  811. case RefSize / Len2 > ?BinaryCopyRatio of
  812. true ->
  813. V3 = binary:copy(TemStrV3);
  814. _ ->
  815. V3 = TemStrV3
  816. end
  817. end,
  818. <<Len3:16/big-unsigned, LeftBin4/binary>> = LeftBin3,
  819. {V4, LeftBin5} = deRecordList(Len3, 2, LeftBin4, []),
  820. {person1, V1, V2, V3, V4};
  821. decodeBin(_, _) ->
  822. {{}, <<>>}.