forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattrDescriptor.cc
More file actions
138 lines (118 loc) · 3.16 KB
/
attrDescriptor.cc
File metadata and controls
138 lines (118 loc) · 3.16 KB
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
#include "clstepcore/attrDescriptor.h"
AttrDescriptor::AttrDescriptor( const char * name, const TypeDescriptor * domainType,
Logical optional, Logical unique, AttrType_Enum at,
const EntityDescriptor & owner )
: _name( name ), _domainType( domainType ), _optional( optional ),
_unique( unique ), _attrType( at ), _owner( ( EntityDescriptor & )owner ) {
}
AttrDescriptor::~AttrDescriptor() {
}
Logical AttrDescriptor::Explicit() const {
if( _attrType == AttrType_Explicit ) {
return LTrue;
}
return LFalse;
}
Logical AttrDescriptor::Inverse() const {
if( _attrType == AttrType_Inverse ) {
return LTrue;
}
return LFalse;
}
Logical AttrDescriptor::Redefining() const {
if( _attrType == AttrType_Redefining ) {
return LTrue;
}
return LFalse;
}
Logical AttrDescriptor::Deriving() const {
if( _attrType == AttrType_Deriving ) {
return LTrue;
}
return LFalse;
}
const char * AttrDescriptor::AttrExprDefStr( std::string & s ) const {
std::string buf;
s = Name();
s.append( " : " );
if( _optional.asInt() == LTrue ) {
s.append( "OPTIONAL " );
}
if( DomainType() ) {
DomainType()->AttrTypeName( buf );
s.append( buf );
}
return const_cast<char *>( s.c_str() );
}
PrimitiveType AttrDescriptor::BaseType() const {
if( _domainType ) {
return _domainType->BaseType();
}
return UNKNOWN_TYPE;
}
int AttrDescriptor::IsAggrType() const {
return ReferentType()->IsAggrType();
}
PrimitiveType AttrDescriptor::AggrElemType() const {
if( IsAggrType() ) {
return ReferentType()->AggrElemType();
}
return UNKNOWN_TYPE;
}
const TypeDescriptor * AttrDescriptor::AggrElemTypeDescriptor() const {
if( IsAggrType() ) {
return ReferentType()->AggrElemTypeDescriptor();
}
return 0;
}
const TypeDescriptor * AttrDescriptor::NonRefTypeDescriptor() const {
if( _domainType ) {
return _domainType->NonRefTypeDescriptor();
}
return 0;
}
PrimitiveType
AttrDescriptor::NonRefType() const {
if( _domainType ) {
return _domainType->NonRefType();
}
return UNKNOWN_TYPE;
}
PrimitiveType
AttrDescriptor::Type() const {
if( _domainType ) {
return _domainType->Type();
}
return UNKNOWN_TYPE;
}
/**
* right side of attr def
* NOTE this returns a \'const char * \' instead of an std::string
*/
const std::string AttrDescriptor::TypeName() const {
std::string buf;
if( _domainType ) {
_domainType->AttrTypeName( buf );
}
return buf;
}
/// an expanded right side of attr def
const char *
AttrDescriptor::ExpandedTypeName( std::string & s ) const {
s.clear();
if( Derived() == LTrue ) {
s = "DERIVE ";
}
if( _domainType ) {
std::string tmp;
return const_cast<char *>( ( s.append( _domainType->TypeString( tmp ) ).c_str() ) );
} else {
return 0;
}
}
const char * AttrDescriptor::GenerateExpress( std::string & buf ) const {
std::string sstr;
buf = AttrExprDefStr( sstr );
buf.append( ";\n" );
return const_cast<char *>( buf.c_str() );
}