1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 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 ///////////////////////////////////////////////////////////////////////////////
11 #include "GeneralTypes.hh"
15 #include <cmath> // for using "pow" function
21 #define ULLONG_MAX 18446744073709551615ULL
24 #define LLONG_MIN -9223372036854775808LL
27 #define LLONG_MAX 9223372036854775807LL
30 extern bool c_flag_used;
31 extern bool e_flag_used;
38 V_attributeFormQualified,
44 V_elementFormQualified,
74 Mstring originalValueWoPrefix;
75 Mstring convertedValue;
79 NameType() : originalValueWoPrefix(), convertedValue(), list_extension(false), no_replace(false) {
81 // Default copy constructor, assignment operator and destructor are used
83 void upload(const Mstring& input) {
84 if (input.empty()) return;
85 convertedValue = input;
86 originalValueWoPrefix = input.getValueWithoutPrefix(':');
95 * This type is used as the base class for the used classes
96 * that represent the main datatypes in the generated TTCN-3 modules
98 * It is installed to have possibility to store main types in one container
104 XMLParser * parser; // no responsibility for this member
105 TTCN3Module * module; // no responsibility for this member
109 unsigned long long int minOccurs;
110 unsigned long long int maxOccurs;
111 List<Mstring> variant;
112 List<Mstring> variant_ref;
113 List<Mstring> hidden_variant;
114 List<Mstring> comment;
116 ConstructType construct;
120 /// List of types that depend on this one.
121 /// Used to propagate the effect of name conversion to the dependents
122 List<SimpleType*> nameDepList; // no responsibility for elements
125 RootType(XMLParser * a_parser, TTCN3Module * a_module, const ConstructType a_construct);
127 virtual ~RootType() {
129 // Default copy constructor and assignment operator is used
131 virtual void loadWithValues() = 0;
132 virtual void printToFile(FILE * file) = 0;
134 virtual void modifyValues() {
137 virtual void referenceResolving() {
140 virtual void nameConversion(const NameConversionMode, const List<NamespaceType> &) {
143 virtual void finalModification() {
146 virtual bool hasUnresolvedReference() {
150 virtual void dump(const unsigned int) const {
153 void setNameValue(const Mstring& str) {
154 name.convertedValue = str;
157 void setTypeValue(const Mstring& str) {
158 type.convertedValue = str;
161 void useNameListProperty() {
162 name.convertedValue += "_list";
165 void setInvisible() {
173 const NameType & getName() const {
177 const NameType & getType() const {
181 unsigned long long int getMinOccurs() const {
185 unsigned long long int getMaxOccurs() const {
189 const List<Mstring> & getVariant() const {
193 const List<Mstring> & getVariantRef() const {
197 const List<Mstring> & getHiddenVariant() const {
198 return hidden_variant;
201 ConstructType getConstruct() const {
205 OriginType getOrigin() const {
209 bool isVisible() const {
213 List<Mstring> & getComment() {
217 List<SimpleType*> & getNameDepList() {
221 XMLParser * getParser() const {
225 TTCN3Module * getModule() const {
229 void setModule(TTCN3Module * mod) {
233 bool hasVariant(const Mstring& var) const;
235 void addVariant(const VariantMode var, const Mstring& var_value = empty_string, const bool into_variant_ref = false);
236 virtual void printVariant(FILE * file);
238 virtual void addComment(const Mstring& text);
239 virtual void printComment(FILE * file, int level = 0);
241 void printMinOccursMaxOccurs(FILE * file, const bool inside_union,
242 const bool empty_allowed = true) const;
244 friend bool compareTypes(RootType * lhs, RootType * rhs);
247 inline bool compareTypes(RootType * lhs, RootType * rhs) {
248 return lhs->name.originalValueWoPrefix < rhs->name.originalValueWoPrefix;
251 #endif /* BASETYPE_HH_ */