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
13 ******************************************************************************/
17 #include "GeneralTypes.hh"
21 #include <cmath> // for using "pow" function
27 #define ULLONG_MAX 18446744073709551615ULL
30 #define LLONG_MIN -9223372036854775808LL
33 #define LLONG_MAX 9223372036854775807LL
36 extern bool c_flag_used;
37 extern bool e_flag_used;
44 V_attributeFormQualified,
50 V_elementFormQualified,
80 Mstring originalValueWoPrefix;
81 Mstring convertedValue;
85 NameType() : originalValueWoPrefix(), convertedValue(), list_extension(false), no_replace(false) {
87 // Default copy constructor, assignment operator and destructor are used
89 void upload(const Mstring& input) {
90 if (input.empty()) return;
91 convertedValue = input;
92 originalValueWoPrefix = input.getValueWithoutPrefix(':');
101 * This type is used as the base class for the used classes
102 * that represent the main datatypes in the generated TTCN-3 modules
104 * It is installed to have possibility to store main types in one container
110 XMLParser * parser; // no responsibility for this member
111 TTCN3Module * module; // no responsibility for this member
115 unsigned long long int minOccurs;
116 unsigned long long int maxOccurs;
117 List<Mstring> variant;
118 List<Mstring> variant_ref;
119 List<Mstring> hidden_variant;
120 List<Mstring> comment;
122 ConstructType construct;
126 /// List of types that depend on this one.
127 /// Used to propagate the effect of name conversion to the dependents
128 List<SimpleType*> nameDepList; // no responsibility for elements
131 RootType(XMLParser * a_parser, TTCN3Module * a_module, const ConstructType a_construct);
133 virtual ~RootType() {
135 // Default copy constructor and assignment operator is used
137 virtual void loadWithValues() = 0;
138 virtual void printToFile(FILE * file) = 0;
140 virtual void modifyValues() {
143 virtual void referenceResolving() {
146 virtual void nameConversion(const NameConversionMode, const List<NamespaceType> &) {
149 virtual void finalModification() {
152 virtual bool hasUnresolvedReference() {
156 virtual void dump(const unsigned int) const {
159 void setNameValue(const Mstring& str) {
160 name.convertedValue = str;
163 void setTypeValue(const Mstring& str) {
164 type.convertedValue = str;
167 void useNameListProperty() {
168 name.convertedValue += "_list";
171 void setInvisible() {
179 const NameType & getName() const {
183 const NameType & getType() const {
187 unsigned long long int getMinOccurs() const {
191 unsigned long long int getMaxOccurs() const {
195 const List<Mstring> & getVariant() const {
199 const List<Mstring> & getVariantRef() const {
203 const List<Mstring> & getHiddenVariant() const {
204 return hidden_variant;
207 ConstructType getConstruct() const {
211 OriginType getOrigin() const {
215 bool isVisible() const {
219 List<Mstring> & getComment() {
223 List<SimpleType*> & getNameDepList() {
227 XMLParser * getParser() const {
231 TTCN3Module * getModule() const {
235 void setModule(TTCN3Module * mod) {
239 bool hasVariant(const Mstring& var) const;
241 void addVariant(const VariantMode var, const Mstring& var_value = empty_string, const bool into_variant_ref = false);
242 virtual void printVariant(FILE * file);
244 virtual void addComment(const Mstring& text);
245 virtual void printComment(FILE * file, int level = 0);
247 void printMinOccursMaxOccurs(FILE * file, const bool inside_union,
248 const bool empty_allowed = true) const;
250 friend bool compareTypes(RootType * lhs, RootType * rhs);
253 inline bool compareTypes(RootType * lhs, RootType * rhs) {
254 return lhs->name.originalValueWoPrefix < rhs->name.originalValueWoPrefix;
257 #endif /* BASETYPE_HH_ */