Sync with 5.4.1
[deliverable/titan.core.git] / xsdconvert / ComplexType.hh
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 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef COMPLEXTYPE_H_
9 #define COMPLEXTYPE_H_
10
11 #include "RootType.hh"
12 #include "SimpleType.hh"
13 #include "TTCN3Module.hh"
14 #include "AttributeType.hh"
15
16
17 class AttributeType;
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>
26 * * <element> if nillable, or is a child of <complexType>
27 *
28 * Result in TTCN-3:
29 *
30 * * TTCN-3 type
31 *
32 */
33 class ComplexType : public SimpleType {
34 public:
35
36 enum ComplexType_Mode {
37 CT_simpletype_mode,
38 CT_complextype_mode,
39 CT_undefined_mode
40 };
41
42 enum CT_fromST {
43 fromTagUnion,
44 fromTagNillable,
45 fromTagComplexType,
46 fromTagSubstitution,
47 fromTypeSubstitution
48 };
49
50 enum Resolv_State {
51 No,
52 InProgress,
53 Yes
54 };
55
56 private:
57 //If the complextype is a top level component (child of schema)
58 bool top;
59 bool nillable;
60 bool enumerated;
61 bool embed;
62 bool with_union;
63 bool first_child;
64 bool fromAll;
65 unsigned max_alt;
66 int skipback;
67 TagName lastType;
68 Mstring actualPath;
69 RootType * actfield;
70 SimpleType * nameDep;
71 RootType * nillable_field;
72 ComplexType * basefield;
73 ComplexType_Mode cmode;
74 Resolv_State resolved;
75
76
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);
91
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);
103
104 void printVariant(FILE * file);
105
106 public:
107 List<ComplexType*> complexfields;
108 List<AttributeType*> attribfields;
109 List<Mstring> enumfields;
110 List<TagName> tagNames;
111
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);
116 ~ComplexType();
117
118 void modifyAttributeParent();
119 void addSubstitution(SimpleType * st);
120 void addTypeSubstitution(SimpleType * st);
121
122 /** Virtual methods
123 * inherited from RootType
124 */
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);
129
130 void modifyValues();
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; }
136
137 void dump(unsigned int depth) const;
138
139 };
140
141 inline bool compareComplexTypeNameSpaces(ComplexType * lhs, ComplexType * rhs) {
142 if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
143 return false;
144 } else if (lhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
145 return true;
146 } else if (rhs->getModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
147 return false;
148 } else {
149 return lhs->getModule()->getTargetNamespace() <= rhs->getModule()->getTargetNamespace();
150 }
151 }
152
153 inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) {
154 return lhs->getName().convertedValue < rhs->getName().convertedValue;
155 }
156
157
158 #endif /* COMPLEXTYPE_H_ */
This page took 0.035203 seconds and 5 git commands to generate.