forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTEPaggrString.cc
More file actions
107 lines (83 loc) · 2.35 KB
/
STEPaggrString.cc
File metadata and controls
107 lines (83 loc) · 2.35 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
#include "clstepcore/STEPaggrString.h"
#include <sstream>
/** \file STEPaggrString.cc
* implement classes StringAggregate, StringNode
*/
StringAggregate::StringAggregate() {
}
StringAggregate::~StringAggregate() {
}
STEPaggregate & StringAggregate::ShallowCopy( const STEPaggregate & a ) {
Empty();
SingleLinkNode * next = a.GetHead();
SingleLinkNode * copy;
while( next ) {
copy = new StringNode( *( StringNode * )next );
AddNode( copy );
next = next->NextNode();
}
if( head ) {
_null = 0;
} else {
_null = 1;
}
return *this;
}
SingleLinkNode * StringAggregate::NewNode() {
return new StringNode();
}
StringNode::StringNode() {
value = "";
}
StringNode::~StringNode() {
}
StringNode::StringNode( StringNode & sn ) {
value = sn.value.c_str();
}
StringNode::StringNode( const char * sStr ) {
// value is an SDAI_String (the memory is copied)
value = sStr;
}
SingleLinkNode * StringNode::NewNode() {
return new StringNode();
}
/**
* non-whitespace chars following s are considered garbage and is an error.
* a valid value will still be assigned if it exists before the garbage.
*/
Severity StringNode::StrToVal( const char * s, ErrorDescriptor * err ) {
return STEPread( s, err );
}
/**
* this function assumes you will check for garbage following input
*/
Severity StringNode::StrToVal( istream & in, ErrorDescriptor * err ) {
return value.STEPread( in, err );
}
/**
* non-whitespace chars following s are considered garbage and is an error.
* a valid value will still be assigned if it exists before the garbage.
*/
Severity StringNode::STEPread( const char * s, ErrorDescriptor * err ) {
istringstream in( ( char * )s );
value.STEPread( in, err );
CheckRemainingInput( in, err, "string", ",)" );
return err->severity();
}
/**
* this function assumes you will check for garbage following input
*/
Severity StringNode::STEPread( istream & in, ErrorDescriptor * err ) {
return value.STEPread( in, err );
}
const char * StringNode::asStr( std::string & s ) {
value.asStr( s );
return const_cast<char *>( s.c_str() );
}
const char * StringNode::STEPwrite( std::string & s, const char * ) {
value.STEPwrite( s );
return const_cast<char *>( s.c_str() );
}
void StringNode::STEPwrite( ostream & out ) {
value.STEPwrite( out );
}