add bool strict

This commit is contained in:
Mark Pictor 2011-11-13 19:22:45 -05:00
parent 6871bc4eca
commit de3495d03f
10 changed files with 23 additions and 16 deletions

View file

@ -171,7 +171,7 @@ STEPfile::ReadHeader( istream & in ) {
fileid = HeaderId( keywd );
//read the values from the istream
objsev = obj->STEPread( fileid, 0, ( InstMgr * )0, in );
objsev = obj->STEPread( fileid, 0, ( InstMgr * )0, in, NULL, true, _strict );
if( !cmtStr.empty() ) {
obj->AddP21Comment( cmtStr );
}
@ -1828,7 +1828,7 @@ STEPfile::ReadInstance( istream & in, ostream & out, std::string & cmtStr,
if( c == '(' ) {
// TODO
sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(),
useTechCor );
useTechCor, _strict );
ReadTokenSeparator( in, &cmtStr );
@ -1875,7 +1875,7 @@ STEPfile::ReadInstance( istream & in, ostream & out, std::string & cmtStr,
// (WORKING_SESSION included)
sev = obj->STEPread( fileid, idIncrNum, &instances(), in, currSch.c_str(),
useTechCor );
useTechCor, _strict );
ReadTokenSeparator( in, &cmtStr );

View file

@ -75,6 +75,8 @@ class STEPfile
int _maxErrorCount;
bool _strict; ///< If false, "missing and required" attributes are replaced with a generic value when file is read
protected:
//file type information
@ -138,7 +140,7 @@ class STEPfile
void Renumber ();
//constructors
STEPfile (Registry& r, InstMgr& i, const std::string filename = "");
STEPfile (Registry& r, InstMgr& i, const std::string filename = "", bool strict = true );
virtual ~STEPfile();
protected:

View file

@ -24,11 +24,11 @@ extern void HeaderSchemaInit( Registry & reg );
//constructor & destructor
STEPfile::STEPfile( Registry & r, InstMgr & i, const std::string filename ) :
STEPfile::STEPfile( Registry & r, InstMgr & i, const std::string filename, bool strict ) :
_instances( i ), _reg( r ), _fileIdIncr( 0 ), _headerId( 0 ),
_entsNotCreated( 0 ), _entsInvalid( 0 ), _entsIncomplete( 0 ),
_entsWarning( 0 ), _errorCount( 0 ), _warningCount( 0 ),
_maxErrorCount( 5000 )
_maxErrorCount( 5000 ), _strict(strict)
{
SetFileType( VERSION_CURRENT );
SetFileIdIncrement();

View file

@ -193,7 +193,7 @@ Severity STEPattribute::StrToVal( const char * s, InstMgr * instances, int addFi
** value <= SEVERITY_INPUT_ERROR is fatal read error
******************************************************************/
Severity STEPattribute::STEPread( istream & in, InstMgr * instances, int addFileId,
const char * currSch ) {
const char * currSch, bool strict ) {
// The attribute has been redefined by the attribute pointed
// to by _redefAttr so write the redefined value.

View file

@ -123,7 +123,7 @@ class STEPattribute {
Severity StrToVal(const char *s, InstMgr *instances =0,
int addFileId =0);
Severity STEPread(istream& in = cin, InstMgr *instances =0,
int addFileId =0, const char * =NULL);
int addFileId =0, const char * =NULL, bool strict = true);
const char * asStr(std::string&, const char * =0) const;
// return the attr value as a string

View file

@ -259,7 +259,7 @@ void STEPcomplex::AppendEntity( STEPcomplex * stepc ) {
// READ
Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgr * instance_set,
istream & in, const char * currSch, bool useTechCor ) {
istream & in, const char * currSch, bool /*useTechCor*/, bool /*strict*/ ) {
char c;
std::string typeNm;
STEPcomplex * stepc = 0;

View file

@ -34,7 +34,7 @@ class STEPcomplex : public SDAI_Application_instance {
virtual Severity STEPread(int id, int addFileId,
class InstMgr * instance_set,
istream& in =cin, const char *currSch =NULL,
bool useTechCor = true );
bool useTechCor = true, bool strict = true );
virtual void STEPread_error(char c, int index, istream& in);

View file

@ -426,7 +426,7 @@ void SDAI_Application_instance::STEPread_error( char c, int i, istream & in ) {
******************************************************************/
Severity SDAI_Application_instance::STEPread( int id, int idIncr,
InstMgr * instance_set, istream & in,
const char * currSch, bool useTechCor ) {
const char * currSch, bool useTechCor, bool strict ) {
STEPfile_id = id;
char c = '\0';
char errStr[BUFSIZ];
@ -489,7 +489,7 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr,
// increment counter to read following attr since these attrs
// aren't written or read => there won't be a delimiter either
} else {
attributes[i].STEPread( in, instance_set, idIncr, currSch );
attributes[i].STEPread( in, instance_set, idIncr, currSch, strict );
in >> c; // read the , or ) following the attr read
severe = attributes[i].Error().severity();

View file

@ -82,7 +82,7 @@ class SDAI_Application_instance : public SDAI_DAObject_SDAI
virtual Severity STEPread(int id, int addFileId,
class InstMgr * instance_set,
istream& in =cin, const char * currSch = NULL,
bool useTechCor = true );
bool useTechCor = true, bool strict = true );
virtual void STEPread_error(char c, int index, istream& in);
// WRITE

View file

@ -83,23 +83,28 @@ void checkSchemaName( Registry & reg, STEPfile & sf, bool ignoreErr ) {
void printUse(const char * exe) {
std::cout << "p21read - read a STEP Part 21 exchange file using SCL, and write the data to another file." << std::endl;
std::cout << "Syntax: " << exe << " [-i] infile [outfile]" << std::endl;
std::cout << "Syntax: " << exe << " [-i] [-s] infile [outfile]" << std::endl;
std::cout << "Use '-i' to ignore a schema name mismatch." << std::endl;
std::cout << "Use '-s' for strict interpretation (attributes that are \"missing and required\" will cause errors)." << std::endl;
std::cout << "Use '--' as the last argument if a file name starts with a dash." << std::endl;
exit( 1 );
}
int main( int argc, char * argv[] ) {
bool ignoreErr = false;
bool strict = false;
char c;
if( argc > 4 || argc < 2 ) {
printUse(argv[0]);
}
while( ( c = getopt( argc, argv, "i" ) ) != -1 ) {
while( ( c = getopt( argc, argv, "is" ) ) != -1 ) {
switch( c ) {
case 'i':
ignoreErr = true;
break;
case 's':
strict = true;
break;
case '?':
default:
printUse(argv[0]);
@ -119,7 +124,7 @@ int main( int argc, char * argv[] ) {
Registry registry( SchemaInit );
InstMgr instance_list;
STEPfile sfile( registry, instance_list );
STEPfile sfile( registry, instance_list, "", strict );
char * flnm;
cout << "\nEXAMPLE : load file ..." << endl;