1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
/******************************************************************************
* Copyright (c) 2000-2021 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Balasko, Jeno
* Szabo, Bence Janos
*
******************************************************************************/
#ifndef ATTRIBUTETYPE_HH_
#define ATTRIBUTETYPE_HH_
#include "SimpleType.hh"
#include "GeneralTypes.hh"
#include "GeneralFunctions.hh"
#include "GeneralFunctions.hh"
#include "TTCN3Module.hh"
#include "TTCN3ModuleInventory.hh"
#include "ComplexType.hh"
#include "Annotation.hh"
/**
* Type that contains information of a field of a TTCN-3 record or union
*
*/
class AttributeType : public SimpleType {
bool isAnyAttr;
UseValue useVal;
Mstring actualPath;
Mstring nameSpace;
bool used; // To know if already in the extended or restricted type
TTCN3Module * origModule;
public:
explicit AttributeType(ComplexType * a_complextype);
AttributeType(const AttributeType & other);
AttributeType & operator=(const AttributeType & rhs);
void setTypeOfField(const Mstring& in);
void setNameOfField(const Mstring& in);
void setOrigModule(TTCN3Module * m) {
origModule = m;
}
const TTCN3Module * getOrigModule() const {
return origModule;
}
void setToAnyAttribute();
void modifyValues();
void setUseVal(UseValue use_value) {
useVal = use_value;
}
void setFieldPath(const Mstring path);
void collectVariants(List<Mstring>& container);
UseValue getUseVal() const {
return useVal;
}
bool getUsed() const {
return used;
}
void setUsed(bool use) {
used = use;
}
const Mstring& getNameSpaceAttribute() const {
return nameSpace;
}
void addNameSpaceAttribute(Mstring namespace_) {
if(nameSpace.empty()){
nameSpace = namespace_;
}else {
nameSpace += " " + namespace_;
}
}
void nameConversion_names(QualifiedNames& used);
void applyUseAttribute();
void applyNamespaceAttribute(VariantMode varLabel);
void applyMinMaxOccursAttribute(unsigned long long min, unsigned long long max);
const Mstring& getPath() const {
return actualPath;
}
bool isAnyAttribute() const {
return isAnyAttr;
}
Mstring getPath() {
return actualPath;
}
void printToFile(FILE* file) {
printToFile(file, 0);
}
void printToFile(FILE* file, unsigned level);
void dump(unsigned int depth) const;
};
inline bool compareAttributeNameSpaces(AttributeType * lhs, AttributeType * rhs) {
if (lhs->isAnyAttribute()) {
return false;
}
if (lhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
return false;
} else if (lhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
return true;
} else if (rhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
return false;
} else {
return lhs->getOrigModule()->getTargetNamespace() <= rhs->getOrigModule()->getTargetNamespace();
}
}
inline bool compareAttributeTypes(AttributeType * lhs, AttributeType * rhs) {
if (lhs->isAnyAttribute()) {
return false;
}
if (lhs->getOrigModule()->getTargetNamespace() == rhs->getOrigModule()->getTargetNamespace()) {
return lhs->getName().originalValueWoPrefix < rhs->getName().originalValueWoPrefix;
} else {
return false;
}
}
#endif /* ATTRIBUTETYPE_HH_ */
|