forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenumTypeDescriptor.cc
More file actions
77 lines (69 loc) · 2.24 KB
/
enumTypeDescriptor.cc
File metadata and controls
77 lines (69 loc) · 2.24 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
#include "clstepcore/enumTypeDescriptor.h"
/*
* why have EnumTypeDescriptor + EnumerationTypeDescriptor ???
* this was in ExpDict.cc before splitting it up
*/
#ifdef NOT_YET
EnumerationTypeDescriptor::EnumerationTypeDescriptor( ) {
_elements = new StringAggregate;
}
#endif
EnumTypeDescriptor::EnumTypeDescriptor( const char * nm, PrimitiveType ft,
Schema * origSchema,
const char * d, EnumCreator f )
: TypeDescriptor( nm, ft, origSchema, d ), CreateNewEnum( f ) {
}
SDAI_Enum * EnumTypeDescriptor::CreateEnum() {
if( CreateNewEnum ) {
return CreateNewEnum();
} else {
return 0;
}
}
const char * EnumTypeDescriptor::GenerateExpress( std::string & buf ) const {
char tmp[BUFSIZ+1];
buf = "TYPE ";
buf.append( StrToLower( Name(), tmp ) );
buf.append( " = ENUMERATION OF \n (" );
const char * desc = Description();
const char * ptr = &( desc[16] );
while( *ptr != '\0' ) {
if( *ptr == ',' ) {
buf.append( ",\n " );
} else if( isupper( *ptr ) ) {
buf += ( char )tolower( *ptr );
} else {
buf += *ptr;
}
ptr++;
}
buf.append( ";\n" );
///////////////
// count is # of WHERE rules
if( _where_rules != 0 ) {
int all_comments = 1;
int count = _where_rules->Count();
for( int i = 0; i < count; i++ ) { // print out each UNIQUE rule
if( !( *( _where_rules ) )[i]->_label.size() ) {
all_comments = 0;
}
}
if( all_comments ) {
buf.append( " (* WHERE *)\n" );
} else {
buf.append( " WHERE\n" );
}
for( int i = 0; i < count; i++ ) { // print out each WHERE rule
if( !( *( _where_rules ) )[i]->_comment.empty() ) {
buf.append( " " );
buf.append( ( *( _where_rules ) )[i]->comment_() );
}
if( ( *( _where_rules ) )[i]->_label.size() ) {
buf.append( " " );
buf.append( ( *( _where_rules ) )[i]->label_() );
}
}
}
buf.append( "END_TYPE;\n" );
return const_cast<char *>( buf.c_str() );
}