1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 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 ///////////////////////////////////////////////////////////////////////////////
11 #include "RootType.hh"
12 #include "SimpleType.hh"
13 #include "TTCN3Module.hh"
14 #include "AttributeType.hh"
20 * Type that contains information coming from XSD complexTypes, model group definitions
25 * * <complexType>, <group> and <attributeGroup> element whose parent element is <schema>
26 * * <element> if nillable, or is a child of <complexType>
33 class ComplexType : public SimpleType {
36 enum ComplexType_Mode {
57 //If the complextype is a top level component (child of schema)
71 RootType * nillable_field;
72 ComplexType * basefield;
73 ComplexType_Mode cmode;
74 Resolv_State resolved;
75 ComplexType * parentTypeSubsGroup;
78 void applyAttributeRestriction(ComplexType * found_CT);
79 void applyAttributeExtension(ComplexType * found_CT, AttributeType * anyAttr = NULL);
80 void nameConversion_names(const List<NamespaceType> & ns);
81 void nameConversion_types(const List<NamespaceType> & ns);
82 void nameConversion_fields(const List<NamespaceType> & ns);
83 void setFieldPaths(Mstring path);
84 void collectVariants(List<Mstring>& container);
85 void addNameSpaceAsVariant(RootType * type, RootType * other);
86 void setMinMaxOccurs(const unsigned long long min, const unsigned long long max, const bool generate_list_postfix = true);
87 void applyNamespaceAttribute(VariantMode varLabel, const Mstring& ns_list);
88 void applyReference(const SimpleType & other, const bool on_attributes = false);
89 void setParent(ComplexType * par, SimpleType * child);
90 void finalModification2();
91 Mstring findRoot(const BlockValue value, SimpleType * elem, const Mstring& head_type, const bool first);
93 //Reference resolving functions
94 void reference_resolving_funtion();
95 void resolveAttribute(AttributeType *attr);
96 void resolveAttributeGroup(SimpleType *st);
97 void resolveGroup(SimpleType *st);
98 void resolveElement(SimpleType *st);
99 void resolveSimpleTypeExtension();
100 void resolveSimpleTypeRestriction();
101 void resolveComplexTypeExtension();
102 void resolveComplexTypeRestriction();
103 void resolveUnion(SimpleType *st);
105 void printVariant(FILE * file);
108 List<ComplexType*> complexfields;
109 List<AttributeType*> attribfields;
110 List<Mstring> enumfields;
111 List<TagName> tagNames;
113 ComplexType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct);
114 ComplexType(ComplexType & other);
115 ComplexType(const SimpleType & other, CT_fromST c);
116 ComplexType(ComplexType * other);
119 void modifyAttributeParent();
120 void addSubstitution(SimpleType * st);
121 void addTypeSubstitution(SimpleType * st);
124 * inherited from RootType
126 void loadWithValues();
127 void addComment(const Mstring& text);
128 void printToFile(FILE * file);
129 void printToFile(FILE * file, const unsigned level, const bool is_union);
132 void referenceResolving();
133 void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns);
134 void finalModification();
135 bool hasUnresolvedReference(){ return resolved == No; }
136 void setNameDep(SimpleType * dep) { nameDep = dep; }
137 void setParentTypeSubsGroup(ComplexType * dep) { parentTypeSubsGroup = dep; }
139 void dump(unsigned int depth) const;
143 inline bool compareComplexTypeNameSpaces(ComplexType * lhs, ComplexType * rhs) {
144 if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
146 } else if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
148 } else if (rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
151 return lhs->getModule()->getTargetNamespace() <= rhs->getModule()->getTargetNamespace();
155 inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) {
156 return lhs->getName().convertedValue < rhs->getName().convertedValue;
160 #endif /* COMPLEXTYPE_H_ */