Use LTTngUSTLogger logger plugin in logtest regression test
[deliverable/titan.core.git] / xsdconvert / RootType.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 * Raduly, Csaba
11 * Szabo, Bence Janos
12 *
13 ******************************************************************************/
970ed795
EL
14#ifndef BASETYPE_HH_
15#define BASETYPE_HH_
16
17#include "GeneralTypes.hh"
18#include "Mstring.hh"
19#include "List.hh"
20
21#include <cmath> // for using "pow" function
22#include <cfloat>
23#include <cctype>
24#include <cerrno>
25#include <climits>
26#ifndef ULLONG_MAX
27#define ULLONG_MAX 18446744073709551615ULL
28#endif
29#ifndef LLONG_MIN
30#define LLONG_MIN -9223372036854775808LL
31#endif
32#ifndef LLONG_MAX
33#define LLONG_MAX 9223372036854775807LL
34#endif
35
36extern bool c_flag_used;
37extern bool e_flag_used;
38
3abe9331 39enum VariantMode {
40 V_abstract,
970ed795
EL
41 V_anyAttributes,
42 V_anyElement,
43 V_attribute,
44 V_attributeFormQualified,
45 V_attributeGroup,
3abe9331 46 V_block,
970ed795
EL
47 V_controlNamespace,
48 V_defaultForEmpty,
49 V_element,
50 V_elementFormQualified,
51 V_embedValues,
52 V_formAs,
53 V_list,
54 V_nameAs,
55 V_namespaceAs,
56 V_onlyValue,
3abe9331 57 V_onlyValueHidden,
970ed795
EL
58 V_untagged,
59 V_useNil,
60 V_useNumber,
61 V_useOrder,
51fa56b9 62 V_useType,
970ed795 63 V_useUnion,
3abe9331 64 V_whiteSpace,
65 V_fractionDigits
970ed795
EL
66};
67
3abe9331 68enum OriginType {
970ed795
EL
69 from_simpleType,
70 from_element,
71 from_attribute,
72 from_complexType,
73 from_group,
74 from_attributeGroup,
75 from_unknown
76};
77
3abe9331 78class NameType {
970ed795
EL
79public:
80 Mstring originalValueWoPrefix;
81 Mstring convertedValue;
82 bool list_extension;
3abe9331 83 bool no_replace;
970ed795 84
3abe9331 85 NameType() : originalValueWoPrefix(), convertedValue(), list_extension(false), no_replace(false) {
86 }
970ed795
EL
87 // Default copy constructor, assignment operator and destructor are used
88
3abe9331 89 void upload(const Mstring& input) {
970ed795
EL
90 if (input.empty()) return;
91 convertedValue = input;
92 originalValueWoPrefix = input.getValueWithoutPrefix(':');
93 }
94};
95
96class SimpleType;
97class XMLParser;
98class TTCN3Module;
99
100/**
101 * This type is used as the base class for the used classes
102 * that represent the main datatypes in the generated TTCN-3 modules
103 *
104 * It is installed to have possibility to store main types in one container
105 *
106 */
107
3abe9331 108class RootType {
970ed795 109protected:
3abe9331 110 XMLParser * parser; // no responsibility for this member
111 TTCN3Module * module; // no responsibility for this member
970ed795
EL
112
113 NameType name;
114 NameType type;
970ed795
EL
115 List<Mstring> variant;
116 List<Mstring> variant_ref;
3abe9331 117 List<Mstring> hidden_variant;
118 List<Mstring> comment;
970ed795
EL
119
120 ConstructType construct;
121 OriginType origin;
122 bool visible;
3abe9331 123
970ed795
EL
124 /// List of types that depend on this one.
125 /// Used to propagate the effect of name conversion to the dependents
126 List<SimpleType*> nameDepList; // no responsibility for elements
4999ad2e 127
128private:
129 unsigned long long int minOccurs;
130 unsigned long long int maxOccurs;
131 bool min_mod;
132 bool max_mod;
133
970ed795 134public:
3abe9331 135 RootType(XMLParser * a_parser, TTCN3Module * a_module, const ConstructType a_construct);
136
137 virtual ~RootType() {
138 }
970ed795
EL
139 // Default copy constructor and assignment operator is used
140
3abe9331 141 virtual void loadWithValues() = 0;
142 virtual void printToFile(FILE * file) = 0;
970ed795 143
3abe9331 144 virtual void modifyValues() {
145 }
970ed795 146
3abe9331 147 virtual void referenceResolving() {
148 }
970ed795 149
3abe9331 150 virtual void nameConversion(const NameConversionMode, const List<NamespaceType> &) {
151 }
152
153 virtual void finalModification() {
154 }
970ed795 155
3abe9331 156 virtual bool hasUnresolvedReference() {
157 return false;
158 }
159
160 virtual void dump(const unsigned int) const {
161 }
162
163 void setNameValue(const Mstring& str) {
164 name.convertedValue = str;
165 }
166
167 void setTypeValue(const Mstring& str) {
168 type.convertedValue = str;
169 }
170
171 void useNameListProperty() {
172 name.convertedValue += "_list";
173 }
174
175 void setInvisible() {
176 visible = false;
177 }
178
51fa56b9 179 void setVisible() {
180 visible = true;
181 }
4999ad2e 182
183 void setMinOccurs(const unsigned long long int min) {
184 minOccurs = min;
185 min_mod = true;
186 }
187
188 void setMaxOccurs(const unsigned long long int max) {
189 maxOccurs = max;
190 max_mod = true;
191 }
192
193 const bool getMinMod() const {
194 return min_mod;
195 }
196
197 const bool getMaxMod() const {
198 return max_mod;
199 }
51fa56b9 200
3abe9331 201 const NameType & getName() const {
202 return name;
203 }
204
205 const NameType & getType() const {
206 return type;
207 }
208
209 unsigned long long int getMinOccurs() const {
210 return minOccurs;
211 }
212
213 unsigned long long int getMaxOccurs() const {
214 return maxOccurs;
215 }
216
217 const List<Mstring> & getVariant() const {
218 return variant;
219 }
220
221 const List<Mstring> & getVariantRef() const {
222 return variant_ref;
223 }
224
225 const List<Mstring> & getHiddenVariant() const {
226 return hidden_variant;
227 }
228
229 ConstructType getConstruct() const {
230 return construct;
231 }
232
233 OriginType getOrigin() const {
234 return origin;
235 }
236
237 bool isVisible() const {
238 return visible;
239 }
240
241 List<Mstring> & getComment() {
242 return comment;
243 }
244
51fa56b9 245 List<SimpleType*> & getNameDepList() {
246 return nameDepList;
247 }
248
3abe9331 249 XMLParser * getParser() const {
250 return parser;
251 }
252
253 TTCN3Module * getModule() const {
254 return module;
255 }
256
257 void setModule(TTCN3Module * mod) {
258 module = mod;
259 }
970ed795 260
3abe9331 261 bool hasVariant(const Mstring& var) const;
970ed795 262
3abe9331 263 void addVariant(const VariantMode var, const Mstring& var_value = empty_string, const bool into_variant_ref = false);
264 virtual void printVariant(FILE * file);
970ed795 265
3abe9331 266 virtual void addComment(const Mstring& text);
267 virtual void printComment(FILE * file, int level = 0);
970ed795 268
3abe9331 269 void printMinOccursMaxOccurs(FILE * file, const bool inside_union,
270 const bool empty_allowed = true) const;
970ed795 271
3abe9331 272 friend bool compareTypes(RootType * lhs, RootType * rhs);
970ed795
EL
273};
274
3abe9331 275inline bool compareTypes(RootType * lhs, RootType * rhs) {
970ed795
EL
276 return lhs->name.originalValueWoPrefix < rhs->name.originalValueWoPrefix;
277}
278
279#endif /* BASETYPE_HH_ */
This page took 0.035926 seconds and 5 git commands to generate.