Update README.linux
[deliverable/titan.core.git] / xsdconvert / SimpleType.hh
CommitLineData
970ed795
EL
1///////////////////////////////////////////////////////////////////////////////
2// Copyright (c) 2000-2014 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 SIMPLETYPE_H_
9#define SIMPLETYPE_H_
10
11#include "RootType.hh"
12
13class SimpleType;
14
15class LengthType
16{
17 LengthType & operator = (const LengthType &); // not implemented
18 // it's a bit strange that it has copy constructor but no assignment
19public:
20 SimpleType * parent; // no responsibility for this member
21 bool modified;
22 unsigned long long int facet_minLength;
23 unsigned long long int facet_maxLength;
24 unsigned long long int lower;
25 unsigned long long int upper;
26
27 LengthType (SimpleType * p_parent);
28 // Default copy constructor and destructor are used
29
30 void applyReference (const LengthType & other);
31 void applyFacets ();
32 void printToFile (FILE * file) const;
33};
34
35class PatternType
36{
37 PatternType & operator = (const PatternType &); // not implemented
38 // it's a bit strange that it has copy constructor but no assignment
39public:
40 SimpleType * parent; // no responsibility for this member
41 bool modified;
42 Mstring facet;
43 Mstring value;
44
45 PatternType (SimpleType * p_parent);
46 // Default copy constructor and destructor are used
47
48 void applyReference (const PatternType & other);
49 void applyFacet ();
50 void printToFile (FILE * file) const;
51};
52
53class EnumerationType
54{
55 EnumerationType & operator = (const EnumerationType &); // not implemented
56 // it's a bit strange that it has copy constructor but no assignment
57public:
58 SimpleType * parent; // no responsibility for this member
59 bool modified;
60 List<Mstring> facets;
61 List<QualifiedName> items_string;
62 List<int> items_int;
63 List<double> items_float;
64 List<QualifiedName> items_time;
65 List<Mstring> items_misc;
66
67 EnumerationType (SimpleType * p_parent);
68 // Default copy constructor and destructor are used
69
70 void applyReference (const EnumerationType & other);
71 void applyFacets ();
72 void sortFacets ();
73 void printToFile (FILE * file, unsigned int indent_level = 0) const;
74};
75
76class WhitespaceType
77{
78 WhitespaceType & operator = (const WhitespaceType &); // not implemented
79 // it's a bit strange that it has copy constructor but no assignment
80public:
81 SimpleType * p_parent; // no responsibility for this member
82 bool modified;
83 Mstring facet;
84 Mstring value;
85
86 WhitespaceType (SimpleType * p_parent);
87 // Default copy constructor and destructor are used
88
89 void applyReference (const WhitespaceType & other);
90 void applyFacet ();
91 void printToFile (FILE * file) const;
92};
93
94class ValueType
95{
96 ValueType & operator = (const ValueType &); // not implemented
97 // it's a bit strange that it has copy constructor but no assignment
98public:
99 SimpleType * parent; // no responsibility for this member
100 bool modified;
101 long double facet_minInclusive;
102 long double facet_maxInclusive;
103 long double facet_minExclusive;
104 long double facet_maxExclusive;
105 int facet_totalDigits;
106 long double lower;
107 long double upper;
108 bool lowerExclusive;
109 bool upperExclusive;
110 Mstring fixed_value;
111 Mstring default_value;
112 List<Mstring> items_with_value;
113
114 ValueType (SimpleType * p_parent);
115 // Default copy constructor and destructor are used
116
117 void applyReference (const ValueType & other);
118 void applyFacets ();
119 void printToFile (FILE * file) const;
120};
121
122class ComplexType;
123
124class ReferenceData {
125public: // interface
126 ReferenceData()
127 : nst(0)
128 , uri()
129 , value()
130 , resolved(false)
131 , ref(NULL)
132 {}
133
134 void load(const Mstring& u, const Mstring& v, NamespaceType *n)
135 {
136 uri = u;
137 value = v;
138 nst = n;
139 }
140
141 const Mstring& get_uri() const { return uri; }
142 const Mstring& get_val() const { return value; }
143 const RootType *get_ref() const { return ref; }
144
145 bool empty() const {
146 return uri.empty() && value.empty();
147 }
148
149 bool is_resolved() const { return resolved; }
150 void set_resolved(RootType const *st /*= NULL*/) { resolved = true; ref = st; }
151
152 Mstring repr() const { return uri + Mstring("|") + value; }
153private: // implementation
154 NamespaceType *nst;
155 Mstring uri;
156 Mstring value;
157 bool resolved;
158 const RootType *ref; // not owned
159};
160
161/**
162 * Type that contains information coming from XSD simpleTypes, elements and attributes
163 *
164 * Source in XSD:
165 *
166 * * <simpleType>, <element> and <attribute> element whose parent element is <schema>
167 *
168 * Result in TTCN-3:
169 *
170 * * TTCN-3 type
171 *
172 */
173class SimpleType : public RootType
174{
175public:
176 enum Mode
177 {
178 noMode,
179 restrictionMode,
180 extensionMode,
181 listMode
182 };
183
184protected:
185 Mstring builtInBase;
186
187 LengthType length;
188 PatternType pattern;
189 EnumerationType enumeration;
190 WhitespaceType whitespace;
191 ValueType value;
192
193 FormValue element_form_as;
194 FormValue attribute_form_as;
195
196 Mode mode;
197
198 ReferenceData outside_reference;
199
200 /// true if name_dependency would be set (not empty)
201 bool in_name_only;
202
203 void referenceForST (SimpleType const * const found_ST);
204 void referenceForCT (ComplexType const * const found_CT);
205
206 void nameConversion_names ();
207 void nameConversion_types (const List<NamespaceType> & ns);
208
209 SimpleType & operator = (const SimpleType &); // not implemented
210 // it's a bit strange that it has copy constructor but no assignment
211public:
212 SimpleType (XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct);
213 SimpleType(const SimpleType& other);
214 // Default destructor is used
215
216 /** Virtual methods
217 * inherited from RootType
218 */
219 void loadWithValues ();
220 void printToFile (FILE * file);
221 void referenceResolving ();
222 void nameConversion (NameConversionMode mode, const List<NamespaceType> & ns);
223 void finalModification ();
224 bool hasUnresolvedReference ();
225 void dump (unsigned int depth) const;
226
227 void applyDefaultAttribute (const Mstring& default_value);
228 void applyFixedAttribute (const Mstring& fixed_value);
229 void applyNillableAttribute (bool nillable_value);
230
231 const Mstring & getBuiltInBase () const {return builtInBase;}
232 const LengthType & getLength () const {return length;}
233 const ValueType & getValue () const {return value;}
234 FormValue getElementFormAs () const {return element_form_as;}
235 FormValue getAttributeFormAs () const {return attribute_form_as;}
236 Mode getMode () const {return mode;}
237 const ReferenceData& getReference() const { return outside_reference; }
238
239 EnumerationType & getEnumeration () {return enumeration;}
240
241 void setBuiltInBase (const Mstring& base) {builtInBase = base;}
242 void setMode (Mode m) {mode = m;}
243 void setElementFormAs (FormValue f) {element_form_as = f;}
244 void setAttributeFormAs (FormValue f) {attribute_form_as = f;}
245
246 void setReference (const Mstring& ref, bool only_name_dependency = false);
247};
248
249#endif /* SIMPLETYPE_H_ */
This page took 0.032709 seconds and 5 git commands to generate.