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