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
14 ******************************************************************************/
15 #ifndef COMPLEXTYPE_H_
16 #define COMPLEXTYPE_H_
18 #include "RootType.hh"
19 #include "SimpleType.hh"
20 #include "TTCN3Module.hh"
21 #include "AttributeType.hh"
27 * Type that contains information coming from XSD complexTypes, model group definitions
32 * * <complexType>, <group> and <attributeGroup> element whose parent element is <schema>
33 * * <element> if nillable, or is a child of <complexType>
40 class ComplexType : public SimpleType {
43 enum ComplexType_Mode {
64 //If the complextype is a top level component (child of schema)
74 //Special use: true if an element of a complextype is restricted to a list
81 RootType * nillable_field;
82 ComplexType * basefield;
83 ComplexType_Mode cmode;
84 Resolv_State resolved;
85 ComplexType * parentTypeSubsGroup;
88 void applyAttributeRestriction(ComplexType * found_CT);
89 void applyAttributeExtension(ComplexType * found_CT, AttributeType * anyAttr = NULL);
90 void nameConversion_names(const List<NamespaceType> & ns);
91 void nameConversion_types(const List<NamespaceType> & ns);
92 void nameConversion_fields(const List<NamespaceType> & ns);
93 void setFieldPaths(Mstring path);
94 void collectVariants(List<Mstring>& container);
95 void addNameSpaceAsVariant(RootType * type, RootType * other);
96 void setMinMaxOccurs(const unsigned long long min, const unsigned long long max, const bool generate_list_postfix = true);
97 void applyNamespaceAttribute(VariantMode varLabel, const Mstring& ns_list);
98 void applyReference(const SimpleType & other, const bool on_attributes = false);
99 void setParent(ComplexType * par, SimpleType * child);
100 void finalModification2();
101 Mstring findRoot(const BlockValue value, SimpleType * elem, const Mstring& head_type, const bool first);
103 //Reference resolving functions
104 void reference_resolving_funtion();
105 void resolveAttribute(AttributeType *attr);
106 void resolveAttributeGroup(SimpleType *st);
107 void resolveGroup(SimpleType *st);
108 void resolveElement(SimpleType *st);
109 void resolveSimpleTypeExtension();
110 void resolveSimpleTypeRestriction();
111 void resolveComplexTypeExtension();
112 void resolveComplexTypeRestriction();
113 void resolveUnion(SimpleType *st);
114 bool hasMatchingFields(const List<ComplexType*>& a, const List<ComplexType*>& b) const;
116 void printVariant(FILE * file);
119 List<ComplexType*> complexfields;
120 List<AttributeType*> attribfields;
121 List<Mstring> enumfields;
122 List<TagName> tagNames;
124 ComplexType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct);
125 ComplexType(ComplexType & other);
126 ComplexType(const SimpleType & other, CT_fromST c);
127 ComplexType(ComplexType * other);
130 void modifyAttributeParent();
131 void addSubstitution(SimpleType * st);
132 void addTypeSubstitution(SimpleType * st);
135 * inherited from RootType
137 void loadWithValues();
138 void addComment(const Mstring& text);
139 void printToFile(FILE * file);
140 void printToFile(FILE * file, const unsigned level, const bool is_union);
143 void referenceResolving();
144 void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns);
145 void finalModification();
146 bool hasUnresolvedReference(){ return resolved == No; }
147 void setNameDep(SimpleType * dep) { nameDep = dep; }
148 void setParentTypeSubsGroup(ComplexType * dep) { parentTypeSubsGroup = dep; }
150 void dump(unsigned int depth) const;
154 inline bool compareComplexTypeNameSpaces(ComplexType * lhs, ComplexType * rhs) {
155 if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
157 } else if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
159 } else if (rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
162 return lhs->getModule()->getTargetNamespace() <= rhs->getModule()->getTargetNamespace();
166 inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) {
167 return lhs->getName().convertedValue < rhs->getName().convertedValue;
171 #endif /* COMPLEXTYPE_H_ */