@@ -18,39 +18,11 @@ SDAI_String & SDAI_String::operator= ( const char * s ) {
1818}
1919
2020void SDAI_String::STEPwrite ( ostream & out ) const {
21- const char * str = 0 ;
22- if ( empty () ) {
23- out << " \'\' " ;
24- } else {
25- out << " \' " ;
26- str = c_str ();
27- while ( *str ) {
28- if ( *str == STRING_DELIM ) {
29- out << STRING_DELIM;
30- }
31- out << *str;
32- str++;
33- }
34- out << " \' " ;
35- }
21+ out << c_str ();
3622}
3723
3824void SDAI_String::STEPwrite ( std::string & s ) const {
39- const char * str = 0 ;
40- if ( empty () ) {
41- s = " \'\' " ;
42- } else {
43- s = " \' " ;
44- str = c_str ();
45- while ( *str ) {
46- if ( *str == STRING_DELIM ) {
47- s += STRING_DELIM;
48- }
49- s += *str;
50- str++;
51- }
52- s += STRING_DELIM;
53- }
25+ s += c_str ();
5426}
5527
5628Severity SDAI_String::StrToVal ( const char * s ) {
@@ -67,54 +39,28 @@ Severity SDAI_String::StrToVal( const char * s ) {
6739 * starting with a single quote
6840 */
6941Severity SDAI_String::STEPread ( istream & in, ErrorDescriptor * err ) {
70- int foundEndQuote = 0 ; // need so this string is not ok: 'hi''
7142 clear (); // clear the old string
72- char c;
73- in >> ws; // skip white space
74- in >> c;
75-
7643 // remember the current format state to restore the previous settings
7744 ios_base::fmtflags flags = in.flags ();
7845 in.unsetf ( ios::skipws );
7946
80- if ( c == STRING_DELIM ) {
81- while ( ( c != ' \0 ' ) && in.good () && in.get ( c ) ) {
82- if ( c == STRING_DELIM ) {
83- in.get ( c );
84- if ( ! in.good () ) {
85- // it is the final quote and no extra char was read
86- foundEndQuote = 1 ;
87- c = ' \0 ' ;
88- continue ;
89- } else if ( !( c == STRING_DELIM ) ) {
90- // it is the final quote and extra char was read
91- in.putback ( c ); // put back non-quote extra char
92- foundEndQuote = 1 ;
93- c = ' \0 ' ;
94- continue ;
95- }
96- // else { ; } // do nothing it is an embedded quote
97- }
98- operator += ( c );
99- }
100-
101- if ( foundEndQuote ) {
102- return SEVERITY_NULL;
103- } else {
104- // non-recoverable error
105- err->AppendToDetailMsg ( " Missing closing quote on string value.\n " );
106- err->AppendToUserMsg ( " Missing closing quote on string value.\n " );
107- err->GreaterSeverity ( SEVERITY_INPUT_ERROR );
108- return SEVERITY_INPUT_ERROR;
109- }
110- }
111- // otherwise there was not a quote
112- in.putback ( c );
113- in.flags ( flags ); // set the format state back to previous settings
47+ // extract the string from the inputstream
48+ std::string s = GetLiteralStr ( in, err );
49+ append ( s );
11450
115- clear ();
51+ // retrieve current severity
52+ Severity sev = err -> severity ();
11653
117- return err -> GreaterSeverity ( SEVERITY_INCOMPLETE );
54+ if ( s.empty () ) {
55+ // no string was read
56+ in.flags ( flags ); // set the format state back to previous settings
57+ err -> GreaterSeverity ( SEVERITY_INCOMPLETE );
58+ sev = SEVERITY_INCOMPLETE;
59+ } else if ( sev != SEVERITY_INPUT_ERROR ) {
60+ // read valid string
61+ sev = SEVERITY_NULL;
62+ }
63+ return sev;
11864}
11965
12066Severity SDAI_String::STEPread ( const char * s, ErrorDescriptor * err ) {
0 commit comments