@@ -30,13 +30,12 @@ SDAI_Application_instance NilSTEPentity;
3030**/
3131
3232SDAI_Application_instance::SDAI_Application_instance ()
33- : _cur( 0 ), STEPfile_id( 0 ), p21Comment( 0 ), headMiEntity( 0 ), nextMiEntity( 0 ),
33+ : _cur( 0 ), STEPfile_id( 0 ), headMiEntity( 0 ), nextMiEntity( 0 ),
3434 _complex( 0 ) {
3535}
3636
3737SDAI_Application_instance::SDAI_Application_instance ( int fileid, int complex )
38- : _cur( 0 ), STEPfile_id( fileid ), p21Comment( 0 ),
39- headMiEntity( 0 ), nextMiEntity( 0 ), _complex( complex ) {
38+ : _cur( 0 ), STEPfile_id( fileid ), headMiEntity( 0 ), nextMiEntity( 0 ), _complex( complex ) {
4039}
4140
4241SDAI_Application_instance::~SDAI_Application_instance () {
@@ -51,8 +50,6 @@ SDAI_Application_instance::~SDAI_Application_instance() {
5150 delete nextMiEntity;
5251 }
5352
54- delete p21Comment;
55-
5653 /*
5754 // this is not necessary since each will call delete on its
5855 // own nextMiEntity - DAS
@@ -88,34 +85,20 @@ SDAI_Application_instance * SDAI_Application_instance::Replicate() {
8885 }
8986}
9087
91- void SDAI_Application_instance::AddP21Comment ( const char * s, int replace ) {
88+ void SDAI_Application_instance::AddP21Comment ( const char * s, bool replace ) {
9289 if ( replace ) {
93- delete p21Comment;
94- p21Comment = 0 ;
90+ p21Comment.clear ();
9591 }
96- if ( s ) {
97- if ( !p21Comment ) {
98- p21Comment = new std::string ( " " );
99- } else {
100- p21Comment->clear ();
101- }
102- p21Comment->append ( s );
92+ if (s) {
93+ p21Comment += s;
10394 }
10495}
10596
106- void SDAI_Application_instance::AddP21Comment ( std::string & s, int replace ) {
97+ void SDAI_Application_instance::AddP21Comment ( const std::string & s, bool replace ) {
10798 if ( replace ) {
108- delete p21Comment;
109- p21Comment = 0 ;
110- }
111- if ( !s.empty () ) {
112- if ( !p21Comment ) {
113- p21Comment = new std::string ( " " );
114- } else {
115- p21Comment->clear ();
116- }
117- p21Comment->append ( const_cast <char *>( s.c_str () ) );
99+ p21Comment.clear ();
118100 }
101+ p21Comment += s;
119102}
120103
121104void SDAI_Application_instance::STEPwrite_reference ( ostream & out ) {
@@ -324,8 +307,8 @@ void SDAI_Application_instance::beginSTEPwrite( ostream & out ) {
324307void SDAI_Application_instance::STEPwrite ( ostream & out, const char * currSch,
325308 int writeComments ) {
326309 std::string tmp;
327- if ( writeComments && p21Comment && !p21Comment-> empty () ) {
328- out << p21Comment-> c_str () ;
310+ if ( writeComments && !p21Comment. empty () ) {
311+ out << p21Comment;
329312 }
330313 out << " #" << STEPfile_id << " =" << StrToUpper ( EntityName ( currSch ), tmp )
331314 << " (" ;
@@ -392,8 +375,8 @@ void SDAI_Application_instance::WriteValuePairs( ostream & out,
392375// out << eDesc->QualifiedName(s) << endl;
393376
394377 std::string tmp, tmp2;
395- if ( writeComments && p21Comment && !p21Comment-> empty () ) {
396- out << p21Comment-> c_str () ;
378+ if ( writeComments && !p21Comment. empty () ) {
379+ out << p21Comment;
397380 }
398381 if ( mixedCase ) {
399382 out << " #" << STEPfile_id << " "
0 commit comments