Sync with 5.3.0
[deliverable/titan.core.git] / core / Addfunc.hh
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 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 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef ADDFUNC_HH
9 #define ADDFUNC_HH
10
11 #include "Types.h"
12
13 class INTEGER;
14 class FLOAT;
15 class BITSTRING;
16 class BITSTRING_ELEMENT;
17 class HEXSTRING;
18 class HEXSTRING_ELEMENT;
19 class OCTETSTRING;
20 class OCTETSTRING_ELEMENT;
21 class CHARSTRING;
22 class CHARSTRING_ELEMENT;
23 class UNIVERSAL_CHARSTRING;
24 class UNIVERSAL_CHARSTRING_ELEMENT;
25 class BITSTRING_template;
26 class HEXSTRING_template;
27 class OCTETSTRING_template;
28 class CHARSTRING_template;
29 class UNIVERSAL_CHARSTRING_template;
30
31 extern char hexdigit_to_char(unsigned char hexdigit);
32
33 // Additional predefined functions defined in Annex C of ES 101 873-1
34
35 // C.1 - int2char
36 extern CHARSTRING int2char(int value);
37 extern CHARSTRING int2char(const INTEGER& value);
38
39 // C.2 - int2unichar
40 extern UNIVERSAL_CHARSTRING int2unichar(int value);
41 extern UNIVERSAL_CHARSTRING int2unichar(const INTEGER& value);
42
43 // C.3 - int2bit
44 extern BITSTRING int2bit(int value, int length);
45 extern BITSTRING int2bit(int value, const INTEGER& length);
46 extern BITSTRING int2bit(const INTEGER& value, int length);
47 extern BITSTRING int2bit(const INTEGER& value, const INTEGER& length);
48
49 // C.4 - int2hex
50 extern HEXSTRING int2hex(int value, int length);
51 extern HEXSTRING int2hex(int value, const INTEGER& length);
52 extern HEXSTRING int2hex(const INTEGER& value, int length);
53 extern HEXSTRING int2hex(const INTEGER& value, const INTEGER& length);
54
55 // C.5 - int2oct
56 extern OCTETSTRING int2oct(int value, int length);
57 extern OCTETSTRING int2oct(int value, const INTEGER& length);
58 extern OCTETSTRING int2oct(const INTEGER& value, int length);
59 extern OCTETSTRING int2oct(const INTEGER& value, const INTEGER& length);
60
61 // C.6 - int2str
62 extern CHARSTRING int2str(int value);
63 extern CHARSTRING int2str(const INTEGER& value);
64
65 // C.7 - int2float
66 extern double int2float(int value);
67 extern double int2float(const INTEGER& value);
68
69 // C.8 - float2int
70 extern INTEGER float2int(double value);
71 extern INTEGER float2int(const FLOAT& value);
72
73 // C.9 - char2int
74 extern int char2int(char value);
75 extern int char2int(const char *value);
76 extern int char2int(const CHARSTRING& value);
77 extern int char2int(const CHARSTRING_ELEMENT& value);
78
79 // C.10 - char2oct
80 extern OCTETSTRING char2oct(const char *value);
81 extern OCTETSTRING char2oct(const CHARSTRING& value);
82 extern OCTETSTRING char2oct(const CHARSTRING_ELEMENT& value);
83
84 // C.11 - unichar2int
85 extern int unichar2int(const universal_char& value);
86 extern int unichar2int(const UNIVERSAL_CHARSTRING& value);
87 extern int unichar2int(const UNIVERSAL_CHARSTRING_ELEMENT& value);
88
89 // C.12 - bit2int
90 extern INTEGER bit2int(const BITSTRING& value);
91 extern INTEGER bit2int(const BITSTRING_ELEMENT& value);
92
93 // C.13 - bit2hex
94 extern HEXSTRING bit2hex(const BITSTRING& value);
95 extern HEXSTRING bit2hex(const BITSTRING_ELEMENT& value);
96
97 // C.14 - bit2oct
98 extern OCTETSTRING bit2oct(const BITSTRING& value);
99 extern OCTETSTRING bit2oct(const BITSTRING_ELEMENT& value);
100
101 // C.15 - bit2str
102 extern CHARSTRING bit2str(const BITSTRING& value);
103 extern CHARSTRING bit2str(const BITSTRING_ELEMENT& value);
104
105 // C.16 - hex2int
106 extern INTEGER hex2int(const HEXSTRING& value);
107 extern INTEGER hex2int(const HEXSTRING_ELEMENT& value);
108
109 // C.17 - hex2bit
110 extern BITSTRING hex2bit(const HEXSTRING& value);
111 extern BITSTRING hex2bit(const HEXSTRING_ELEMENT& value);
112
113 // C.18 - hex2oct
114 extern OCTETSTRING hex2oct(const HEXSTRING& value);
115 extern OCTETSTRING hex2oct(const HEXSTRING_ELEMENT& value);
116
117 // C.19 - hex2str
118 extern CHARSTRING hex2str(const HEXSTRING& value);
119 extern CHARSTRING hex2str(const HEXSTRING_ELEMENT& value);
120
121 // C.20 - oct2int
122 extern INTEGER oct2int(const OCTETSTRING& value);
123 extern INTEGER oct2int(const OCTETSTRING_ELEMENT& value);
124
125 // C.21 - oct2bit
126 extern BITSTRING oct2bit(const OCTETSTRING& value);
127 extern BITSTRING oct2bit(const OCTETSTRING_ELEMENT& value);
128
129 // C.22 - oct2hex
130 extern HEXSTRING oct2hex(const OCTETSTRING& value);
131 extern HEXSTRING oct2hex(const OCTETSTRING_ELEMENT& value);
132
133 // C.23 - oct2str
134 extern CHARSTRING oct2str(const OCTETSTRING& value);
135 extern CHARSTRING oct2str(const OCTETSTRING_ELEMENT& value);
136
137 // C.24 - oct2char
138 extern CHARSTRING oct2char(const OCTETSTRING& value);
139 extern CHARSTRING oct2char(const OCTETSTRING_ELEMENT& value);
140
141 // C.25 - str2int
142 extern INTEGER str2int(const char *value);
143 extern INTEGER str2int(const CHARSTRING& value);
144 extern INTEGER str2int(const CHARSTRING_ELEMENT& value);
145
146 // C.26 - str2oct
147 extern OCTETSTRING str2oct(const char *value);
148 extern OCTETSTRING str2oct(const CHARSTRING& value);
149
150 // C.27 - str2float
151 extern double str2float(const char *value);
152 extern double str2float(const CHARSTRING& value);
153
154 // C.28 - lengthof: built-in
155
156 // C.29 - sizeof: built-in
157
158 // C.31 - ispresent: built-in
159
160 // C.32 - ischosen: built-in
161
162 // C.33 - regexp
163 extern CHARSTRING regexp(const CHARSTRING& instr, const CHARSTRING& expression,
164 int groupno);
165 extern CHARSTRING regexp(const CHARSTRING& instr, const CHARSTRING& expression,
166 const INTEGER& groupno);
167 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
168 const UNIVERSAL_CHARSTRING* expression_val,
169 const UNIVERSAL_CHARSTRING_template* expression_tmpl,
170 int groupno);
171 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
172 const UNIVERSAL_CHARSTRING& expression, int groupno);
173 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
174 const UNIVERSAL_CHARSTRING& expression, const INTEGER& groupno);
175 // regexp on templates
176 extern CHARSTRING regexp(const CHARSTRING_template& instr,
177 const CHARSTRING_template& expression, int groupno);
178 extern CHARSTRING regexp(const CHARSTRING_template& instr,
179 const CHARSTRING_template& expression, const INTEGER& groupno);
180 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING_template& instr,
181 const UNIVERSAL_CHARSTRING_template& expression, int groupno);
182 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING_template& instr,
183 const UNIVERSAL_CHARSTRING_template& expression, const INTEGER& groupno);
184
185 // C.34 - substr
186 extern void check_substr_arguments(int value_length, int index,
187 int returncount, const char *string_type, const char *element_name);
188 extern BITSTRING substr(const BITSTRING& value, int index, int returncount);
189 extern BITSTRING substr(const BITSTRING& value, int index,
190 const INTEGER& returncount);
191 extern BITSTRING substr(const BITSTRING& value, const INTEGER& index,
192 int returncount);
193 extern BITSTRING substr(const BITSTRING& value, const INTEGER& index,
194 const INTEGER& returncount);
195 extern BITSTRING substr(const BITSTRING_ELEMENT& value, int index,
196 int returncount);
197 extern BITSTRING substr(const BITSTRING_ELEMENT& value, int index,
198 const INTEGER& returncount);
199 extern BITSTRING substr(const BITSTRING_ELEMENT& value, const INTEGER& index,
200 int returncount);
201 extern BITSTRING substr(const BITSTRING_ELEMENT& value, const INTEGER& index,
202 const INTEGER& returncount);
203
204 extern HEXSTRING substr(const HEXSTRING& value, int index, int returncount);
205 extern HEXSTRING substr(const HEXSTRING& value, int index,
206 const INTEGER& returncount);
207 extern HEXSTRING substr(const HEXSTRING& value, const INTEGER& index,
208 int returncount);
209 extern HEXSTRING substr(const HEXSTRING& value, const INTEGER& index,
210 const INTEGER& returncount);
211 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, int index,
212 int returncount);
213 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, int index,
214 const INTEGER& returncount);
215 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, const INTEGER& index,
216 int returncount);
217 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, const INTEGER& index,
218 const INTEGER& returncount);
219
220 extern OCTETSTRING substr(const OCTETSTRING& value, int index,
221 int returncount);
222 extern OCTETSTRING substr(const OCTETSTRING& value, int index,
223 const INTEGER& returncount);
224 extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
225 int returncount);
226 extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
227 const INTEGER& returncount);
228 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value, int index,
229 int returncount);
230 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value, int index,
231 const INTEGER& returncount);
232 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value,
233 const INTEGER& index, int returncount);
234 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value,
235 const INTEGER& index, const INTEGER& returncount);
236
237 extern CHARSTRING substr(const CHARSTRING& value, int index,
238 int returncount);
239 extern CHARSTRING substr(const CHARSTRING& value, int index,
240 const INTEGER& returncount);
241 extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
242 int returncount);
243 extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
244 const INTEGER& returncount);
245 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value, int index,
246 int returncount);
247 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value, int index,
248 const INTEGER& returncount);
249 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value,
250 const INTEGER& index, int returncount);
251 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value,
252 const INTEGER& index, const INTEGER& returncount);
253
254 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
255 int index, int returncount);
256 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
257 int index, const INTEGER& returncount);
258 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
259 const INTEGER& index, int returncount);
260 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
261 const INTEGER& index, const INTEGER& returncount);
262 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
263 int index, int returncount);
264 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
265 int index, const INTEGER& returncount);
266 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
267 const INTEGER& index, int returncount);
268 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
269 const INTEGER& index, const INTEGER& returncount);
270
271 // substr for templates
272 extern BITSTRING substr(const BITSTRING_template& value, int index,
273 int returncount);
274 extern BITSTRING substr(const BITSTRING_template& value, int index,
275 const INTEGER& returncount);
276 extern BITSTRING substr(const BITSTRING_template& value, const INTEGER& index,
277 int returncount);
278 extern BITSTRING substr(const BITSTRING_template& value, const INTEGER& index,
279 const INTEGER& returncount);
280
281 extern HEXSTRING substr(const HEXSTRING_template& value, int index,
282 int returncount);
283 extern HEXSTRING substr(const HEXSTRING_template& value, int index,
284 const INTEGER& returncount);
285 extern HEXSTRING substr(const HEXSTRING_template& value, const INTEGER& index,
286 int returncount);
287 extern HEXSTRING substr(const HEXSTRING_template& value, const INTEGER& index,
288 const INTEGER& returncount);
289
290 extern OCTETSTRING substr(const OCTETSTRING_template& value, int index,
291 int returncount);
292 extern OCTETSTRING substr(const OCTETSTRING_template& value, int index,
293 const INTEGER& returncount);
294 extern OCTETSTRING substr(const OCTETSTRING_template& value, const INTEGER& index,
295 int returncount);
296 extern OCTETSTRING substr(const OCTETSTRING_template& value, const INTEGER& index,
297 const INTEGER& returncount);
298
299 extern CHARSTRING substr(const CHARSTRING_template& value, int index,
300 int returncount);
301 extern CHARSTRING substr(const CHARSTRING_template& value, int index,
302 const INTEGER& returncount);
303 extern CHARSTRING substr(const CHARSTRING_template& value, const INTEGER& index,
304 int returncount);
305 extern CHARSTRING substr(const CHARSTRING_template& value, const INTEGER& index,
306 const INTEGER& returncount);
307
308 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
309 int index, int returncount);
310 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
311 int index, const INTEGER& returncount);
312 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
313 const INTEGER& index, int returncount);
314 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
315 const INTEGER& index, const INTEGER& returncount);
316
317 // C.35 - replace
318 extern void check_replace_arguments(int value_length, int index, int len,
319 const char *string_type, const char *element_name);
320 extern BITSTRING replace(const BITSTRING& value, int index, int len,
321 const BITSTRING& repl);
322 extern BITSTRING replace(const BITSTRING& value, int index,
323 const INTEGER& len, const BITSTRING& repl);
324 extern BITSTRING replace(const BITSTRING& value, const INTEGER& index,
325 int len, const BITSTRING& repl);
326 extern BITSTRING replace(const BITSTRING& value, const INTEGER& index,
327 const INTEGER& len, const BITSTRING& repl);
328
329 extern HEXSTRING replace(const HEXSTRING& value, int index, int len,
330 const HEXSTRING& repl);
331 extern HEXSTRING replace(const HEXSTRING& value, int index,
332 const INTEGER& len, const HEXSTRING& repl);
333 extern HEXSTRING replace(const HEXSTRING& value, const INTEGER& index,
334 int len, const HEXSTRING& repl);
335 extern HEXSTRING replace(const HEXSTRING& value, const INTEGER& index,
336 const INTEGER& len, const HEXSTRING& repl);
337
338 extern OCTETSTRING replace(const OCTETSTRING& value, int index, int len,
339 const OCTETSTRING& repl);
340 extern OCTETSTRING replace(const OCTETSTRING& value, int index,
341 const INTEGER& len, const OCTETSTRING& repl);
342 extern OCTETSTRING replace(const OCTETSTRING& value, const INTEGER& index,
343 int len, const OCTETSTRING& repl);
344 extern OCTETSTRING replace(const OCTETSTRING& value, const INTEGER& index,
345 const INTEGER& len, const OCTETSTRING& repl);
346
347 extern CHARSTRING replace(const CHARSTRING& value, int index, int len,
348 const CHARSTRING& repl);
349 extern CHARSTRING replace(const CHARSTRING& value, int index,
350 const INTEGER& len, const CHARSTRING& repl);
351 extern CHARSTRING replace(const CHARSTRING& value, const INTEGER& index,
352 int len, const CHARSTRING& repl);
353 extern CHARSTRING replace(const CHARSTRING& value, const INTEGER& index,
354 const INTEGER& len, const CHARSTRING& repl);
355
356 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
357 int index, int len, const UNIVERSAL_CHARSTRING& repl);
358 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
359 int index, const INTEGER& len, const UNIVERSAL_CHARSTRING& repl);
360 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
361 const INTEGER& index, int len, const UNIVERSAL_CHARSTRING& repl);
362 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
363 const INTEGER& index, const INTEGER& len,
364 const UNIVERSAL_CHARSTRING& repl);
365 // replace - template parameters
366 extern BITSTRING replace(const BITSTRING_template& value, int index, int len,
367 const BITSTRING_template& repl);
368 extern BITSTRING replace(const BITSTRING_template& value, int index,
369 const INTEGER& len, const BITSTRING_template& repl);
370 extern BITSTRING replace(const BITSTRING_template& value, const INTEGER& index,
371 int len, const BITSTRING_template& repl);
372 extern BITSTRING replace(const BITSTRING_template& value, const INTEGER& index,
373 const INTEGER& len, const BITSTRING_template& repl);
374
375 extern HEXSTRING replace(const HEXSTRING_template& value, int index, int len,
376 const HEXSTRING_template& repl);
377 extern HEXSTRING replace(const HEXSTRING_template& value, int index,
378 const INTEGER& len, const HEXSTRING_template& repl);
379 extern HEXSTRING replace(const HEXSTRING_template& value, const INTEGER& index,
380 int len, const HEXSTRING_template& repl);
381 extern HEXSTRING replace(const HEXSTRING_template& value, const INTEGER& index,
382 const INTEGER& len, const HEXSTRING_template& repl);
383
384 extern OCTETSTRING replace(const OCTETSTRING_template& value, int index, int len,
385 const OCTETSTRING& repl);
386 extern OCTETSTRING replace(const OCTETSTRING_template& value, int index,
387 const INTEGER& len, const OCTETSTRING& repl);
388 extern OCTETSTRING replace(const OCTETSTRING_template& value, const INTEGER& index,
389 int len, const OCTETSTRING_template& repl);
390 extern OCTETSTRING replace(const OCTETSTRING_template& value, const INTEGER& index,
391 const INTEGER& len, const OCTETSTRING_template& repl);
392
393 extern CHARSTRING replace(const CHARSTRING_template& value, int index, int len,
394 const CHARSTRING_template& repl);
395 extern CHARSTRING replace(const CHARSTRING_template& value, int index,
396 const INTEGER& len, const CHARSTRING_template& repl);
397 extern CHARSTRING replace(const CHARSTRING_template& value, const INTEGER& index,
398 int len, const CHARSTRING_template& repl);
399 extern CHARSTRING replace(const CHARSTRING_template& value, const INTEGER& index,
400 const INTEGER& len, const CHARSTRING_template& repl);
401
402 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
403 int index, int len, const UNIVERSAL_CHARSTRING_template& repl);
404 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
405 int index, const INTEGER& len, const UNIVERSAL_CHARSTRING_template& repl);
406 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
407 const INTEGER& index, int len, const UNIVERSAL_CHARSTRING_template& repl);
408 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
409 const INTEGER& index, const INTEGER& len,
410 const UNIVERSAL_CHARSTRING_template& repl);
411
412
413 // C.36 - rnd
414 extern double rnd();
415 extern double rnd(double seed);
416 extern double rnd(const FLOAT& seed);
417
418
419 // Additional predefined functions defined in Annex B of ES 101 873-7
420
421 // B.1 decomp - not implemented yet
422
423
424 // Non-standard functions
425
426 // str2bit
427 extern BITSTRING str2bit(const char *value);
428 extern BITSTRING str2bit(const CHARSTRING& value);
429 extern BITSTRING str2bit(const CHARSTRING_ELEMENT& value);
430
431 // str2hex
432 extern HEXSTRING str2hex(const char *value);
433 extern HEXSTRING str2hex(const CHARSTRING& value);
434 extern HEXSTRING str2hex(const CHARSTRING_ELEMENT& value);
435
436 // float2str
437 extern CHARSTRING float2str(double value);
438 extern CHARSTRING float2str(const FLOAT& value);
439
440 // unichar2char
441 extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING& value);
442 extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING_ELEMENT& value);
443
444 // only for internal purposes
445 extern CHARSTRING get_port_name(const char *port_name, int array_index);
446 extern CHARSTRING get_port_name(const char *port_name,
447 const INTEGER& array_index);
448 extern CHARSTRING get_port_name(const CHARSTRING& port_name, int array_index);
449 extern CHARSTRING get_port_name(const CHARSTRING& port_name,
450 const INTEGER& array_index);
451
452 unsigned char char_to_hexdigit(char c);
453
454 // unichar2oct
455 extern OCTETSTRING unichar2oct(const UNIVERSAL_CHARSTRING& invalue); // default string_encoding UTF-8
456 extern OCTETSTRING unichar2oct(const UNIVERSAL_CHARSTRING& invalue,
457 const CHARSTRING& string_encoding);
458 //oct2unichar
459 extern UNIVERSAL_CHARSTRING oct2unichar(const OCTETSTRING& invalue ); // default string_encoding UTF-8
460 extern UNIVERSAL_CHARSTRING oct2unichar(const OCTETSTRING& invalue,
461 const CHARSTRING& string_encoding);
462
463 extern CHARSTRING get_stringencoding(const OCTETSTRING& encoded__value);
464 extern OCTETSTRING remove_bom(const OCTETSTRING& encoded__value);
465 extern CHARSTRING encode_base64(const OCTETSTRING& msg, bool use_linebreaks);
466 extern CHARSTRING encode_base64(const OCTETSTRING& msg);
467 extern OCTETSTRING decode_base64(const CHARSTRING& b64);
468
469 #endif
This page took 0.041232 seconds and 5 git commands to generate.