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