Sync with 5.1.0
[deliverable/titan.core.git] / compiler2 / ttcn3 / TextAST.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 TEXT_AST_HH
9 #define TEXT_AST_HH
10
11 #include "../Setting.hh"
12 #include "../Identifier.hh"
13 #include "../../common/memory.h"
14
15 struct textAST_matching_values {
16 char* encode_token;
17 char* decode_token;
18 bool case_sensitive;
19 bool generated_decode_token;
20 };
21
22 struct textAST_enum_def {
23 Common::Identifier *name;
24 textAST_matching_values value;
25 };
26
27 struct textAST_param_values {
28 bool leading_zero;
29 bool repeatable;
30 int min_length;
31 int max_length;
32 int convert;
33 int just;
34 };
35
36 class TextAST {
37 private:
38 void init_TextAST();
39 TextAST(const TextAST&);
40 TextAST& operator=(const TextAST&);
41 public:
42 textAST_matching_values *begin_val;
43 textAST_matching_values *end_val;
44 textAST_matching_values *separator_val;
45 textAST_param_values coding_params;
46 textAST_param_values decoding_params;
47 int nof_field_params;
48 textAST_enum_def **field_params;
49 textAST_matching_values *true_params;
50 textAST_matching_values *false_params;
51 char* decode_token;
52 bool case_sensitive;
53
54 TextAST() { init_TextAST(); }
55 TextAST(const TextAST *other_val);
56 ~TextAST();
57
58 void print_TextAST() const;
59 int get_field_param_index(const Common::Identifier *name);
60 };
61
62 void copy_textAST_matching_values(textAST_matching_values **to,
63 const textAST_matching_values *from);
64
65 /** Checks for forbidden references within {} and substitutes the escape
66 * sequences of apostrophes ('' and \') and quotation marks("" and \") in
67 * \a decode_token. Returns the result of substitution. Argument \a loc is
68 * used for error reporting. */
69 char *process_decode_token(const char *decode_token,
70 const Common::Location& loc);
71
72 /** "Encode" the TEXT matching pattern.
73 *
74 * @param str TTCN pattern from the TEXT attribute
75 * @param cs true for case sensitive matching, false for case insensitive
76 * @return a newly allocated string whose first character is
77 * 'I' for case sensitive matching, 'N' for case insensitive matching,
78 * or 'F' for fixed string matching.
79 * The rest of the string is the POSIX regexp corresponding to the pattern
80 * in \p str (or a copy of \p str for fixed string matching).
81 *
82 * The string must be deallocated by the caller using \b Free()
83 */
84 char *make_posix_str_code(const char *str, bool cs);
85
86 /** Converts a TTCN-3 charstring value to an equivalent TTCN-3 pattern. The
87 * special characters of TTCN-3 patterns are escaped. */
88 extern char *convert_charstring_to_pattern(const char *str);
89
90 void init_textAST_matching_values(textAST_matching_values *val);
91
92 #endif
This page took 0.032082 seconds and 5 git commands to generate.