Addfunc.hh 20.7 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
/******************************************************************************
balaskoa's avatar
balaskoa committed
2
 * Copyright (c) 2000-2020 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v2.0
Elemer Lelik's avatar
Elemer Lelik committed
5
 * which accompanies this distribution, and is available at
6
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Elemer Lelik's avatar
Elemer Lelik committed
7
8
9
10
11
12
13
14
15
 *
 * Contributors:
 *   Baji, Laszlo
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Delic, Adam
 *   Forstner, Matyas
 *   Kovacs, Ferenc
 *   Raduly, Csaba
16
 *   Szabo, Bence Janos
Elemer Lelik's avatar
Elemer Lelik committed
17
18
19
20
 *   Szabo, Janos Zoltan – initial implementation
 *   Zalanyi, Balazs Andor
 *
 ******************************************************************************/
Elemer Lelik's avatar
Elemer Lelik committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef ADDFUNC_HH
#define ADDFUNC_HH

#include "Types.h"

class INTEGER;
class FLOAT;
class BITSTRING;
class BITSTRING_ELEMENT;
class HEXSTRING;
class HEXSTRING_ELEMENT;
class OCTETSTRING;
class OCTETSTRING_ELEMENT;
class CHARSTRING;
class CHARSTRING_ELEMENT;
class UNIVERSAL_CHARSTRING;
class UNIVERSAL_CHARSTRING_ELEMENT;
class BITSTRING_template;
class HEXSTRING_template;
class OCTETSTRING_template;
class CHARSTRING_template;
class UNIVERSAL_CHARSTRING_template;

44
45
// Helper functions

Elemer Lelik's avatar
Elemer Lelik committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
extern char hexdigit_to_char(unsigned char hexdigit);

// Additional predefined functions defined in Annex C of ES 101 873-1

// C.1 - int2char
extern CHARSTRING int2char(int value);
extern CHARSTRING int2char(const INTEGER& value);

// C.2 - int2unichar
extern UNIVERSAL_CHARSTRING int2unichar(int value);
extern UNIVERSAL_CHARSTRING int2unichar(const INTEGER& value);

// C.3 - int2bit
extern BITSTRING int2bit(int value, int length);
extern BITSTRING int2bit(int value, const INTEGER& length);
extern BITSTRING int2bit(const INTEGER& value, int length);
extern BITSTRING int2bit(const INTEGER& value, const INTEGER& length);

// C.4 - int2hex
extern HEXSTRING int2hex(int value, int length);
extern HEXSTRING int2hex(int value, const INTEGER& length);
extern HEXSTRING int2hex(const INTEGER& value, int length);
extern HEXSTRING int2hex(const INTEGER& value, const INTEGER& length);

// C.5 - int2oct
extern OCTETSTRING int2oct(int value, int length);
extern OCTETSTRING int2oct(int value, const INTEGER& length);
extern OCTETSTRING int2oct(const INTEGER& value, int length);
extern OCTETSTRING int2oct(const INTEGER& value, const INTEGER& length);

// C.6 - int2str
extern CHARSTRING int2str(int value);
extern CHARSTRING int2str(const INTEGER& value);

// C.7 - int2float
extern double int2float(int value);
extern double int2float(const INTEGER& value);

// C.8 - float2int
extern INTEGER float2int(double value);
extern INTEGER float2int(const FLOAT& value);

// C.9 - char2int
extern int char2int(char value);
extern int char2int(const char *value);
extern int char2int(const CHARSTRING& value);
extern int char2int(const CHARSTRING_ELEMENT& value);

// C.10 - char2oct
extern OCTETSTRING char2oct(const char *value);
extern OCTETSTRING char2oct(const CHARSTRING& value);
extern OCTETSTRING char2oct(const CHARSTRING_ELEMENT& value);

// C.11 - unichar2int
extern int unichar2int(const universal_char& value);
extern int unichar2int(const UNIVERSAL_CHARSTRING& value);
extern int unichar2int(const UNIVERSAL_CHARSTRING_ELEMENT& value);

// C.12 - bit2int
extern INTEGER bit2int(const BITSTRING& value);
extern INTEGER bit2int(const BITSTRING_ELEMENT& value);

// C.13 - bit2hex
extern HEXSTRING bit2hex(const BITSTRING& value);
extern HEXSTRING bit2hex(const BITSTRING_ELEMENT& value);

