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