Sync with 5.4.1
[deliverable/titan.core.git] / xsdconvert / ComplexType.hh
CommitLineData
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 17class 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 33class ComplexType : public SimpleType {
970ed795 34public:
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,
51fa56b9 46 fromTagSubstitution,
47 fromTypeSubstitution
970ed795 48 };
3abe9331 49
970ed795
EL
50 enum Resolv_State {
51 No,
52 InProgress,
53 Yes
54 };
55
56private:
3abe9331 57 //If the complextype is a top level component (child of schema)
58 bool top;
59 bool nillable;
60 bool enumerated;
61 bool embed;
970ed795 62 bool with_union;
3abe9331 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;
970ed795
EL
74 Resolv_State resolved;
75
970ed795 76
3abe9331 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);
970ed795
EL
105
106public:
3abe9331 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();
51fa56b9 119 void addSubstitution(SimpleType * st);
120 void addTypeSubstitution(SimpleType * st);
970ed795
EL
121
122 /** Virtual methods
123 * inherited from RootType
124 */
3abe9331 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);
970ed795 129
3abe9331 130 void modifyValues();
131 void referenceResolving();
132 void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns);
133 void finalModification();
134 bool hasUnresolvedReference(){ return resolved == No; }
51fa56b9 135 void setNameDep(SimpleType * dep) { nameDep = dep; }
970ed795 136
3abe9331 137 void dump(unsigned int depth) const;
970ed795 138
3abe9331 139};
970ed795 140
3abe9331 141inline 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}
970ed795 152
3abe9331 153inline bool compareTypes(ComplexType * lhs, ComplexType * rhs) {
154 return lhs->getName().convertedValue < rhs->getName().convertedValue;
155}
970ed795 156
970ed795
EL
157
158#endif /* COMPLEXTYPE_H_ */
This page took 0.055077 seconds and 5 git commands to generate.