// C.14 - bit2oct
extern OCTETSTRING bit2oct(const BITSTRING& value);
extern OCTETSTRING bit2oct(const BITSTRING_ELEMENT& value);

// C.15 - bit2str
extern CHARSTRING bit2str(const BITSTRING& value);
extern CHARSTRING bit2str(const BITSTRING_ELEMENT& value);

// C.16 - hex2int
extern INTEGER hex2int(const HEXSTRING& value);
extern INTEGER hex2int(const HEXSTRING_ELEMENT& value);

// C.17 - hex2bit
extern BITSTRING hex2bit(const HEXSTRING& value);
extern BITSTRING hex2bit(const HEXSTRING_ELEMENT& value);

// C.18 - hex2oct
extern OCTETSTRING hex2oct(const HEXSTRING& value);
extern OCTETSTRING hex2oct(const HEXSTRING_ELEMENT& value);

// C.19 - hex2str
extern CHARSTRING hex2str(const HEXSTRING& value);
extern CHARSTRING hex2str(const HEXSTRING_ELEMENT& value);

// C.20 - oct2int
extern INTEGER oct2int(const OCTETSTRING& value);
extern INTEGER oct2int(const OCTETSTRING_ELEMENT& value);

// C.21 - oct2bit
extern BITSTRING oct2bit(const OCTETSTRING& value);
extern BITSTRING oct2bit(const OCTETSTRING_ELEMENT& value);

// C.22 - oct2hex
extern HEXSTRING oct2hex(const OCTETSTRING& value);
extern HEXSTRING oct2hex(const OCTETSTRING_ELEMENT& value);

// C.23 - oct2str
extern CHARSTRING oct2str(const OCTETSTRING& value);
extern CHARSTRING oct2str(const OCTETSTRING_ELEMENT& value);

// C.24 - oct2char
extern CHARSTRING oct2char(const OCTETSTRING& value);
extern CHARSTRING oct2char(const OCTETSTRING_ELEMENT& value);

// C.25 - str2int
extern INTEGER str2int(const char *value);
extern INTEGER str2int(const CHARSTRING& value);
extern INTEGER str2int(const CHARSTRING_ELEMENT& value);

// C.26 - str2oct
extern OCTETSTRING str2oct(const char *value);
extern OCTETSTRING str2oct(const CHARSTRING& value);

// C.27 - str2float
extern double str2float(const char *value);
extern double str2float(const CHARSTRING& value);

// C.28 - lengthof: built-in

// C.29 - sizeof: built-in

// C.31 - ispresent: built-in

// C.32 - ischosen: built-in

// C.33 - regexp
extern CHARSTRING regexp(const CHARSTRING& instr, const CHARSTRING& expression,
179
    int groupno, boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
180
extern CHARSTRING regexp(const CHARSTRING& instr, const CHARSTRING& expression,
181
    const INTEGER& groupno, boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
182
183
184
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
    const UNIVERSAL_CHARSTRING* expression_val,
    const UNIVERSAL_CHARSTRING_template* expression_tmpl,
185
    int groupno, boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
186
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
187
    const UNIVERSAL_CHARSTRING& expression, int groupno, boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
188
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
189
190
    const UNIVERSAL_CHARSTRING& expression, const INTEGER& groupno,
    boolean nocase);
191
192
193
194
195
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
    const CHARSTRING& expression, int groupno, boolean nocase);
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
    const CHARSTRING& expression, const INTEGER& groupno,
    boolean nocase);
196
197
198
199
extern CHARSTRING regexp(const CHARSTRING& instr,
    const UNIVERSAL_CHARSTRING& expression, int groupno, boolean nocase);
