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
16 ******************************************************************************/
20 #include "RootType.hh"
25 LengthType & operator=(const LengthType &); // not implemented
26 // it's a bit strange that it has copy constructor but no assignment
28 SimpleType * parent; // no responsibility for this member
30 unsigned long long int facet_minLength;
31 unsigned long long int facet_maxLength;
32 unsigned long long int lower;
33 unsigned long long int upper;
35 LengthType(SimpleType * p_parent);
36 // Default copy constructor and destructor are used
38 void applyReference(const LengthType & other);
40 void printToFile(FILE * file) const;
44 PatternType & operator=(const PatternType &); // not implemented
45 // it's a bit strange that it has copy constructor but no assignment
47 SimpleType * parent; // no responsibility for this member
52 PatternType(SimpleType * p_parent);
53 // Default copy constructor and destructor are used
55 void applyReference(const PatternType & other);
57 void printToFile(FILE * file) const;
60 class EnumerationType {
61 EnumerationType & operator=(const EnumerationType &); // not implemented
62 // it's a bit strange that it has copy constructor but no assignment
64 SimpleType * parent; // no responsibility for this member
67 List<QualifiedName> items_string;
69 List<double> items_float;
70 List<QualifiedName> items_time;
71 List<Mstring> items_misc;
72 List<Mstring> variants;
74 EnumerationType(SimpleType * p_parent);
75 // Default copy constructor and destructor are used
77 void applyReference(const EnumerationType & other);
80 void printToFile(FILE * file, unsigned int indent_level = 0) const;
81 void insertVariants();
84 class WhitespaceType {
85 WhitespaceType & operator=(const WhitespaceType &); // not implemented
86 // it's a bit strange that it has copy constructor but no assignment
88 SimpleType * p_parent; // no responsibility for this member
93 WhitespaceType(SimpleType * p_parent);
94 // Default copy constructor and destructor are used
96 void applyReference(const WhitespaceType & other);
98 void printToFile(FILE * file) const;
102 ValueType & operator=(const ValueType &); // not implemented
103 // it's a bit strange that it has copy constructor but no assignment
105 SimpleType * parent; // no responsibility for this member
107 long double facet_minInclusive;
108 long double facet_maxInclusive;
109 long double facet_minExclusive;
110 long double facet_maxExclusive;
111 int facet_totalDigits;
118 Mstring default_value;
119 List<Mstring> items_with_value;
121 ValueType(SimpleType * p_parent);
122 // Default copy constructor and destructor are used
124 void applyReference(const ValueType & other);
126 void printToFile(FILE * file) const;
131 class ReferenceData {
142 void load(const Mstring& u, const Mstring& v, NamespaceType *n) {
148 const Mstring& get_uri() const {
152 const Mstring& get_val() const {
156 RootType *get_ref() const {
161 return uri.empty() && value.empty();
164 bool is_resolved() const {
168 void set_resolved(RootType *st /*= NULL*/) {
173 Mstring repr() const {
174 return uri + Mstring("|") + value;
176 private: // implementation
181 RootType *ref; // not owned
185 * Type that contains information coming from XSD simpleTypes, elements and attributes
189 * * <simpleType>, <element> and <attribute> element whose parent element is <schema>
196 class SimpleType : public RootType {
204 restrictionAfterListMode
212 EnumerationType enumeration;
213 WhitespaceType whitespace;
216 FormValue element_form_as;
217 FormValue attribute_form_as;
221 ReferenceData outside_reference;
223 /// true if name_dependency would be set (not empty)
226 // True if element or attribute used with ref attribute
228 // XSD Type of the type
231 Mstring substitutionGroup;
232 //Pointer to the generated element substitution group
233 ComplexType * subsGroup;
234 //Pointer to the generated type substitution group
235 ComplexType * typeSubsGroup;
236 //To determine if already added to type substitution
237 bool addedToTypeSubstitution;
240 //Special use: true if an element of a complexType is restricted to a list
241 // in a simpleType, or a simpleType is a restriction of a list, which is a
242 // restriction of a simpleType
244 // We are inside a list if inList is true and mode == listMode
246 //Element substitution
247 void addToSubstitutions();
250 void addToTypeSubstitutions();
251 //Returns the type substitution which the builtInType belongs
252 ComplexType * findBuiltInTypeInStoredTypeSubstitutions(const Mstring& builtInType);
254 //Only used when type substitution is enabled
255 //If an element reference is found then it is put to a container
256 //to know if type substitution is possible
257 void collectElementTypes(SimpleType * found_ST = NULL, ComplexType * found_CT = NULL);
258 void nameConversion_names();
259 virtual void nameConversion_types(const List<NamespaceType> & ns);
261 SimpleType & operator=(const SimpleType &); // not implemented
262 // it's a bit strange that it has copy constructor but no assignment
264 SimpleType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct);
265 SimpleType(const SimpleType& other);
266 // Default destructor is used
268 // Parent of the element (both complexType, and AttributeType) has this
269 // Not responsible for this member
270 ComplexType * parent;
273 * inherited from RootType
275 void loadWithValues();
276 void printToFile(FILE * file);
277 void referenceResolving();
278 void nameConversion(const NameConversionMode mode, const List<NamespaceType> & ns);
279 void finalModification();
280 virtual bool hasUnresolvedReference();
281 void dump(const unsigned int depth) const;
283 void applyDefaultAttribute(const Mstring& default_value);
284 void applyFixedAttribute(const Mstring& fixed_value);
285 void applyNillableAttribute(const bool nillable_value);
286 void applyAbstractAttribute(const bool abstract_value);
287 void applySubstitionGroupAttribute(const Mstring& substition_group);
288 void applyBlockAttribute(const BlockValue block_);
289 void applyRefAttribute(const Mstring& ref_value);
291 const Mstring & getBuiltInBase() const {
295 const LengthType & getLength() const {
299 const ValueType & getValue() const {
303 const PatternType & getPattern() const {
307 const WhitespaceType & getWhitespace() const {
311 const EnumerationType & getEnumeration() const {
315 FormValue getElementFormAs() const {
316 return element_form_as;
319 FormValue getAttributeFormAs() const {
320 return attribute_form_as;
323 Mode getMode() const {
327 bool isFromRef() const {
331 const ReferenceData& getReference() const {
332 return outside_reference;
335 EnumerationType & getEnumeration() {
339 void setBuiltInBase(const Mstring& base) {
343 void setMode(Mode m) {
347 void setElementFormAs(FormValue f) {
351 void setAttributeFormAs(FormValue f) {
352 attribute_form_as = f;
355 void setReference(const Mstring& ref, bool only_name_dependency = false);
357 void referenceForST(SimpleType * found_ST);
358 void referenceForCT(ComplexType * found_CT);
360 void setXsdtype(TagName xsdtype_) {
364 TagName getXsdtype() const {
368 ComplexType * getSubstitution() const {
372 ComplexType * getTypeSubstitution() const {
373 return typeSubsGroup;
376 BlockValue getBlock() const {
380 void setList(const bool value) {
384 void addToNameDepList(SimpleType * t) {
385 //If the type has a substitution, we add the namedep to the substitution
386 if(subsGroup != NULL && this != (SimpleType*)subsGroup){
387 SimpleType * substitution = (SimpleType*)subsGroup;
388 substitution->addToNameDepList(t);
389 }else if(typeSubsGroup != NULL && this != (SimpleType*)typeSubsGroup){
390 SimpleType * substitution = (SimpleType*)typeSubsGroup;
391 substitution->addToNameDepList(t);
393 nameDepList.push_back(t);
399 #endif /* SIMPLETYPE_H_ */