1 /******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
11 using Custom1::c__separator
;
15 BITSTRING
f__enc__rec(const Custom3::Rec
& x
)
17 return int2bit(x
.num(), 8);
20 INTEGER
f__dec__rec(BITSTRING
& b
, Custom3::Rec
& x
)
27 BITSTRING
f__enc__uni(const Custom1::Uni
& x
)
29 if (x
.get_selection() == Custom1::Uni::ALT_i
) {
30 return c__separator
+ int2bit(x
.i(), 8) + c__separator
;
33 return c__separator
+ c__separator
;
37 INTEGER
f__dec__uni(BITSTRING
& b
, Custom1::Uni
& x
)
39 int b_len
= b
.lengthof();
40 int sep_len
= c__separator
.lengthof();
41 if (b_len
>= 2 * sep_len
&&
42 substr(b
, 0, sep_len
) == c__separator
&&
43 substr(b
, b_len
- sep_len
, sep_len
) == c__separator
) {
44 if (b_len
> 2 * sep_len
) {
45 x
.i() = bit2int(substr(b
, sep_len
, b_len
- 2 * sep_len
));
54 } // namespace Custom2
58 BITSTRING
f__enc__recof(const RecOf
& x
)
61 for (int i
= 1; i
< x
.size_of(); ++i
) {
62 res
= res
+ c__separator
+ x
[i
];
67 int find_bitstring(const BITSTRING
& src
, int start
, const BITSTRING
& fnd
)
69 int len
= fnd
.lengthof();
70 for (int i
= start
; i
<= src
.lengthof() - len
; ++i
) {
71 if (substr(src
, i
, len
) == fnd
) {
78 INTEGER
f__dec__recof(BITSTRING
& b
, RecOf
& x
)
81 int end
= find_bitstring(b
, start
, c__separator
);
84 x
[index
] = substr(b
, start
, end
- start
);
86 start
= end
+ c__separator
.lengthof();
87 end
= find_bitstring(b
, start
, c__separator
);
89 x
[index
] = substr(b
, start
, b
.lengthof() - start
);
93 } // namespace Custom1
This page took 0.032164 seconds and 5 git commands to generate.