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);
115 void printVariant(FILE * file);
118 List<ComplexType*> complexfields;
119 List<AttributeType*> attribfields;
120 List<Mstring> enumfields;
121 List<TagName> tagNames;
123 ComplexType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct);
124 ComplexType(ComplexType & other);
125 ComplexType(const SimpleType & other, CT_fromST c);
126 ComplexType(ComplexType * other);
129 void modifyAttributeParent();
130 void addSubstitution(SimpleType * st);
131 void addTypeSubstitution(SimpleType * st);
134 * inherited from RootType
136 void loadWithValues();
137 void addComment(const Mstring& text);
138 void printToFile(FILE * file);
139 void printToFile(FILE * file, const unsigned level, const bool is_union);
142 void referenceResolving();
143 void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns);
144 void finalModification();
145 bool hasUnresolvedReference(){ return resolved == No; }
146 void setNameDep(SimpleType * dep) { nameDep = dep; }
147 void setParentTypeSubsGroup(ComplexType * dep) { parentTypeSubsGroup = dep; }
149 void dump(unsigned int depth) const;
153 inline bool compareComplexTypeNameSpaces(ComplexType * lhs, ComplexType * rhs) {
154 if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
156 } else if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
158 } else if (rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
161 return lhs->getModule()->getTargetNamespace() <= rhs->getModule()->getTargetNamespace();
165 inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) {
166 return lhs->getName().convertedValue < rhs->getName().convertedValue;
170 #endif /* COMPLEXTYPE_H_ */