Sync with 5.1.0
[deliverable/titan.core.git] / compiler2 / ttcn3 / RawAST.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 RAW_AST_HH
9 #define RAW_AST_HH
10
11 #include "rawASTspec.h"
12 #include "../Setting.hh"
13 #include "../Identifier.hh"
14
15 class XerAttributes;
16 class TextAST;
17 class BerAST;
18 class JsonAST;
19
20 namespace Ttcn {
21 class AttributeSpec;
22 }
23
24 typedef struct{
25 int ext_bit;
26 Common::Identifier *from;
27 Common::Identifier *to;
28 } rawAST_ext_bit_group;
29
30 typedef struct {
31 int nElements;
32 Common::Identifier **names;
33 } rawAST_field_list;
34
35 typedef struct {
36 rawAST_field_list* keyField;
37 char* value;
38 Common::Value *v_value;
39 } rawAST_tag_field_value;
40
41 typedef struct {
42 Common::Identifier* fieldName;
43 int nElements;
44 rawAST_tag_field_value* keyList;
45 } rawAST_single_tag;
46
47 typedef struct {
48 int nElements;
49 rawAST_single_tag* tag;
50 } rawAST_tag_list;
51
52 typedef struct{
53 char* value;
54 Common::Value *v_value;
55 } rawAST_values;
56
57 /** Parsed RAW encoder attributes */
58 class RawAST{
59 private:
60 void init_rawast(bool int_type);
61 /** No copying */
62 RawAST(const RawAST&);
63 /** No assignment */
64 RawAST& operator=(const RawAST&);
65 public:
66 int fieldlength; /**< Nr of bits per character, hexstring : 4,
67 octetstring and charstring : 8, etc */
68 int comp; /**< Handling of sign: no, 2scomp, signbit */
69 int byteorder; /**< XDEFMSB, XDEFLSB */
70 int align; /**< XDEFLEFT, XDEFRIGHT */
71 int bitorderinfield; /**< XDEFMSB, XDEFLSB */
72 int bitorderinoctet; /**< XDEFMSB, XDEFLSB */
73 int extension_bit; /**< XDEFYES, XDEFNO
74 can be used for record fields:
75 variant (field1) EXTENSION_BIT(use)*/
76 int ext_bit_goup_num;
77 rawAST_ext_bit_group *ext_bit_groups;
78 int hexorder; /**< XDEFLOW, XDEFHIGH */
79 int padding; /**< XDEFYES: next field starts at next octet */
80 int prepadding;
81 int padding_pattern_length;
82 int paddall;
83 int repeatable;
84 char* padding_pattern;
85 int fieldorder; /**< XDEFMSB, XDEFLSB */
86 int lengthto_num;
87 Common::Identifier **lengthto; /**< list of fields to generate length for */
88 Common::Identifier *pointerto; /**< pointer to the specified field is contained
89 in this field */
90 int ptroffset; /**< offset to the pointer value in bits
91 Actual position will be:
92 pointerto*ptrunit + ptroffset */
93 Common::Identifier *ptrbase; /**< the identifier in PTROFFSET(identifier) */
94 int unit; /**< XDEFOCTETS, XDEFBITS */
95 rawAST_field_list *lengthindex; /**< stores subattribute of the lengthto
96 attribute */
97 rawAST_tag_list crosstaglist;
98 rawAST_tag_list taglist; /**< field IDs in form of
99 [unionField.sub]field_N,
100 keyField.subfield_M = tagValue
101 multiple tagValues may be specified */
102 rawAST_single_tag presence; /**< Presence indicator expressions for an
103 optional field */
104 int topleveleind;
105 rawAST_toplevel toplevel; /**< Toplevel attributes */
106 int length_restrition;
107 /** Default constructor.
108 * Calls \c init_rawast(false).
109 * \todo should be merged with the next one */
110 RawAST();
111 /** Constructor.
112 * Calls \c init_rawast(int_type). */
113 RawAST(bool int_type);
114 /** Sort-of copy constructor. */
115 RawAST(RawAST *other, bool int_type);
116 ~RawAST();
117 void print_RawAST();
118
119 };
120
121 /** The entry point for the RAW attribute parser.
122 *
123 * This is overloaded with the TEXT and XER attribute parsing.
124 *
125 * Called from Common::Type::parse_raw()
126 *
127 * @param[out] par the parsed RAW encoder attributes
128 * @param[out] textpar the parsed TEXT encoder attributes
129 * @param[out] xerpar the parsed XER encoder settings
130 * @param[out] jsonpar the parsed JSON encoder settings
131 * @param[in] attrib attribute specification to be parsed
132 * @param[in] l_multip length multiplier (4 for \c hexstring,
133 * 8 for \c octet \c string and \c charstring,
134 * 1 for anything else)
135 * @param[in] mod pointer to the current module
136 * @param[out] raw_found set to \c true if a RAW attribute was found
137 * (or if none found)
138 * @param[out] text_found set to \c true if a TEXT attribute was found
139 * @param[out] xer_found set to \c true if a XER attribute was found
140 * @param[out] json_found set to \c true if a JSON attribute was found
141 * @return the return value of rawAST_parse: 0 for success, 1 for error,
142 * 2 for out of memory.
143 */
144 extern int parse_rawAST(RawAST *par, TextAST *textpar, XerAttributes *xerpar,
145 BerAST *berpar, JsonAST* jsonpar, const Ttcn::AttributeSpec& attrib,
146 int l_multip, const Common::Module* mod, bool &raw_found, bool &text_found,
147 bool &xer_found, bool &ber_found, bool &json_found);
148 extern void copy_rawAST_to_struct(RawAST *from, raw_attrib_struct *to);
149 extern void free_raw_attrib_struct(raw_attrib_struct *raw);
150 extern int compare_raw_attrib(RawAST *a, RawAST *b);
151
152 extern void free_rawAST_field_list(rawAST_field_list *ptr);
153 extern rawAST_single_tag *link_rawAST_single_tag(rawAST_single_tag *dst,
154 rawAST_single_tag *src);
155 extern void free_rawAST_single_tag(rawAST_single_tag *spec);
156 extern void free_rawAST_tag_field_value(rawAST_tag_field_value *spec);
157 extern rawAST_tag_field_value *link_rawAST_tag_field_value(
158 rawAST_tag_field_value *dst, rawAST_tag_field_value* src);
159 extern rawAST_tag_field_value *init_rawAST_tag_field_value(
160 rawAST_tag_field_value *spec);
161 extern void free_rawAST_tag_list(rawAST_tag_list *spec);
162 extern rawAST_tag_list* link_rawAST_tag_list(rawAST_tag_list *dst,
163 rawAST_tag_list *src);
164
165 #endif
This page took 0.033737 seconds and 5 git commands to generate.