Commit | Line | Data |
---|---|---|
970ed795 | 1 | /////////////////////////////////////////////////////////////////////////////// |
3abe9331 | 2 | // Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef COMPLEXTYPE_H_ | |
9 | #define COMPLEXTYPE_H_ | |
10 | ||
11 | #include "RootType.hh" | |
3abe9331 | 12 | #include "SimpleType.hh" |
13 | #include "TTCN3Module.hh" | |
14 | #include "AttributeType.hh" | |
970ed795 | 15 | |
970ed795 | 16 | |
3abe9331 | 17 | class AttributeType; |
970ed795 EL |
18 | |
19 | /** | |
20 | * Type that contains information coming from XSD complexTypes, model group definitions | |
21 | * and attributeGroups | |
22 | * | |
23 | * Source in XSD: | |
24 | * | |
25 | * * <complexType>, <group> and <attributeGroup> element whose parent element is <schema> | |
3abe9331 | 26 | * * <element> if nillable, or is a child of <complexType> |
970ed795 EL |
27 | * |
28 | * Result in TTCN-3: | |
29 | * | |
30 | * * TTCN-3 type | |
31 | * | |
32 | */ | |
3abe9331 | 33 | class ComplexType : public SimpleType { |
970ed795 | 34 | public: |
3abe9331 | 35 | |
36 | enum ComplexType_Mode { | |
970ed795 EL |
37 | CT_simpletype_mode, |
38 | CT_complextype_mode, | |
39 | CT_undefined_mode | |
40 | }; | |
3abe9331 | 41 | |
42 | enum CT_fromST { | |
970ed795 EL |
43 | fromTagUnion, |
44 | fromTagNillable, | |
3abe9331 | 45 | fromTagComplexType, |
46 | fromTagSubstition | |
970ed795 | 47 | }; |
3abe9331 | 48 | |
970ed795 EL |
49 | enum Resolv_State { |
50 | No, | |
51 | InProgress, | |
52 | Yes | |
53 | }; | |
54 | ||
55 | private: | |
3abe9331 | 56 | //If the complextype is a top level component (child of schema) |
57 | bool top; | |
58 | bool nillable; | |
59 | bool enumerated; | |
60 | bool embed; | |
970ed795 | 61 | bool with_union; |
3abe9331 | 62 | bool first_child; |
63 | bool fromAll; | |
64 | unsigned max_alt; | |
65 | int skipback; | |
66 | TagName lastType; | |
67 | Mstring actualPath; | |
68 | RootType * actfield; | |
69 | SimpleType * nameDep; | |
70 | RootType * nillable_field; | |
71 | ComplexType * basefield; | |
72 | ComplexType_Mode cmode; | |
970ed795 EL |
73 | Resolv_State resolved; |
74 | ||
970ed795 | 75 | |
3abe9331 | 76 | void applyAttributeRestriction(ComplexType * found_CT); |
77 | void applyAttributeExtension(ComplexType * found_CT, AttributeType * anyAttr = NULL); | |
78 | void nameConversion_names(const List<NamespaceType> & ns); | |
79 | void nameConversion_types(const List<NamespaceType> & ns); | |
80 | void nameConversion_fields(const List<NamespaceType> & ns); | |
81 | void setFieldPaths(Mstring path); | |
82 | void collectVariants(List<Mstring>& container); | |
83 | void addNameSpaceAsVariant(RootType * type, RootType * other); | |
84 | void setMinMaxOccurs(const unsigned long long min, const unsigned long long max, const bool generate_list_postfix = true); | |
85 | void applyNamespaceAttribute(VariantMode varLabel, const Mstring& ns_list); | |
86 | void applyReference(const SimpleType & other, const bool on_attributes = false); | |
87 | void setParent(ComplexType * par, SimpleType * child); | |
88 | void finalModification2(); | |
89 | Mstring findRoot(const BlockValue value, SimpleType * elem, const Mstring& head_type, const bool first); | |
90 | ||
91 | //Reference resolving functions | |
92 | void reference_resolving_funtion(); | |
93 | void resolveAttribute(AttributeType *attr); | |
94 | void resolveAttributeGroup(SimpleType *st); | |
95 | void resolveGroup(SimpleType *st); | |
96 | void resolveElement(SimpleType *st); | |
97 | void resolveSimpleTypeExtension(); | |
98 | void resolveSimpleTypeRestriction(); | |
99 | void resolveComplexTypeExtension(); | |
100 | void resolveComplexTypeRestriction(); | |
101 | void resolveUnion(SimpleType *st); | |
102 | ||
103 | void printVariant(FILE * file); | |
970ed795 EL |
104 | |
105 | public: | |
3abe9331 | 106 | List<ComplexType*> complexfields; |
107 | List<AttributeType*> attribfields; | |
108 | List<Mstring> enumfields; | |
109 | List<TagName> tagNames; | |
110 | ||
111 | ComplexType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct); | |
112 | ComplexType(ComplexType & other); | |
113 | ComplexType(const SimpleType & other, CT_fromST c); | |
114 | ComplexType(ComplexType * other); | |
115 | ~ComplexType(); | |
116 | ||
117 | void modifyAttributeParent(); | |
118 | void addSubstitution(SimpleType* st); | |
970ed795 EL |
119 | |
120 | /** Virtual methods | |
121 | * inherited from RootType | |
122 | */ | |
3abe9331 | 123 | void loadWithValues(); |
124 | void addComment(const Mstring& text); | |
125 | void printToFile(FILE * file); | |
126 | void printToFile(FILE * file, const unsigned level, const bool is_union); | |
970ed795 | 127 | |
3abe9331 | 128 | void modifyValues(); |
129 | void referenceResolving(); | |
130 | void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns); | |
131 | void finalModification(); | |
132 | bool hasUnresolvedReference(){ return resolved == No; } | |
970ed795 | 133 | |
3abe9331 | 134 | void dump(unsigned int depth) const; |
970ed795 | 135 | |
3abe9331 | 136 | }; |
970ed795 | 137 | |
3abe9331 | 138 | inline bool compareComplexTypeNameSpaces(ComplexType * lhs, ComplexType * rhs) { |
139 | if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) { | |
140 | return false; | |
141 | } else if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) { | |
142 | return true; | |
143 | } else if (rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) { | |
144 | return false; | |
145 | } else { | |
146 | return lhs->getModule()->getTargetNamespace() <= rhs->getModule()->getTargetNamespace(); | |
147 | } | |
148 | } | |
970ed795 | 149 | |
3abe9331 | 150 | inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) { |
151 | return lhs->getName().convertedValue < rhs->getName().convertedValue; | |
152 | } | |
970ed795 | 153 | |
970ed795 EL |
154 | |
155 | #endif /* COMPLEXTYPE_H_ */ |