Skip to content

Commit 0173945

Browse files
committed
add bool verbose to STEPfile class
Defaults to false, in which case nothing is printed unless there is an error
1 parent 346ced2 commit 0173945

File tree

3 files changed

+43
-32
lines changed

3 files changed

+43
-32
lines changed

src/cleditor/STEPfile.cc

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,24 +1680,28 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
16801680
return SEVERITY_INPUT_ERROR;
16811681
}
16821682

1683-
cout << "Reading Data from " << ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) << "...\n";
1683+
if( _verbose || _errorCount || _warningCount ) {
1684+
cout << "Reading Data from " << ( ( FileName().compare( "-" ) == 0 ) ? "standard input" : FileName().c_str() ) << "...\n";
1685+
}
16841686

16851687
// Read header
16861688
rval = ReadHeader( *in );
1687-
cout << "\nHEADER read:";
1688-
if( rval < SEVERITY_WARNING ) {
1689-
sprintf( errbuf,
1690-
"Error: non-recoverable error in reading header section. "
1691-
"There were %d errors encountered. Rest of file is ignored.\n",
1692-
_errorCount );
1693-
_error.AppendToUserMsg( errbuf );
1694-
return rval;
1695-
} else if( rval != SEVERITY_NULL ) {
1696-
sprintf( errbuf, " %d ERRORS\t %d WARNINGS\n\n",
1697-
_errorCount, _warningCount );
1698-
cout << errbuf;
1699-
} else {
1700-
cout << endl;
1689+
if( _verbose || _errorCount || _warningCount ) {
1690+
cout << "\nHEADER read:";
1691+
if( rval < SEVERITY_WARNING ) {
1692+
sprintf( errbuf,
1693+
"Error: non-recoverable error in reading header section. "
1694+
"There were %d errors encountered. Rest of file is ignored.\n",
1695+
_errorCount );
1696+
_error.AppendToUserMsg( errbuf );
1697+
return rval;
1698+
} else if( rval != SEVERITY_NULL ) {
1699+
sprintf( errbuf, " %d ERRORS\t %d WARNINGS\n\n",
1700+
_errorCount, _warningCount );
1701+
cout << errbuf;
1702+
} else {
1703+
cout << endl;
1704+
}
17011705
}
17021706

17031707
if( !FindDataSection( *in ) ) {
@@ -1709,12 +1713,14 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
17091713
_errorCount = 0;
17101714
total_insts = ReadData1( *in );
17111715

1712-
cout << "\nFIRST PASS complete: " << total_insts
1716+
if( _verbose || _errorCount || _warningCount ) {
1717+
cout << "\nFIRST PASS complete: " << total_insts
17131718
<< " instances created.\n";
1714-
sprintf( errbuf,
1715-
" %d ERRORS\t %d WARNINGS\n\n",
1716-
_errorCount, _warningCount );
1717-
cout << errbuf;
1719+
sprintf( errbuf,
1720+
" %d ERRORS\t %d WARNINGS\n\n",
1721+
_errorCount, _warningCount );
1722+
cout << errbuf;
1723+
}
17181724

17191725
// PASS 2
17201726
// This would be nicer if you didn't actually have to close the
@@ -1762,13 +1768,15 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
17621768
return _error.GreaterSeverity( SEVERITY_WARNING );
17631769
}
17641770

1765-
cout << "\nSECOND PASS complete: " << valid_insts
1771+
if( _verbose || _errorCount || _warningCount ) {
1772+
cout << "\nSECOND PASS complete: " << valid_insts
17661773
<< " instances valid.\n";
1767-
sprintf( errbuf,
1768-
" %d ERRORS\t %d WARNINGS\n\n",
1769-
_errorCount, _warningCount );
1770-
_error.AppendToUserMsg( errbuf );
1771-
cout << errbuf;
1774+
sprintf( errbuf,
1775+
" %d ERRORS\t %d WARNINGS\n\n",
1776+
_errorCount, _warningCount );
1777+
_error.AppendToUserMsg( errbuf );
1778+
cout << errbuf;
1779+
}
17721780

17731781

17741782
//check for "ENDSTEP;" || "END-ISO-10303-21;"
@@ -1796,7 +1804,9 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
17961804
return _error.GreaterSeverity( SEVERITY_WARNING );
17971805
}
17981806
CloseInputFile( in2 );
1799-
cout << "Finished reading file.\n\n";
1807+
if( _verbose || _errorCount || _warningCount ) {
1808+
cout << "Finished reading file.\n\n";
1809+
}
18001810
return SEVERITY_NULL;
18011811
}
18021812

src/cleditor/STEPfile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class SCL_EDITOR_EXPORT STEPfile {
8686
int _maxErrorCount;
8787

8888
bool _strict; ///< If false, "missing and required" attributes are replaced with a generic value when file is read
89+
bool _verbose; ///< Defaults to false; if true, info is always printed to stdout.
8990

9091
protected:
9192

@@ -168,7 +169,7 @@ class SCL_EDITOR_EXPORT STEPfile {
168169
void Renumber();
169170

170171
//constructors
171-
STEPfile( Registry & r, InstMgr & i, const std::string filename = "", bool strict = true );
172+
STEPfile( Registry & r, InstMgr & i, const std::string filename = "", bool strict = true, bool verbose = false );
172173
virtual ~STEPfile();
173174

174175
protected:

src/cleditor/STEPfile.inline.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ extern void HeaderSchemaInit( Registry & reg );
2525

2626
//constructor & destructor
2727

28-
STEPfile::STEPfile( Registry & r, InstMgr & i, const std::string filename, bool strict ) :
28+
STEPfile::STEPfile( Registry & r, InstMgr & i, const std::string filename, bool strict, bool verbose ) :
2929
_instances( i ), _reg( r ), _fileIdIncr( 0 ), _headerId( 0 ),
3030
_entsNotCreated( 0 ), _entsInvalid( 0 ), _entsIncomplete( 0 ),
3131
_entsWarning( 0 ), _errorCount( 0 ), _warningCount( 0 ),
32-
_maxErrorCount( 5000 ), _strict( strict ),_iFileSize( 0 ),
33-
_iFileCurrentPosition( 0 ), _oFileInstsWritten( 0 ),
34-
_iFileStage1Done( false ) {
32+
_maxErrorCount( 5000 ), _strict( strict ), _verbose( verbose ),
33+
_iFileSize( 0 ), _iFileCurrentPosition( 0 ),
34+
_oFileInstsWritten( 0 ), _iFileStage1Done( false ) {
3535
SetFileType( VERSION_CURRENT );
3636
SetFileIdIncrement();
3737
_currentDir = new DirObj( "" );

0 commit comments

Comments
 (0)