extern CHARSTRING regexp(const CHARSTRING& instr,
    const UNIVERSAL_CHARSTRING& expression, const INTEGER& groupno, boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
200
201
// regexp on templates
extern CHARSTRING regexp(const CHARSTRING_template& instr,
202
    const CHARSTRING_template& expression, int groupno, boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
203
extern CHARSTRING regexp(const CHARSTRING_template& instr,
204
205
    const CHARSTRING_template& expression, const INTEGER& groupno,
    boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
206
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING_template& instr,
207
208
    const UNIVERSAL_CHARSTRING_template& expression, int groupno,
    boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
209
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING_template& instr,
210
211
    const UNIVERSAL_CHARSTRING_template& expression, const INTEGER& groupno,
    boolean nocase);
Elemer Lelik's avatar
Elemer Lelik committed
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492

// C.34 - substr
extern void check_substr_arguments(int value_length, int index,
    int returncount, const char *string_type, const char *element_name);
extern BITSTRING substr(const BITSTRING& value, int index, int returncount);
extern BITSTRING substr(const BITSTRING& value, int index,
    const INTEGER& returncount);
extern BITSTRING substr(const BITSTRING& value, const INTEGER& index,
    int returncount);
extern BITSTRING substr(const BITSTRING& value, const INTEGER& index,
    const INTEGER& returncount);
extern BITSTRING substr(const BITSTRING_ELEMENT& value, int index,
    int returncount);
extern BITSTRING substr(const BITSTRING_ELEMENT& value, int index,
    const INTEGER& returncount);
extern BITSTRING substr(const BITSTRING_ELEMENT& value, const INTEGER& index,
    int returncount);
extern BITSTRING substr(const BITSTRING_ELEMENT& value, const INTEGER& index,
    const INTEGER& returncount);

extern HEXSTRING substr(const HEXSTRING& value, int index, int returncount);
extern HEXSTRING substr(const HEXSTRING& value, int index,
    const INTEGER& returncount);
extern HEXSTRING substr(const HEXSTRING& value, const INTEGER& index,
    int returncount);
extern HEXSTRING substr(const HEXSTRING& value, const INTEGER& index,
    const INTEGER& returncount);
extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, int index,
    int returncount);
extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, int index,
    const INTEGER& returncount);
extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, const INTEGER& index,
    int returncount);
extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, const INTEGER& index,
    const INTEGER& returncount);

extern OCTETSTRING substr(const OCTETSTRING& value, int index,
    int returncount);
extern OCTETSTRING substr(const OCTETSTRING& value, int index,
    const INTEGER& returncount);
extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
    int returncount);
extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
    const INTEGER& returncount);
extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value, int index,
    int returncount);
extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value, int index,
    const INTEGER& returncount);
extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value,
    const INTEGER& index, int returncount);
extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value,
    const INTEGER& index, const INTEGER& returncount);

extern CHARSTRING substr(const CHARSTRING& value, int index,
    int returncount);
extern CHARSTRING substr(const CHARSTRING& value, int index,
    const INTEGER& returncount);
extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
    int returncount);
extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
    const INTEGER& returncount);
extern CHARSTRING substr(const CHARSTRING_ELEMENT& value, int index,
    int returncount);
extern CHARSTRING substr(const CHARSTRING_ELEMENT& value, int index,
    const INTEGER& returncount);
extern CHARSTRING substr(const CHARSTRING_ELEMENT& value,
    const INTEGER& index, int returncount);
extern CHARSTRING substr(const CHARSTRING_ELEMENT& value,
    const INTEGER& index, const INTEGER& returncount);

extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
    int index, int returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
    int index, const INTEGER& returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
    const INTEGER& index, int returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
    const INTEGER& index, const INTEGER& returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
    int index, int returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
    int index, const INTEGER& returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
    const INTEGER& index, int returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
    const INTEGER& index, const INTEGER& returncount);

// substr for templates
extern BITSTRING substr(const BITSTRING_template& value, int index,
    int returncount);
extern BITSTRING substr(const BITSTRING_template& value, int index,
    const INTEGER& returncount);
extern BITSTRING substr(const BITSTRING_template& value, const INTEGER& index,
    int returncount);
extern BITSTRING substr(const BITSTRING_template& value, const INTEGER& index,
    const INTEGER& returncount);

extern HEXSTRING substr(const HEXSTRING_template& value, int index,
    int returncount);
extern HEXSTRING substr(const HEXSTRING_template& value, int index,
    const INTEGER& returncount);
extern HEXSTRING substr(const HEXSTRING_template& value, const INTEGER& index,
    int returncount);
extern HEXSTRING substr(const HEXSTRING_template& value, const INTEGER& index,
    const INTEGER& returncount);

extern OCTETSTRING substr(const OCTETSTRING_template& value, int index,
    int returncount);
extern OCTETSTRING substr(const OCTETSTRING_template& value, int index,
    const INTEGER& returncount);
extern OCTETSTRING substr(const OCTETSTRING_template& value, const INTEGER& index,
    int returncount);
