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 ///////////////////////////////////////////////////////////////////////////////
11 #include "rawASTspec.h"
12 #include "../Setting.hh"
13 #include "../Identifier.hh"
26 Common::Identifier *from;
27 Common::Identifier *to;
28 } rawAST_ext_bit_group;
32 Common::Identifier **names;
36 rawAST_field_list* keyField;
38 Common::Value *v_value;
39 } rawAST_tag_field_value;
42 Common::Identifier* fieldName;
44 rawAST_tag_field_value* keyList;
49 rawAST_single_tag* tag;
54 Common::Value *v_value;
57 /** Parsed RAW encoder attributes */
60 void init_rawast(bool int_type);
62 RawAST(const RawAST&);
64 RawAST& operator=(const RawAST&);
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)*/
77 rawAST_ext_bit_group *ext_bit_groups;
78 int hexorder; /**< XDEFLOW, XDEFHIGH */
79 int padding; /**< XDEFYES: next field starts at next octet */
81 int padding_pattern_length;
84 char* padding_pattern;
85 int fieldorder; /**< XDEFMSB, XDEFLSB */
87 Common::Identifier **lengthto; /**< list of fields to generate length for */
88 Common::Identifier *pointerto; /**< pointer to the specified field is contained
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
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
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 */
112 * Calls \c init_rawast(int_type). */
113 RawAST(bool int_type);
114 /** Sort-of copy constructor. */
115 RawAST(RawAST *other, bool int_type);
121 /** The entry point for the RAW attribute parser.
123 * This is overloaded with the TEXT and XER attribute parsing.
125 * Called from Common::Type::parse_raw()
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
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.
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);
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);