-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathSTEPundefined.cc
More file actions
154 lines (123 loc) · 3.15 KB
/
STEPundefined.cc
File metadata and controls
154 lines (123 loc) · 3.15 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* NIST STEP Core Class Library
* clstepcore/STEPundefined.cc
* April 1997
* KC Morris
* David Sauder
* Development of this software was funded by the United States Government,
* and is not subject to copyright.
*/
#include <stdio.h> // to get the BUFSIZ #define
#include "clstepcore/STEPattribute.h"
#include "clstepcore/STEPundefined.h"
/** \class SCLundefined
** helper functions for reading unknown types
*/
Severity SCLundefined::StrToVal( const char * s, ErrorDescriptor * err ) {
(void) err; //unused
val = s;
return SEVERITY_NULL;
}
Severity SCLundefined::StrToVal( istream & in, ErrorDescriptor * err ) {
return STEPread( in, err );
}
Severity SCLundefined::STEPread( const char * s, ErrorDescriptor * err ) {
istringstream in( ( char * ) s );
return STEPread( in, err );
}
Severity SCLundefined::STEPread( istream & in, ErrorDescriptor * err ) {
char c = '\0';
ostringstream ss;
std::string str;
int terminal = 0;
in >> ws; // skip white space
in >> c;
if( c == '$' ) {
val = "";
CheckRemainingInput( in, err, "aggregate item", ",)" );
} else {
in.putback( c );
}
while( !terminal ) {
in.get( c );
switch( c ) {
case '(':
in.putback( c );
PushPastImbedAggr( in, str, err );
ss << str;
break;
case '\'':
in.putback( c );
PushPastString( in, str, err );
ss << str;
break;
case ',':
terminal = 1; // it's a STEPattribute separator
in.putback( c );
c = '\0';
break;
case ')':
in.putback( c );
terminal = 1; // found a valid delimiter
break;
case '\0':
case EOF:
terminal = 1; // found a valid delimiter
break;
default:
ss.put( c );
break;
}
if( !in.good() ) {
terminal = 1;
c = '\0';
}
}
ss << ends;
val = &( ss.str()[0] );
err->GreaterSeverity( SEVERITY_NULL );
return SEVERITY_NULL;
}
const char * SCLundefined::asStr( std::string & s ) const {
s = val.c_str();
return const_cast<char *>( s.c_str() );
}
const char * SCLundefined::STEPwrite( std::string & s ) {
if( val.empty() ) {
s = "$";
} else {
s = val.c_str();
}
return const_cast<char *>( s.c_str() );
}
void SCLundefined:: STEPwrite( ostream & out ) {
if( val.empty() ) {
out << "$";
} else {
out << val;
}
}
SCLundefined & SCLundefined::operator= ( const SCLundefined & x ) {
std::string tmp;
val = x.asStr( tmp );
return *this;
}
SCLundefined & SCLundefined::operator= ( const char * str ) {
if( !str ) {
val.clear();
} else {
val = str;
}
return *this;
}
SCLundefined::SCLundefined() {
}
SCLundefined::~SCLundefined() {
}
int SCLundefined::set_null() {
val = "";
return 1;
}
bool SCLundefined::is_null() {
return ( val.empty() );
}