extern OCTETSTRING substr(const OCTETSTRING_template& value, const INTEGER& index,
    const INTEGER& returncount);

extern CHARSTRING substr(const CHARSTRING_template& value, int index,
    int returncount);
extern CHARSTRING substr(const CHARSTRING_template& value, int index,
    const INTEGER& returncount);
extern CHARSTRING substr(const CHARSTRING_template& value, const INTEGER& index,
    int returncount);
extern CHARSTRING substr(const CHARSTRING_template& value, const INTEGER& index,
    const INTEGER& returncount);

extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
    int index, int returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
    int index, const INTEGER& returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
    const INTEGER& index, int returncount);
extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
    const INTEGER& index, const INTEGER& returncount);

// C.35 - replace
extern void check_replace_arguments(int value_length, int index, int len,
	const char *string_type, const char *element_name);
extern BITSTRING replace(const BITSTRING& value, int index, int len,
	const BITSTRING& repl);
extern BITSTRING replace(const BITSTRING& value, int index,
	const INTEGER& len, const BITSTRING& repl);
extern BITSTRING replace(const BITSTRING& value, const INTEGER& index,
	int len, const BITSTRING& repl);
extern BITSTRING replace(const BITSTRING& value, const INTEGER& index,
	const INTEGER& len, const BITSTRING& repl);

extern HEXSTRING replace(const HEXSTRING& value, int index, int len,
	const HEXSTRING& repl);
extern HEXSTRING replace(const HEXSTRING& value, int index,
	const INTEGER& len, const HEXSTRING& repl);
extern HEXSTRING replace(const HEXSTRING& value, const INTEGER& index,
	int len, const HEXSTRING& repl);
extern HEXSTRING replace(const HEXSTRING& value, const INTEGER& index,
	const INTEGER& len, const HEXSTRING& repl);

extern OCTETSTRING replace(const OCTETSTRING& value, int index, int len,
	const OCTETSTRING& repl);
extern OCTETSTRING replace(const OCTETSTRING& value, int index,
	const INTEGER& len, const OCTETSTRING& repl);
extern OCTETSTRING replace(const OCTETSTRING& value, const INTEGER& index,
	int len, const OCTETSTRING& repl);
extern OCTETSTRING replace(const OCTETSTRING& value, const INTEGER& index,
	const INTEGER& len, const OCTETSTRING& repl);

extern CHARSTRING replace(const CHARSTRING& value, int index, int len,
	const CHARSTRING& repl);
extern CHARSTRING replace(const CHARSTRING& value, int index,
	const INTEGER& len, const CHARSTRING& repl);
extern CHARSTRING replace(const CHARSTRING& value, const INTEGER& index,
	int len, const CHARSTRING& repl);
extern CHARSTRING replace(const CHARSTRING& value, const INTEGER& index,
	const INTEGER& len, const CHARSTRING& repl);

extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
	int index, int len, const UNIVERSAL_CHARSTRING& repl);
extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
	int index, const INTEGER& len, const UNIVERSAL_CHARSTRING& repl);
extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
	const INTEGER& index, int len, const UNIVERSAL_CHARSTRING& repl);
extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
	const INTEGER& index, const INTEGER& len,
	const UNIVERSAL_CHARSTRING& repl);
// replace - template parameters
extern BITSTRING replace(const BITSTRING_template& value, int index, int len,
	const BITSTRING_template& repl);
extern BITSTRING replace(const BITSTRING_template& value, int index,
	const INTEGER& len, const BITSTRING_template& repl);
extern BITSTRING replace(const BITSTRING_template& value, const INTEGER& index,
	int len, const BITSTRING_template& repl);
extern BITSTRING replace(const BITSTRING_template& value, const INTEGER& index,
	const INTEGER& len, const BITSTRING_template& repl);

extern HEXSTRING replace(const HEXSTRING_template& value, int index, int len,
	const HEXSTRING_template& repl);
extern HEXSTRING replace(const HEXSTRING_template& value, int index,
	const INTEGER& len, const HEXSTRING_template& repl);
extern HEXSTRING replace(const HEXSTRING_template& value, const INTEGER& index,
	int len, const HEXSTRING_template& repl);
extern HEXSTRING replace(const HEXSTRING_template& value, const INTEGER& index,
	const INTEGER& len, const HEXSTRING_template& repl);

