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
16 ******************************************************************************/
20 #include "RootType.hh"
25 LengthType & operator=(const LengthType &); // not implemented
26 // it's a bit strange that it has copy constructor but no assignment
28 SimpleType * parent; // no responsibility for this member
30 unsigned long long int facet_minLength;
31 unsigned long long int facet_maxLength;
32 unsigned long long int lower;
33 unsigned long long int upper;
35 LengthType(SimpleType * p_parent);
36 // Default copy constructor and destructor are used
38 void applyReference(const LengthType & other);
40 void printToFile(FILE * file) const;
44 PatternType & operator=(const PatternType &); // not implemented
45 // it's a bit strange that it has copy constructor but no assignment
47 SimpleType * parent; // no responsibility for this member
52 PatternType(SimpleType * p_parent);
53 // Default copy constructor and destructor are used
55 void applyReference(const PatternType & other);
57 void printToFile(FILE * file) const;
60 class EnumerationType {
61 EnumerationType & operator=(const EnumerationType &); // not implemented
62 // it's a bit strange that it has copy constructor but no assignment
64 SimpleType * parent; // no responsibility for this member
67 List<QualifiedName> items_string;
69 List<double> items_float;
70 List<QualifiedName> items_time;
71 List<Mstring> items_misc;
72 List<Mstring> variants;
74 EnumerationType(SimpleType * p_parent);
75 // Default copy constructor and destructor are used
77 void applyReference(const EnumerationType & other);
80 void printToFile(FILE * file, unsigned int indent_level = 0) const;
81 void insertVariants();
84 class WhitespaceType {
85 WhitespaceType & operator=(const WhitespaceType &); // not implemented
86 // it's a bit strange that it has copy constructor but no assignment
88 SimpleType * p_parent; // no responsibility for this member
93 WhitespaceType(SimpleType * p_parent);
94 // Default copy constructor and destructor are used
96 void applyReference(const WhitespaceType & other);
98 void printToFile(FILE * file) const;
102 ValueType & operator=(const ValueType &); // not implemented
103 // it's a bit strange that it has copy constructor but no assignment
105 SimpleType * parent; // no responsibility for this member
107 long double facet_minInclusive;
108 long double facet_maxInclusive;
109 long double facet_minExclusive;
110 long double facet_maxExclusive;
111 int facet_totalDigits;
118 Mstring default_value;
119 List<Mstring> items_with_value;
121 ValueType(SimpleType * p_parent);
122 // Default copy constructor and destructor are used
124 void applyReference(const ValueType & other);
126 void printToFile(FILE * file) const;
131 class ReferenceData {
142 void load(const Mstring& u, const Mstring& v, NamespaceType *n) {
148 const Mstring& get_uri() const {
152 const Mstring& get_val() const {
156 RootType *get_ref() const {
161 return uri.empty() && value.empty();
164 bool is_resolved() const {
168 void set_resolved(RootType *st /*= NULL*/) {
173 Mstring repr() const {
174 return uri + Mstring("|") + value;
176 private: // implementation
181 RootType *ref; // not owned
185 * Type that contains information coming from XSD simpleTypes, elements and attributes
189 * * <simpleType>, <element> and <attribute> element whose parent element is <schema>
196 class SimpleType : public RootType {
211 EnumerationType enumeration;
212 WhitespaceType whitespace;
215 FormValue element_form_as;
216 FormValue attribute_form_as;
220 ReferenceData outside_reference;
222 /// true if name_dependency would be set (not empty)
225 // True if element or attribute used with ref attribute
227 // XSD Type of the type
230 Mstring substitutionGroup;
231 //Pointer to the generated element substitution group
232 ComplexType * subsGroup;
233 //Pointer to the generated type substitution group
234 ComplexType * typeSubsGroup;
235 //To determine if already added to type substitution
236 bool addedToTypeSubstitution;
239 //Element substitution
240 void addToSubstitutions();
243 void addToTypeSubstitutions();
244 //Returns the type substitution which the builtInType belongs
245 ComplexType * findBuiltInTypeInStoredTypeSubstitutions(const Mstring& builtInType);
247 //Only used when type substitution is enabled
248 //If an element reference is found then it is put to a container
249 //to know if type substitution is possible
250 void collectElementTypes(SimpleType * found_ST = NULL, ComplexType * found_CT = NULL);
251 void nameConversion_names();
252 virtual void nameConversion_types(const List<NamespaceType> & ns);
254 SimpleType & operator=(const SimpleType &); // not implemented
255 // it's a bit strange that it has copy constructor but no assignment
257 SimpleType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct);
258 SimpleType(const SimpleType& other);
259 // Default destructor is used
261 // Parent of the element (both complexType, and AttributeType) has this
262 // Not responsible for this member
263 ComplexType * parent;
266 * inherited from RootType
268 void loadWithValues();
269 void printToFile(FILE * file);
270 void referenceResolving();
271 void nameConversion(const NameConversionMode mode, const List<NamespaceType> & ns);
272 void finalModification();
273 virtual bool hasUnresolvedReference();
274 void dump(const unsigned int depth) const;
276 void applyDefaultAttribute(const Mstring& default_value);
277 void applyFixedAttribute(const Mstring& fixed_value);
278 void applyNillableAttribute(const bool nillable_value);
279 void applyAbstractAttribute(const bool abstract_value);
280 void applySubstitionGroupAttribute(const Mstring& substition_group);
281 void applyBlockAttribute(const BlockValue block_);
282 void applyRefAttribute(const Mstring& ref_value);
284 const Mstring & getBuiltInBase() const {
288 const LengthType & getLength() const {
292 const ValueType & getValue() const {
296 const PatternType & getPattern() const {
300 const WhitespaceType & getWhitespace() const {
304 const EnumerationType & getEnumeration() const {
308 FormValue getElementFormAs() const {
309 return element_form_as;
312 FormValue getAttributeFormAs() const {
313 return attribute_form_as;
316 Mode getMode() const {
320 bool isFromRef() const {
324 const ReferenceData& getReference() const {
325 return outside_reference;
328 EnumerationType & getEnumeration() {
332 void setBuiltInBase(const Mstring& base) {
336 void setMode(Mode m) {
340 void setElementFormAs(FormValue f) {
344 void setAttributeFormAs(FormValue f) {
345 attribute_form_as = f;
348 void setReference(const Mstring& ref, bool only_name_dependency = false);
350 void referenceForST(SimpleType * found_ST);
351 void referenceForCT(ComplexType * found_CT);
353 void setXsdtype(TagName xsdtype_) {
357 TagName getXsdtype() const {
361 ComplexType * getSubstitution() const {
365 ComplexType * getTypeSubstitution() const {
366 return typeSubsGroup;
369 BlockValue getBlock() const {
373 void addToNameDepList(SimpleType * t) {
374 //If the type has a substitution, we add the namedep to the substitution
375 if(subsGroup != NULL && this != (SimpleType*)subsGroup){
376 SimpleType * substitution = (SimpleType*)subsGroup;
377 substitution->addToNameDepList(t);
378 }else if(typeSubsGroup != NULL && this != (SimpleType*)typeSubsGroup){
379 SimpleType * substitution = (SimpleType*)typeSubsGroup;
380 substitution->addToNameDepList(t);
382 nameDepList.push_back(t);
388 #endif /* SIMPLETYPE_H_ */