Commit | Line | Data |
---|---|---|
d44e3c4f | 1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2016 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 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Baranyi, Botond | |
11 | * Beres, Szabolcs | |
12 | * Delic, Adam | |
13 | * Forstner, Matyas | |
14 | * Kovacs, Ferenc | |
15 | * Raduly, Csaba | |
16 | * Szabados, Kristof | |
17 | * Szabo, Bence Janos | |
18 | * Szabo, Janos Zoltan – initial implementation | |
19 | * Szalai, Gabor | |
20 | * Tatarka, Gabor | |
21 | * Zalanyi, Balazs Andor | |
22 | * Pandi, Krisztian | |
23 | * | |
24 | ******************************************************************************/ | |
970ed795 EL |
25 | #ifndef CHARSTRING_HH |
26 | #define CHARSTRING_HH | |
27 | ||
28 | #include <sys/types.h> | |
29 | #include <regex.h> | |
30 | ||
31 | #include "Types.h" | |
32 | #include "Basetype.hh" | |
33 | #include "Template.hh" | |
34 | #include "Optional.hh" | |
35 | ||
36 | class INTEGER; | |
37 | class BITSTRING; | |
38 | class HEXSTRING; | |
39 | class OCTETSTRING; | |
40 | class CHARSTRING_ELEMENT; | |
41 | class UNIVERSAL_CHARSTRING; | |
42 | class UNIVERSAL_CHARSTRING_ELEMENT; | |
43 | ||
44 | class Module_Param; | |
45 | ||
46 | /** Runtime class for character strings. | |
47 | * | |
48 | * Memory is reserved for the terminating null character | |
49 | * (not counted in the length). | |
50 | * | |
51 | * This class implements the following string types: | |
52 | * | |
53 | * - TTCN-3 \c charstring | |
54 | * - ASN.1 restricted character strings: | |
55 | * - \c NumericString | |
56 | * - \c PrintableString | |
57 | * - \c IA5String | |
58 | * - \c VisibleString. | |
59 | * - ASN.1 time types: | |
60 | * - \c UTCTime | |
61 | * - \c GeneralizedTime | |
62 | * | |
63 | */ | |
64 | class CHARSTRING : public Base_Type { | |
65 | ||
66 | friend class CHARSTRING_ELEMENT; | |
67 | friend class UNIVERSAL_CHARSTRING; | |
68 | friend class UNIVERSAL_CHARSTRING_ELEMENT; | |
69 | friend class TTCN_Buffer; | |
3abe9331 | 70 | friend class CHARSTRING_template; |
970ed795 EL |
71 | |
72 | friend boolean operator==(const char* string_value, | |
73 | const CHARSTRING& other_value); | |
74 | friend CHARSTRING operator+(const char* string_value, | |
75 | const CHARSTRING& other_value); | |
76 | friend CHARSTRING operator+(const char* string_value, | |
77 | const CHARSTRING_ELEMENT& other_value); | |
78 | ||
79 | friend CHARSTRING bit2str(const BITSTRING& value); | |
80 | friend CHARSTRING hex2str(const HEXSTRING& value); | |
81 | friend CHARSTRING oct2str(const OCTETSTRING& value); | |
82 | friend CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING& value); | |
83 | friend CHARSTRING replace(const CHARSTRING& value, int index, int len, | |
84 | const CHARSTRING& repl); | |
85 | friend UNIVERSAL_CHARSTRING operator+(const universal_char& uchar_value, | |
86 | const UNIVERSAL_CHARSTRING_ELEMENT& other_value); | |
87 | friend UNIVERSAL_CHARSTRING operator+(const universal_char& uchar_value, | |
88 | const UNIVERSAL_CHARSTRING& other_value); | |
89 | friend boolean operator==(const universal_char& uchar_value, | |
90 | const UNIVERSAL_CHARSTRING& other_value); | |
91 | friend boolean operator==(const char *string_value, | |
92 | const UNIVERSAL_CHARSTRING_ELEMENT& other_value); | |
93 | friend UNIVERSAL_CHARSTRING operator+(const char *string_value, | |
94 | const UNIVERSAL_CHARSTRING& other_value); | |
95 | friend UNIVERSAL_CHARSTRING operator+(const char *string_value, | |
96 | const UNIVERSAL_CHARSTRING_ELEMENT& other_value); | |
97 | ||
98 | struct charstring_struct; | |
99 | charstring_struct *val_ptr; | |
100 | ||
101 | void init_struct(int n_chars); | |
102 | void copy_value(); | |
103 | CHARSTRING(int n_chars); | |
104 | ||
3abe9331 | 105 | /** An extended version of set_param(), which also accepts string patterns if |
106 | * the second parameter is set (needed by CHARSTRING_template to concatenate | |
107 | * string patterns). | |
108 | * @return TRUE, if the module parameter was a string pattern, otherwise FALSE */ | |
109 | boolean set_param_internal(Module_Param& param, boolean allow_pattern); | |
110 | ||
970ed795 EL |
111 | public: |
112 | /** Construct an unbound CHARSTRING object */ | |
113 | CHARSTRING(); | |
114 | /** Construct a CHARSTRING of length 1 */ | |
115 | CHARSTRING(char other_value); | |
116 | /** Construct a CHARSTRING from the given C string. | |
117 | * @param chars_ptr may be NULL, resulting in an empty CHARSTRING */ | |
118 | CHARSTRING(const char* chars_ptr); | |
119 | /** Construct a CHARSTRING of a given length. | |
120 | * | |
121 | * CHARSTRING(0,NULL) is the most efficient way to a bound, empty string. | |
122 | * | |
123 | * @param n_chars number of characters | |
124 | * @param chars_ptr pointer to string (does not need to be 0-terminated) | |
125 | * @pre at least \p n_chars are readable from \p chars_ptr */ | |
126 | CHARSTRING(int n_chars, const char* chars_ptr); | |
127 | /** Copy constructor */ | |
128 | CHARSTRING(const CHARSTRING& other_value); | |
129 | /** Construct a CHARSTRING of length one */ | |
130 | CHARSTRING(const CHARSTRING_ELEMENT& other_value); | |
131 | ||
132 | /** Destructor. Simply calls clean_up() */ | |
133 | ~CHARSTRING(); | |
134 | void clean_up(); | |
135 | ||
136 | CHARSTRING& operator=(const char* other_value); | |
137 | CHARSTRING& operator=(const CHARSTRING& other_value); | |
138 | CHARSTRING& operator=(const CHARSTRING_ELEMENT& other_value); | |
139 | CHARSTRING& operator=(const UNIVERSAL_CHARSTRING& other_value); | |
140 | ||
141 | boolean operator==(const char* other_value) const; | |
142 | boolean operator==(const CHARSTRING& other_value) const; | |
143 | boolean operator==(const CHARSTRING_ELEMENT& other_value) const; | |
144 | boolean operator==(const UNIVERSAL_CHARSTRING& other_value) const; | |
145 | boolean operator==(const UNIVERSAL_CHARSTRING_ELEMENT& other_value) const; | |
146 | ||
147 | inline boolean operator!=(const char* other_value) const | |
148 | { return !(*this == other_value); } | |
149 | inline boolean operator!=(const CHARSTRING& other_value) const | |
150 | { return !(*this == other_value); } | |
151 | inline boolean operator!=(const CHARSTRING_ELEMENT& other_value) const | |
152 | { return !(*this == other_value); } | |
153 | ||
154 | CHARSTRING operator+(const char* other_value) const; | |
155 | CHARSTRING operator+(const CHARSTRING& other_value) const; | |
156 | CHARSTRING operator+(const CHARSTRING_ELEMENT& other_value) const; | |
157 | UNIVERSAL_CHARSTRING operator+(const UNIVERSAL_CHARSTRING& other_value) const; | |
158 | UNIVERSAL_CHARSTRING operator+ | |
159 | (const UNIVERSAL_CHARSTRING_ELEMENT& other_value) const; | |
160 | ||
161 | CHARSTRING& operator+=(char other_value); | |
162 | CHARSTRING& operator+=(const char *other_value); | |
163 | CHARSTRING& operator+=(const CHARSTRING& other_value); | |
164 | CHARSTRING& operator+=(const CHARSTRING_ELEMENT& other_value); | |
165 | ||
166 | CHARSTRING operator<<=(int rotate_count) const; | |
167 | CHARSTRING operator<<=(const INTEGER& rotate_count) const; | |
168 | CHARSTRING operator>>=(int rotate_count) const; | |
169 | CHARSTRING operator>>=(const INTEGER& rotate_count) const; | |
170 | ||
171 | CHARSTRING_ELEMENT operator[](int index_value); | |
172 | CHARSTRING_ELEMENT operator[](const INTEGER& index_value); | |
173 | const CHARSTRING_ELEMENT operator[](int index_value) const; | |
174 | const CHARSTRING_ELEMENT operator[](const INTEGER& index_value) const; | |
175 | ||
176 | operator const char*() const; | |
177 | ||
178 | inline boolean is_bound() const { return val_ptr != NULL; } | |
179 | inline boolean is_value() const { return val_ptr != NULL; } | |
180 | inline void must_bound(const char *err_msg) const | |
181 | { if (val_ptr == NULL) TTCN_error("%s", err_msg); } | |
182 | ||
183 | int lengthof() const; | |
184 | ||
185 | void log() const; | |
186 | ||
187 | #ifdef TITAN_RUNTIME_2 | |
188 | boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const CHARSTRING*>(other_value)); } | |
189 | void set_value(const Base_Type* other_value) { *this = *(static_cast<const CHARSTRING*>(other_value)); } | |
190 | Base_Type* clone() const { return new CHARSTRING(*this); } | |
191 | const TTCN_Typedescriptor_t* get_descriptor() const { return &CHARSTRING_descr_; } | |
192 | #else | |
193 | inline boolean is_present() const { return is_bound(); } | |
194 | #endif | |
195 | ||
196 | /** Initializes this object with a module parameter value or concatenates a module | |
197 | * parameter value to the end of this string. | |
198 | * @note UFT-8 strings will be decoded. If the decoding results in multi-octet | |
199 | * characters an error will be thrown. */ | |
200 | void set_param(Module_Param& param); | |
3abe9331 | 201 | Module_Param* get_param(Module_Param_Name& param_name) const; |
970ed795 EL |
202 | |
203 | void encode_text(Text_Buf& text_buf) const; | |
204 | void decode_text(Text_Buf& text_buf); | |
205 | ||
206 | void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, | |
207 | TTCN_EncDec::coding_t p_coding, ...) const; | |
208 | ||
209 | void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, | |
210 | TTCN_EncDec::coding_t p_coding, ...); | |
211 | ||
212 | ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, | |
213 | unsigned p_coding) const; | |
214 | ||
215 | boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, | |
216 | const ASN_BER_TLV_t& p_tlv, unsigned L_form); | |
217 | ||
218 | /** Encodes the value of the variable according to the | |
219 | * TTCN_Typedescriptor_t. It must be public because called by | |
220 | * another types during encoding. Returns the length of encoded | |
221 | * data */ | |
222 | int RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree&) const; | |
223 | /** Decodes the value of the variable according to the | |
224 | * TTCN_Typedescriptor_t. It must be public because called by | |
225 | * another types during encoding. Returns the number of decoded | |
226 | * bits */ | |
227 | int RAW_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, int, raw_order_t, | |
228 | boolean no_err=FALSE, int sel_field=-1, boolean first_call=TRUE); | |
229 | int TEXT_encode(const TTCN_Typedescriptor_t&, | |
230 | TTCN_Buffer&) const; | |
231 | int TEXT_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, Limit_Token_List&, | |
232 | boolean no_err=FALSE, boolean first_call=TRUE); | |
af710487 | 233 | int XER_encode(const XERdescriptor_t&, TTCN_Buffer&, unsigned int, int, embed_values_enc_struct_t*) const; |
feade998 | 234 | int XER_decode(const XERdescriptor_t&, XmlReaderWrap& reader, unsigned int, unsigned int, embed_values_dec_struct_t*); |
970ed795 EL |
235 | |
236 | /** Returns the charstring in the format a string would appear in C or TTCN-3 code. | |
237 | * Inserts double quotation marks to the beginning and end of the string and | |
238 | * doubles the backlsashes in escaped characters. | |
239 | * Used for JSON encoding. | |
240 | * | |
241 | * Example: "He said\nhis name was \"Al\"." -> "\"He said\\nhis name was \\\"Al\\\".\"" | |
242 | * @note The returned character buffer needs to be freed after use. */ | |
243 | char* to_JSON_string() const; | |
244 | ||
245 | /** Initializes the charstring with a JSON string value. | |
246 | * The double quotation marks from the beginning and end of the JSON string are | |
247 | * removed and double-escaped characters are changed to simple-escaped ones. | |
248 | * JSON characters stored as \u + 4 hex digits are converted to the characters | |
249 | * they represent. | |
250 | * Returns false if any non-charstring characters were found, otherwise true. | |
251 | * Used for JSON decoding. | |
252 | * | |
253 | * Example: "\"He said\\nhis name was \\\"Al\\\".\"" -> "He said\nhis name was \"Al\"." | |
254 | * Example2: "\u0061" -> "a" | |
255 | * | |
256 | * @param check_quotes turn the checking of double quotes (mentioned above) on or off */ | |
257 | boolean from_JSON_string(const char* p_value, size_t p_value_len, boolean check_quotes); | |
258 | ||
259 | /** Encodes accordingly to the JSON encoding rules. | |
260 | * Returns the length of the encoded data. | |
261 | * @note Since JSON has its own set of escaped characters, the ones in the | |
262 | * charstring need to be double-escaped. */ | |
263 | int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const; | |
264 | ||
265 | /** Decodes accordingly to the JSON encoding rules. | |
266 | * Returns the length of the decoded data. */ | |
267 | int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean); | |
268 | ||
269 | #ifdef TITAN_RUNTIME_2 | |
270 | virtual int encode_raw(TTCN_Buffer& p_buf) const; | |
3f84031e | 271 | /** Adds this charstring to the end of a JSON buffer as raw data. |
272 | * Used during the negative testing of the JSON encoder. | |
273 | * @return The number of bytes added. */ | |
274 | int JSON_encode_negtest_raw(JSON_Tokenizer&) const; | |
970ed795 EL |
275 | #endif |
276 | }; | |
277 | ||
278 | class CHARSTRING_ELEMENT { | |
279 | boolean bound_flag; | |
280 | CHARSTRING& str_val; | |
281 | int char_pos; | |
282 | ||
283 | public: | |
284 | CHARSTRING_ELEMENT(boolean par_bound_flag, CHARSTRING& par_str_val, | |
285 | int par_char_pos); | |
286 | ||
287 | CHARSTRING_ELEMENT& operator=(const char* other_value); | |
288 | CHARSTRING_ELEMENT& operator=(const CHARSTRING& other_value); | |
289 | CHARSTRING_ELEMENT& operator=(const CHARSTRING_ELEMENT& other_value); | |
290 | ||
291 | boolean operator==(const char *other_value) const; | |
292 | boolean operator==(const CHARSTRING& other_value) const; | |
293 | boolean operator==(const CHARSTRING_ELEMENT& other_value) const; | |
294 | boolean operator==(const UNIVERSAL_CHARSTRING& other_value) const; | |
295 | boolean operator==(const UNIVERSAL_CHARSTRING_ELEMENT& other_value) const; | |
296 | ||
297 | inline boolean operator!=(const char *other_value) const | |
298 | { return !(*this == other_value); } | |
299 | inline boolean operator!=(const CHARSTRING& other_value) const | |
300 | { return !(*this == other_value); } | |
301 | inline boolean operator!=(const CHARSTRING_ELEMENT& other_value) const | |
302 | { return !(*this == other_value); } | |
303 | ||
304 | CHARSTRING operator+(const char *other_value) const; | |
305 | CHARSTRING operator+(const CHARSTRING& other_value) const; | |
306 | CHARSTRING operator+(const CHARSTRING_ELEMENT& other_value) const; | |
307 | UNIVERSAL_CHARSTRING operator+(const UNIVERSAL_CHARSTRING& other_value) const; | |
308 | UNIVERSAL_CHARSTRING operator+ | |
309 | (const UNIVERSAL_CHARSTRING_ELEMENT& other_value) const; | |
310 | ||
311 | inline boolean is_bound() const { return bound_flag; } | |
312 | inline boolean is_present() const { return bound_flag; } | |
313 | inline boolean is_value() const { return bound_flag; } | |
314 | inline void must_bound(const char *err_msg) const | |
315 | { if (!bound_flag) TTCN_error("%s", err_msg); } | |
316 | ||
317 | char get_char() const; | |
318 | ||
319 | void log() const; | |
320 | }; | |
321 | ||
322 | extern boolean operator==(const char* string_value, | |
323 | const CHARSTRING& other_value); | |
324 | extern boolean operator==(const char* string_value, | |
325 | const CHARSTRING_ELEMENT& other_value); | |
326 | ||
327 | inline boolean operator!=(const char* string_value, | |
328 | const CHARSTRING& other_value) | |
329 | { | |
330 | return !(string_value == other_value); | |
331 | } | |
332 | ||
333 | inline boolean operator!=(const char* string_value, | |
334 | const CHARSTRING_ELEMENT& other_value) | |
335 | { | |
336 | return !(string_value == other_value); | |
337 | } | |
338 | ||
339 | extern CHARSTRING operator+(const char* string_value, | |
340 | const CHARSTRING& other_value); | |
341 | extern CHARSTRING operator+(const char* string_value, | |
342 | const CHARSTRING_ELEMENT& other_value); | |
343 | ||
344 | extern CHARSTRING operator<<=(const char *string_value, | |
345 | const INTEGER& rotate_count); | |
346 | extern CHARSTRING operator>>=(const char *string_value, | |
347 | const INTEGER& rotate_count); | |
348 | ||
349 | // charstring template class | |
350 | ||
351 | class CHARSTRING_template : public Restricted_Length_Template { | |
352 | ||
353 | friend class UNIVERSAL_CHARSTRING_template; | |
354 | ||
355 | private: | |
356 | CHARSTRING single_value; | |
357 | union { | |
358 | struct { | |
359 | unsigned int n_values; | |
360 | CHARSTRING_template *list_value; | |
361 | } value_list; | |
362 | struct { | |
363 | boolean min_is_set, max_is_set; | |
364 | char min_value, max_value; | |
365 | } value_range; | |
366 | mutable struct { | |
367 | boolean regexp_init; | |
368 | regex_t posix_regexp; | |
369 | } pattern_value; | |
370 | }; | |
371 | ||
372 | void copy_template(const CHARSTRING_template& other_value); | |
373 | static void log_pattern(int n_chars, const char *chars_ptr); | |
374 | ||
375 | public: | |
376 | CHARSTRING_template(); | |
377 | /** Constructor for any/omit/any-or-omit | |
378 | * @param other_value must be ANY_VALUE, OMIT_VALUE or ANY_OR_OMIT | |
379 | */ | |
380 | CHARSTRING_template(template_sel other_value); | |
381 | /** Construct from a string | |
382 | * @post template_selection is SPECIFIC_VALUE | |
383 | * @param other_value | |
384 | */ | |
385 | CHARSTRING_template(const CHARSTRING& other_value); | |
386 | /** Construct from a one-character string (result of CHARSTRING::op[]) | |
387 | * @post template_selection is SPECIFIC_VALUE | |
388 | * @param other_value | |
389 | */ | |
390 | CHARSTRING_template(const CHARSTRING_ELEMENT& other_value); | |
391 | /** Construct from an optional string | |
392 | * @post template_selection is SPECIFIC_VALUE or OMIT_VALUE | |
393 | * @param other_value | |
394 | */ | |
395 | CHARSTRING_template(const OPTIONAL<CHARSTRING>& other_value); | |
396 | /** Constructor for STRING_PATTERN | |
397 | * @param p_sel must be STRING_PATTERN or else Dynamic Testcase Error | |
398 | * @param p_str pattern string | |
399 | */ | |
400 | CHARSTRING_template(template_sel p_sel, const CHARSTRING& p_str); | |
401 | /// Copy constructor | |
402 | CHARSTRING_template(const CHARSTRING_template& other_value); | |
403 | ||
404 | ~CHARSTRING_template(); | |
405 | void clean_up(); | |
406 | ||
407 | CHARSTRING_template& operator=(template_sel other_value); | |
408 | CHARSTRING_template& operator=(const CHARSTRING& other_value); | |
409 | CHARSTRING_template& operator=(const CHARSTRING_ELEMENT& other_value); | |
410 | CHARSTRING_template& operator=(const OPTIONAL<CHARSTRING>& other_value); | |
411 | CHARSTRING_template& operator=(const CHARSTRING_template& other_value); | |
412 | ||
413 | CHARSTRING_ELEMENT operator[](int index_value); | |
414 | CHARSTRING_ELEMENT operator[](const INTEGER& index_value); | |
415 | const CHARSTRING_ELEMENT operator[](int index_value) const; | |
416 | const CHARSTRING_ELEMENT operator[](const INTEGER& index_value) const; | |
417 | ||
3abe9331 | 418 | boolean match(const CHARSTRING& other_value, boolean legacy = FALSE) const; |
970ed795 EL |
419 | const CHARSTRING& valueof() const; |
420 | ||
421 | int lengthof() const; | |
422 | ||
423 | void set_type(template_sel template_type, unsigned int list_length = 0); | |
424 | CHARSTRING_template& list_item(unsigned int list_index); | |
425 | ||
426 | void set_min(const CHARSTRING& min_value); | |
427 | void set_max(const CHARSTRING& max_value); | |
428 | ||
429 | void log() const; | |
3abe9331 | 430 | void log_match(const CHARSTRING& match_value, boolean legacy = FALSE) const; |
970ed795 EL |
431 | |
432 | void set_param(Module_Param& param); | |
3abe9331 | 433 | Module_Param* get_param(Module_Param_Name& param_name) const; |
970ed795 EL |
434 | |
435 | void encode_text(Text_Buf& text_buf) const; | |
436 | void decode_text(Text_Buf& text_buf); | |
437 | ||
3abe9331 | 438 | boolean is_present(boolean legacy = FALSE) const; |
439 | boolean match_omit(boolean legacy = FALSE) const; | |
970ed795 EL |
440 | #ifdef TITAN_RUNTIME_2 |
441 | void valueofv(Base_Type* value) const { *(static_cast<CHARSTRING*>(value)) = valueof(); } | |
442 | void set_value(template_sel other_value) { *this = other_value; } | |
443 | void copy_value(const Base_Type* other_value) { *this = *(static_cast<const CHARSTRING*>(other_value)); } | |
444 | Base_Template* clone() const { return new CHARSTRING_template(*this); } | |
445 | const TTCN_Typedescriptor_t* get_descriptor() const { return &CHARSTRING_descr_; } | |
3abe9331 | 446 | boolean matchv(const Base_Type* other_value, boolean legacy) const { return match(*(static_cast<const CHARSTRING*>(other_value)), legacy); } |
447 | void log_matchv(const Base_Type* match_value, boolean legacy) const { log_match(*(static_cast<const CHARSTRING*>(match_value)), legacy); } | |
970ed795 | 448 | #else |
3abe9331 | 449 | void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const; |
970ed795 EL |
450 | #endif |
451 | ||
452 | /** Returns the single_value member | |
453 | * @pre template_selection is SPECIFIC_VALUE or STRING_PATTERN */ | |
454 | const CHARSTRING& get_single_value() const; | |
455 | }; | |
456 | ||
457 | typedef CHARSTRING NumericString; | |
458 | typedef CHARSTRING PrintableString; | |
459 | typedef CHARSTRING IA5String; | |
460 | typedef CHARSTRING VisibleString; | |
461 | typedef VisibleString ISO646String; | |
462 | ||
463 | typedef CHARSTRING_template NumericString_template; | |
464 | typedef CHARSTRING_template PrintableString_template; | |
465 | typedef CHARSTRING_template IA5String_template; | |
466 | typedef CHARSTRING_template VisibleString_template; | |
467 | typedef VisibleString_template ISO646String_template; | |
468 | ||
469 | typedef VisibleString ASN_GeneralizedTime; | |
470 | typedef VisibleString ASN_UTCTime; | |
471 | ||
472 | typedef VisibleString_template ASN_GeneralizedTime_template; | |
473 | typedef VisibleString_template ASN_UTCTime_template; | |
474 | ||
475 | // Only for backward compatibility | |
476 | typedef CHARSTRING CHAR; | |
477 | typedef CHARSTRING_template CHAR_template; | |
478 | ||
479 | // TTCN_TYPE is a class that represents a ttcn-3 value or template | |
480 | template<typename TTCN_TYPE> | |
481 | CHARSTRING ttcn_to_string(const TTCN_TYPE& ttcn_data) { | |
482 | Logger_Format_Scope logger_format(TTCN_Logger::LF_TTCN); | |
483 | TTCN_Logger::begin_event_log2str(); | |
484 | ttcn_data.log(); | |
485 | return TTCN_Logger::end_event_log2str(); | |
486 | } | |
487 | ||
488 | template<typename TTCN_TYPE> | |
489 | void string_to_ttcn(const CHARSTRING& ttcn_string, TTCN_TYPE& ttcn_value) { | |
490 | Module_Param* parsed_mp = process_config_string2ttcn((const char*)ttcn_string, ttcn_value.is_component()); | |
491 | try { | |
492 | Ttcn_String_Parsing ttcn_string_parsing; | |
493 | ttcn_value.set_param(*parsed_mp); | |
494 | delete parsed_mp; | |
495 | } | |
496 | catch (...) { | |
497 | delete parsed_mp; | |
498 | throw; | |
499 | } | |
500 | } | |
501 | ||
502 | #endif |