extern OCTETSTRING replace(const OCTETSTRING_template& value, int index, int len,
	const OCTETSTRING& repl);
extern OCTETSTRING replace(const OCTETSTRING_template& value, int index,
	const INTEGER& len, const OCTETSTRING& repl);
extern OCTETSTRING replace(const OCTETSTRING_template& value, const INTEGER& index,
	int len, const OCTETSTRING_template& repl);
extern OCTETSTRING replace(const OCTETSTRING_template& value, const INTEGER& index,
	const INTEGER& len, const OCTETSTRING_template& repl);

extern CHARSTRING replace(const CHARSTRING_template& value, int index, int len,
	const CHARSTRING_template& repl);
extern CHARSTRING replace(const CHARSTRING_template& value, int index,
	const INTEGER& len, const CHARSTRING_template& repl);
extern CHARSTRING replace(const CHARSTRING_template& value, const INTEGER& index,
	int len, const CHARSTRING_template& repl);
extern CHARSTRING replace(const CHARSTRING_template& value, const INTEGER& index,
	const INTEGER& len, const CHARSTRING_template& repl);

extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
	int index, int len, const UNIVERSAL_CHARSTRING_template& repl);
extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
	int index, const INTEGER& len, const UNIVERSAL_CHARSTRING_template& repl);
extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
	const INTEGER& index, int len, const UNIVERSAL_CHARSTRING_template& repl);
extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
	const INTEGER& index, const INTEGER& len,
	const UNIVERSAL_CHARSTRING_template& repl);


// C.36 - rnd
extern double rnd();
extern double rnd(double seed);
extern double rnd(const FLOAT& seed);


// Additional predefined functions defined in Annex B of ES 101 873-7

// B.1 decomp - not implemented yet


// Non-standard functions

// str2bit
extern BITSTRING str2bit(const char *value);
extern BITSTRING str2bit(const CHARSTRING& value);
extern BITSTRING str2bit(const CHARSTRING_ELEMENT& value);

// str2hex
extern HEXSTRING str2hex(const char *value);
extern HEXSTRING str2hex(const CHARSTRING& value);
extern HEXSTRING str2hex(const CHARSTRING_ELEMENT& value);

// float2str
extern CHARSTRING float2str(double value);
extern CHARSTRING float2str(const FLOAT& value);

// unichar2char
extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING& value);
extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING_ELEMENT& value);

// only for internal purposes
extern CHARSTRING get_port_name(const char *port_name, int array_index);
extern CHARSTRING get_port_name(const char *port_name,
    const INTEGER& array_index);
extern CHARSTRING get_port_name(const CHARSTRING& port_name, int array_index);
extern CHARSTRING get_port_name(const CHARSTRING& port_name,
    const INTEGER& array_index);

unsigned char char_to_hexdigit(char c);

// unichar2oct
extern OCTETSTRING unichar2oct(const UNIVERSAL_CHARSTRING& invalue); // default string_encoding UTF-8
extern OCTETSTRING unichar2oct(const UNIVERSAL_CHARSTRING& invalue,
                               const CHARSTRING& string_encoding);
//oct2unichar
extern UNIVERSAL_CHARSTRING oct2unichar(const OCTETSTRING& invalue ); // default string_encoding UTF-8
extern UNIVERSAL_CHARSTRING oct2unichar(const OCTETSTRING& invalue,
                                        const CHARSTRING& string_encoding);

extern CHARSTRING get_stringencoding(const OCTETSTRING& encoded__value);
extern OCTETSTRING remove_bom(const OCTETSTRING& encoded__value);
493
extern CHARSTRING encode_base64(const OCTETSTRING& msg, boolean use_linebreaks);
Elemer Lelik's avatar
Elemer Lelik committed
494
495
496
extern CHARSTRING encode_base64(const OCTETSTRING& msg);
extern OCTETSTRING decode_base64(const CHARSTRING& b64);

497
498
499
extern OCTETSTRING json2cbor(const UNIVERSAL_CHARSTRING& value);
extern UNIVERSAL_CHARSTRING cbor2json(const OCTETSTRING& value);

500
501
502
extern OCTETSTRING json2bson(const UNIVERSAL_CHARSTRING& value);
extern UNIVERSAL_CHARSTRING bson2json(const OCTETSTRING& value);

Elemer Lelik's avatar
Elemer Lelik committed
503
#endif