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;
77 void applyAttributeRestriction(ComplexType * found_CT);
78 void applyAttributeExtension(ComplexType * found_CT, AttributeType * anyAttr = NULL);
79 void nameConversion_names(const List<NamespaceType> & ns);
80 void nameConversion_types(const List<NamespaceType> & ns);
81 void nameConversion_fields(const List<NamespaceType> & ns);
82 void setFieldPaths(Mstring path);
83 void collectVariants(List<Mstring>& container);
84 void addNameSpaceAsVariant(RootType * type, RootType * other);
85 void setMinMaxOccurs(const unsigned long long min, const unsigned long long max, const bool generate_list_postfix = true);
86 void applyNamespaceAttribute(VariantMode varLabel, const Mstring& ns_list);
87 void applyReference(const SimpleType & other, const bool on_attributes = false);
88 void setParent(ComplexType * par, SimpleType * child);
89 void finalModification2();
90 Mstring findRoot(const BlockValue value, SimpleType * elem, const Mstring& head_type, const bool first);
92 //Reference resolving functions
93 void reference_resolving_funtion();
94 void resolveAttribute(AttributeType *attr);
95 void resolveAttributeGroup(SimpleType *st);
96 void resolveGroup(SimpleType *st);
97 void resolveElement(SimpleType *st);
98 void resolveSimpleTypeExtension();
99 void resolveSimpleTypeRestriction();
100 void resolveComplexTypeExtension();
101 void resolveComplexTypeRestriction();
102 void resolveUnion(SimpleType *st);
104 void printVariant(FILE * file);
107 List<ComplexType*> complexfields;
108 List<AttributeType*> attribfields;
109 List<Mstring> enumfields;
110 List<TagName> tagNames;
112 ComplexType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct);
113 ComplexType(ComplexType & other);
114 ComplexType(const SimpleType & other, CT_fromST c);
115 ComplexType(ComplexType * other);
118 void modifyAttributeParent();
119 void addSubstitution(SimpleType * st);
120 void addTypeSubstitution(SimpleType * st);
123 * inherited from RootType
125 void loadWithValues();
126 void addComment(const Mstring& text);
127 void printToFile(FILE * file);
128 void printToFile(FILE * file, const unsigned level, const bool is_union);
131 void referenceResolving();
132 void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns);
133 void finalModification();
134 bool hasUnresolvedReference(){ return resolved == No; }
135 void setNameDep(SimpleType * dep) { nameDep = dep; }
137 void dump(unsigned int depth) const;
141 inline bool compareComplexTypeNameSpaces(ComplexType * lhs, ComplexType * rhs) {
142 if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
144 } else if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
146 } else if (rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
149 return lhs->getModule()->getTargetNamespace() <= rhs->getModule()->getTargetNamespace();
153 inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) {
154 return lhs->getName().convertedValue < rhs->getName().convertedValue;
158 #endif /* COMPLEXTYPE_H_ */