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 ///////////////////////////////////////////////////////////////////////////////
16 class BITSTRING_ELEMENT;
18 class HEXSTRING_ELEMENT;
20 class OCTETSTRING_ELEMENT;
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;
31 extern char hexdigit_to_char(unsigned char hexdigit);
33 // Additional predefined functions defined in Annex C of ES 101 873-1
36 extern CHARSTRING int2char(int value);
37 extern CHARSTRING int2char(const INTEGER& value);
40 extern UNIVERSAL_CHARSTRING int2unichar(int value);
41 extern UNIVERSAL_CHARSTRING int2unichar(const INTEGER& value);
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);
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);
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);
62 extern CHARSTRING int2str(int value);
63 extern CHARSTRING int2str(const INTEGER& value);
66 extern double int2float(int value);
67 extern double int2float(const INTEGER& value);
70 extern INTEGER float2int(double value);
71 extern INTEGER float2int(const FLOAT& value);
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);
80 extern OCTETSTRING char2oct(const char *value);
81 extern OCTETSTRING char2oct(const CHARSTRING& value);
82 extern OCTETSTRING char2oct(const CHARSTRING_ELEMENT& value);
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);
90 extern INTEGER bit2int(const BITSTRING& value);
91 extern INTEGER bit2int(const BITSTRING_ELEMENT& value);
94 extern HEXSTRING bit2hex(const BITSTRING& value);
95 extern HEXSTRING bit2hex(const BITSTRING_ELEMENT& value);
98 extern OCTETSTRING bit2oct(const BITSTRING& value);
99 extern OCTETSTRING bit2oct(const BITSTRING_ELEMENT& value);
102 extern CHARSTRING bit2str(const BITSTRING& value);
103 extern CHARSTRING bit2str(const BITSTRING_ELEMENT& value);
106 extern INTEGER hex2int(const HEXSTRING& value);
107 extern INTEGER hex2int(const HEXSTRING_ELEMENT& value);
110 extern BITSTRING hex2bit(const HEXSTRING& value);
111 extern BITSTRING hex2bit(const HEXSTRING_ELEMENT& value);
114 extern OCTETSTRING hex2oct(const HEXSTRING& value);
115 extern OCTETSTRING hex2oct(const HEXSTRING_ELEMENT& value);
118 extern CHARSTRING hex2str(const HEXSTRING& value);
119 extern CHARSTRING hex2str(const HEXSTRING_ELEMENT& value);
122 extern INTEGER oct2int(const OCTETSTRING& value);
123 extern INTEGER oct2int(const OCTETSTRING_ELEMENT& value);
126 extern BITSTRING oct2bit(const OCTETSTRING& value);
127 extern BITSTRING oct2bit(const OCTETSTRING_ELEMENT& value);
130 extern HEXSTRING oct2hex(const OCTETSTRING& value);
131 extern HEXSTRING oct2hex(const OCTETSTRING_ELEMENT& value);
134 extern CHARSTRING oct2str(const OCTETSTRING& value);
135 extern CHARSTRING oct2str(const OCTETSTRING_ELEMENT& value);
138 extern CHARSTRING oct2char(const OCTETSTRING& value);
139 extern CHARSTRING oct2char(const OCTETSTRING_ELEMENT& value);
142 extern INTEGER str2int(const char *value);
143 extern INTEGER str2int(const CHARSTRING& value);
144 extern INTEGER str2int(const CHARSTRING_ELEMENT& value);
147 extern OCTETSTRING str2oct(const char *value);
148 extern OCTETSTRING str2oct(const CHARSTRING& value);
151 extern double str2float(const char *value);
152 extern double str2float(const CHARSTRING& value);
154 // C.28 - lengthof: built-in
156 // C.29 - sizeof: built-in
158 // C.31 - ispresent: built-in
160 // C.32 - ischosen: built-in
163 extern CHARSTRING regexp(const CHARSTRING& instr, const CHARSTRING& expression,
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,
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);
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,
193 extern BITSTRING substr(const BITSTRING& value, const INTEGER& index,
194 const INTEGER& returncount);
195 extern BITSTRING substr(const BITSTRING_ELEMENT& value, int index,
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,
201 extern BITSTRING substr(const BITSTRING_ELEMENT& value, const INTEGER& index,
202 const INTEGER& returncount);
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,
209 extern HEXSTRING substr(const HEXSTRING& value, const INTEGER& index,
210 const INTEGER& returncount);
211 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, int index,
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,
217 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, const INTEGER& index,
218 const INTEGER& returncount);
220 extern OCTETSTRING substr(const OCTETSTRING& value, int index,
222 extern OCTETSTRING substr(const OCTETSTRING& value, int index,
223 const INTEGER& returncount);
224 extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
226 extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
227 const INTEGER& returncount);
228 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value, int index,
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);
237 extern CHARSTRING substr(const CHARSTRING& value, int index,
239 extern CHARSTRING substr(const CHARSTRING& value, int index,
240 const INTEGER& returncount);
241 extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
243 extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
244 const INTEGER& returncount);
245 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value, int index,
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);
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);
271 // substr for templates
272 extern BITSTRING substr(const BITSTRING_template& value, int index,
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,
278 extern BITSTRING substr(const BITSTRING_template& value, const INTEGER& index,
279 const INTEGER& returncount);
281 extern HEXSTRING substr(const HEXSTRING_template& value, int index,
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,
287 extern HEXSTRING substr(const HEXSTRING_template& value, const INTEGER& index,
288 const INTEGER& returncount);
290 extern OCTETSTRING substr(const OCTETSTRING_template& value, int index,
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,
296 extern OCTETSTRING substr(const OCTETSTRING_template& value, const INTEGER& index,
297 const INTEGER& returncount);
299 extern CHARSTRING substr(const CHARSTRING_template& value, int index,
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,
305 extern CHARSTRING substr(const CHARSTRING_template& value, const INTEGER& index,
306 const INTEGER& returncount);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
415 extern double rnd(double seed);
416 extern double rnd(const FLOAT& seed);
419 // Additional predefined functions defined in Annex B of ES 101 873-7
421 // B.1 decomp - not implemented yet
424 // Non-standard functions
427 extern BITSTRING str2bit(const char *value);
428 extern BITSTRING str2bit(const CHARSTRING& value);
429 extern BITSTRING str2bit(const CHARSTRING_ELEMENT& value);
432 extern HEXSTRING str2hex(const char *value);
433 extern HEXSTRING str2hex(const CHARSTRING& value);
434 extern HEXSTRING str2hex(const CHARSTRING_ELEMENT& value);
437 extern CHARSTRING float2str(double value);
438 extern CHARSTRING float2str(const FLOAT& value);
441 extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING& value);
442 extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING_ELEMENT& value);
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);
452 unsigned char char_to_hexdigit(char c);
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);
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);
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);