Skip to content

Commit dc32b24

Browse files
committed
move StringAggregate and co out of STEPaggregate.*
1 parent 57a3d9c commit dc32b24

File tree

5 files changed

+165
-156
lines changed

5 files changed

+165
-156
lines changed

src/clstepcore/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set(LIBSTEPCORE_SRCS
4545
STEPaggrEnum.cc
4646
STEPaggrInt.cc
4747
STEPaggrReal.cc
48+
STEPaggrString.cc
4849
STEPattribute.cc
4950
STEPattributeList.cc
5051
STEPcomplex.cc
@@ -101,6 +102,7 @@ set(SC_CLSTEPCORE_HDRS
101102
STEPaggrEnum.h
102103
STEPaggrInt.h
103104
STEPaggrReal.h
105+
STEPaggrString.h
104106
STEPattribute.h
105107
STEPattributeList.h
106108
STEPcomplex.h

src/clstepcore/STEPaggrString.cc

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#include "STEPaggrString.h"
2+
3+
/** \file STEPaggrString.cc
4+
* implement classes StringAggregate, StringNode
5+
*/
6+
7+
8+
StringAggregate::StringAggregate() {
9+
}
10+
11+
StringAggregate::~StringAggregate() {
12+
}
13+
14+
STEPaggregate & StringAggregate::ShallowCopy( const STEPaggregate & a ) {
15+
Empty();
16+
17+
SingleLinkNode * next = a.GetHead();
18+
SingleLinkNode * copy;
19+
20+
while( next ) {
21+
copy = new StringNode( *( StringNode * )next );
22+
AddNode( copy );
23+
next = next->NextNode();
24+
}
25+
if( head ) {
26+
_null = 0;
27+
} else {
28+
_null = 1;
29+
}
30+
return *this;
31+
32+
}
33+
34+
SingleLinkNode * StringAggregate::NewNode() {
35+
return new StringNode();
36+
}
37+
38+
39+
StringNode::StringNode() {
40+
value = "";
41+
}
42+
43+
StringNode::~StringNode() {
44+
}
45+
46+
StringNode::StringNode( StringNode & sn ) {
47+
value = sn.value.c_str();
48+
}
49+
50+
StringNode::StringNode( const char * sStr ) {
51+
// value is an SDAI_String (the memory is copied)
52+
value = sStr;
53+
}
54+
55+
SingleLinkNode * StringNode::NewNode() {
56+
return new StringNode();
57+
}
58+
59+
/**
60+
* non-whitespace chars following s are considered garbage and is an error.
61+
* a valid value will still be assigned if it exists before the garbage.
62+
*/
63+
Severity StringNode::StrToVal( const char * s, ErrorDescriptor * err ) {
64+
return STEPread( s, err );
65+
}
66+
67+
/**
68+
* this function assumes you will check for garbage following input
69+
*/
70+
Severity StringNode::StrToVal( istream & in, ErrorDescriptor * err ) {
71+
return value.STEPread( in, err );
72+
}
73+
74+
/**
75+
* non-whitespace chars following s are considered garbage and is an error.
76+
* a valid value will still be assigned if it exists before the garbage.
77+
*/
78+
Severity StringNode::STEPread( const char * s, ErrorDescriptor * err ) {
79+
istringstream in( ( char * )s );
80+
81+
value.STEPread( in, err );
82+
CheckRemainingInput( in, err, "string", ",)" );
83+
return err->severity();
84+
}
85+
86+
/**
87+
* this function assumes you will check for garbage following input
88+
*/
89+
Severity StringNode::STEPread( istream & in, ErrorDescriptor * err ) {
90+
return value.STEPread( in, err );
91+
}
92+
93+
const char * StringNode::asStr( std::string & s ) {
94+
value.asStr( s );
95+
return const_cast<char *>( s.c_str() );
96+
}
97+
98+
const char * StringNode::STEPwrite( std::string & s, const char * ) {
99+
value.STEPwrite( s );
100+
return const_cast<char *>( s.c_str() );
101+
}
102+
103+
void StringNode::STEPwrite( ostream & out ) {
104+
value.STEPwrite( out );
105+
}
106+

src/clstepcore/STEPaggrString.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef STEPAGGRSTRING_H
2+
#define STEPAGGRSTRING_H
3+
4+
#include "STEPaggregate.h"
5+
#include <sc_export.h>
6+
7+
/** \file STEPaggrString.h
8+
* classes StringAggregate, StringNode
9+
*/
10+
11+
/**
12+
* * \class StringAggregate
13+
** This class supports LIST OF STRING type
14+
*/
15+
class SC_CORE_EXPORT StringAggregate : public STEPaggregate {
16+
public:
17+
virtual SingleLinkNode * NewNode();
18+
virtual STEPaggregate & ShallowCopy( const STEPaggregate & );
19+
20+
StringAggregate();
21+
virtual ~StringAggregate();
22+
};
23+
typedef StringAggregate * StringAggregateH;
24+
typedef StringAggregate * StringAggregate_ptr;
25+
typedef const StringAggregate * StringAggregate_ptr_c;
26+
typedef StringAggregate_ptr StringAggregate_var;
27+
28+
/**
29+
* * \class StringNode
30+
** This class is for the Nodes of StringAggregates
31+
*/
32+
class SC_CORE_EXPORT StringNode : public STEPnode {
33+
public:
34+
SDAI_String value;
35+
// INPUT
36+
virtual Severity StrToVal( const char * s, ErrorDescriptor * err );
37+
virtual Severity StrToVal( istream & in, ErrorDescriptor * err );
38+
39+
virtual Severity STEPread( const char * s, ErrorDescriptor * err );
40+
virtual Severity STEPread( istream & in, ErrorDescriptor * err );
41+
42+
// OUTPUT
43+
virtual const char * asStr( std::string & s );
44+
virtual const char * STEPwrite( std::string & s, const char * = 0 );
45+
virtual void STEPwrite( ostream & out = cout );
46+
47+
// CONSTRUCTORS
48+
StringNode( StringNode & sn );
49+
StringNode( const char * sStr );
50+
StringNode();
51+
~StringNode();
52+
53+
virtual SingleLinkNode * NewNode();
54+
};
55+
56+
#endif //STEPAGGRSTRING_H

src/clstepcore/STEPaggregate.cc

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -924,109 +924,3 @@ void SelectNode::STEPwrite( ostream & out ) {
924924
out << asStr( s );
925925
}
926926

927-
///////////////////////////////////////////////////////////////////////////////
928-
// StringAggregate
929-
///////////////////////////////////////////////////////////////////////////////
930-
931-
StringAggregate::StringAggregate() {
932-
}
933-
934-
StringAggregate::~StringAggregate() {
935-
}
936-
937-
STEPaggregate & StringAggregate::ShallowCopy( const STEPaggregate & a ) {
938-
Empty();
939-
940-
SingleLinkNode * next = a.GetHead();
941-
SingleLinkNode * copy;
942-
943-
while( next ) {
944-
copy = new StringNode( *( StringNode * )next );
945-
AddNode( copy );
946-
next = next->NextNode();
947-
}
948-
if( head ) {
949-
_null = 0;
950-
} else {
951-
_null = 1;
952-
}
953-
return *this;
954-
955-
}
956-
957-
SingleLinkNode * StringAggregate::NewNode() {
958-
return new StringNode();
959-
}
960-
961-
///////////////////////////////////////////////////////////////////////////////
962-
// StringNode
963-
///////////////////////////////////////////////////////////////////////////////
964-
965-
StringNode::StringNode() {
966-
value = "";
967-
}
968-
969-
StringNode::~StringNode() {
970-
}
971-
972-
StringNode::StringNode( StringNode & sn ) {
973-
value = sn.value.c_str();
974-
}
975-
976-
StringNode::StringNode( const char * sStr ) {
977-
// value is an SDAI_String (the memory is copied)
978-
value = sStr;
979-
}
980-
981-
SingleLinkNode * StringNode::NewNode() {
982-
return new StringNode();
983-
}
984-
985-
/**
986-
* non-whitespace chars following s are considered garbage and is an error.
987-
* a valid value will still be assigned if it exists before the garbage.
988-
*/
989-
Severity StringNode::StrToVal( const char * s, ErrorDescriptor * err ) {
990-
return STEPread( s, err );
991-
}
992-
993-
/**
994-
* this function assumes you will check for garbage following input
995-
*/
996-
Severity StringNode::StrToVal( istream & in, ErrorDescriptor * err ) {
997-
return value.STEPread( in, err );
998-
}
999-
1000-
/**
1001-
* non-whitespace chars following s are considered garbage and is an error.
1002-
* a valid value will still be assigned if it exists before the garbage.
1003-
*/
1004-
Severity StringNode::STEPread( const char * s, ErrorDescriptor * err ) {
1005-
istringstream in( ( char * )s );
1006-
1007-
value.STEPread( in, err );
1008-
CheckRemainingInput( in, err, "string", ",)" );
1009-
return err->severity();
1010-
}
1011-
1012-
/**
1013-
* this function assumes you will check for garbage following input
1014-
*/
1015-
Severity StringNode::STEPread( istream & in, ErrorDescriptor * err ) {
1016-
return value.STEPread( in, err );
1017-
}
1018-
1019-
const char * StringNode::asStr( std::string & s ) {
1020-
value.asStr( s );
1021-
return const_cast<char *>( s.c_str() );
1022-
}
1023-
1024-
const char * StringNode::STEPwrite( std::string & s, const char * ) {
1025-
value.STEPwrite( s );
1026-
return const_cast<char *>( s.c_str() );
1027-
}
1028-
1029-
void StringNode::STEPwrite( ostream & out ) {
1030-
value.STEPwrite( out );
1031-
}
1032-

src/clstepcore/STEPaggregate.h

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,7 @@ typedef SelectAggregate * SelectAggregate_ptr;
149149
typedef const SelectAggregate * SelectAggregate_ptr_c;
150150
typedef SelectAggregate_ptr SelectAggregate_var;
151151

152-
/****************************************************************//**
153-
** \class StringAggregate
154-
** This class supports LIST OF STRING type
155-
******************************************************************/
156-
class SC_CORE_EXPORT StringAggregate : public STEPaggregate {
157-
public:
158-
virtual SingleLinkNode * NewNode();
159-
virtual STEPaggregate & ShallowCopy( const STEPaggregate & );
160-
161-
StringAggregate();
162-
virtual ~StringAggregate();
163-
};
164-
typedef StringAggregate * StringAggregateH;
165-
typedef StringAggregate * StringAggregate_ptr;
166-
typedef const StringAggregate * StringAggregate_ptr_c;
167-
typedef StringAggregate_ptr StringAggregate_var;
168-
169-
152+
#include "STEPaggrString.h"
170153
#include "STEPaggrBinary.h"
171154
#include "STEPaggrEnum.h"
172155
#include "STEPaggrReal.h"
@@ -345,38 +328,6 @@ class SC_CORE_EXPORT SelectNode : public STEPnode {
345328
}
346329
};
347330

348-
/**************************************************************//**
349-
** \class StringNode
350-
** This class is for the Nodes of StringAggregates
351-
******************************************************************/
352-
class SC_CORE_EXPORT StringNode : public STEPnode {
353-
public:
354-
SDAI_String value;
355-
// INPUT
356-
virtual Severity StrToVal( const char * s, ErrorDescriptor * err );
357-
virtual Severity StrToVal( istream & in, ErrorDescriptor * err );
358-
359-
virtual Severity STEPread( const char * s, ErrorDescriptor * err );
360-
virtual Severity STEPread( istream & in, ErrorDescriptor * err );
361-
362-
// OUTPUT
363-
virtual const char * asStr( std::string & s );
364-
virtual const char * STEPwrite( std::string & s, const char * = 0 );
365-
virtual void STEPwrite( ostream & out = cout );
366-
367-
// CONSTRUCTORS
368-
StringNode( StringNode & sn );
369-
StringNode( const char * sStr );
370-
StringNode();
371-
~StringNode();
372-
373-
virtual SingleLinkNode * NewNode();
374-
};
375-
376-
377-
378-
379-
380331
/******************************************************************
381332
** FIXME The following classes are currently stubs
382333
**

0 commit comments

Comments
 (0)