This commit is contained in:
Mark Pictor
2011-11-13 21:01:33 -05:00
parent b277759f58
commit c4971681e5
4 changed files with 95 additions and 92 deletions
+3 -3
View File
@@ -1857,7 +1857,7 @@ STEPfile::ReadInstance( istream & in, ostream & out, std::string & cmtStr,
if( !in.good() ) {
out << "ERROR: instance #" << fileid
<< " Unexpected file problem in "
<< "STEPfile::CreateInstance.\n";
<< "STEPfile::ReadInstance." << endl;;
}
ReadTokenSeparator( in, &cmtStr );
@@ -1865,8 +1865,8 @@ STEPfile::ReadInstance( istream & in, ostream & out, std::string & cmtStr,
if( userDefined ) {
SkipInstance( in, tmpbuf );
out << "WARNING: #" << fileid <<
". Ignoring User defined entity.\n\tdata lost: !"
<< objnm << tmpbuf << "\n";
". Ignoring User defined entity."<< endl << " data lost: !"
<< objnm << tmpbuf << endl;
++_warningCount;
return ENTITY_NULL;
}
+23 -23
View File
@@ -1,5 +1,5 @@
#ifndef _STEPFILE_H
#define _STEPFILE_H
#define _STEPFILE_H
/*
* NIST STEP Core Class Library
@@ -27,11 +27,11 @@
#define READ_INCOMPLETE 20
enum FileTypeCode {
TYPE_UNKNOWN = -2,
VERSION_OLD = -1,
VERSION_UNKNOWN = 0,
VERSION_CURRENT = 1,
WORKING_SESSION = 2,
TYPE_UNKNOWN = -2,
VERSION_OLD = -1,
VERSION_UNKNOWN = 0,
VERSION_CURRENT = 1,
WORKING_SESSION = 2,
OLD_WORKING_SESSION = 3
};
@@ -91,9 +91,9 @@ class STEPfile
InstMgr* HeaderInstances() { return _headerInstances; }
const Registry *HeaderRegistry() { return _headerRegistry; }
// to create header instances
SDAI_Application_instance* HeaderDefaultFileName();
SDAI_Application_instance* HeaderDefaultFileDescription();
SDAI_Application_instance* HeaderDefaultFileSchema();
SDAI_Application_instance* HeaderDefaultFileName();
SDAI_Application_instance* HeaderDefaultFileDescription();
SDAI_Application_instance* HeaderDefaultFileSchema();
//file information
const std::string FileName() const { return _fileName; }
@@ -101,14 +101,14 @@ class STEPfile
const std::string TruncFileName (const std::string name) const;
//error information
ErrorDescriptor& Error() /* const */ { return _error; }
ErrorDescriptor& Error() /* const */ { return _error; }
int ErrorCount() const { return _errorCount; }
int WarningCount() const { return _warningCount; }
Severity AppendEntityErrorMsg (ErrorDescriptor *e);
Severity AppendEntityErrorMsg (ErrorDescriptor *e);
//version information
FileTypeCode FileType() const { return _fileType; }
void FileType (FileTypeCode ft) { _fileType = ft; }
void FileType (FileTypeCode ft) { _fileType = ft; }
int SetFileType (FileTypeCode ft = VERSION_CURRENT);
//Reading and Writing
@@ -121,17 +121,17 @@ class STEPfile
Severity AppendFile (istream* in, bool useTechCor = true ) ;
Severity WriteExchangeFile (ostream& out, int validate =1,
int clearError = 1, int writeComments = 1);
int clearError = 1, int writeComments = 1);
Severity WriteExchangeFile (const std::string filename = "", int validate =1,
int clearError = 1, int writeComments = 1);
int clearError = 1, int writeComments = 1);
Severity WriteValuePairsFile(ostream& out, int validate =1,
int clearError =1,
int writeComments = 1, int mixedCase = 1);
int clearError =1,
int writeComments = 1, int mixedCase = 1);
Severity WriteWorkingFile (ostream& out, int clearError = 1,
int writeComments = 1);
int writeComments = 1);
Severity WriteWorkingFile (const std::string filename = "", int clearError = 1,
int writeComments = 1);
int writeComments = 1);
stateEnum EntityWfState(char c);
@@ -166,13 +166,13 @@ class STEPfile
void ReadRestOfFile(istream& in);
// create instance - used by ReadData1()
// create instance - used by ReadData1()
SDAI_Application_instance * CreateInstance(istream& in, ostream& out);
// create complex instance - used by CreateInstance()
// create complex instance - used by CreateInstance()
SDAI_Application_instance * CreateSubSuperInstance(istream& in, int fileid,
ErrorDescriptor &);
ErrorDescriptor &);
// read the instance - used by ReadData2()
// read the instance - used by ReadData2()
SDAI_Application_instance * ReadInstance(istream& in, ostream& out,
std::string &cmtStr, bool useTechCor = true );
@@ -200,7 +200,7 @@ class STEPfile
void WriteData (ostream& out, int writeComments = 1);
void WriteValuePairsData(ostream& out, int writeComments = 1,
int mixedCase = 1);
int mixedCase = 1);
int IncrementFileId (int fileid);
int FileIdIncr() { return _fileIdIncr; }
+20 -20
View File
@@ -364,25 +364,25 @@ Severity RealValidLevel( const char * attrValue, ErrorDescriptor * err,
return err->severity();
}
///////////////////////////////////////////////////////////////////////////////
// ReadNumber - read as a real number
// * This function reads a number if possible
// * If a number is read it is assigned to val and 1 (true) is returned.
// * If a number is not read because of an error then val is left unchanged
// and 0 (false) is returned.
// * If there is an error then the ErrorDescriptor err is set accordingly with
// a severity level and error message (no error MESSAGE is set for severity
// incomplete).
// * tokenList contains characters that terminate reading the value.
// * If tokenList is not zero then the istream will be read until a character
// is found matching a character in tokenlist. All values read up to the
// terminating character (delimiter) must be valid or err will be set with an
// appropriate error message. A valid value may still have been assigned
// but it may be followed by garbage thus an error will result. White
// space between the value and the terminating character is not considered
// to be invalid. If tokenList is null then the value must not be followed
// by any characters other than white space (i.e. EOF must happen)
///////////////////////////////////////////////////////////////////////////////
/**
* ReadNumber - read as a real number
* * This function reads a number if possible
* * If a number is read it is assigned to val and 1 (true) is returned.
* * If a number is not read because of an error then val is left unchanged
* and 0 (false) is returned.
* * If there is an error then the ErrorDescriptor err is set accordingly with
* a severity level and error message (no error MESSAGE is set for severity
* incomplete).
* * tokenList contains characters that terminate reading the value.
* * If tokenList is not zero then the istream will be read until a character
* is found matching a character in tokenlist. All values read up to the
* terminating character (delimiter) must be valid or err will be set with an
* appropriate error message. A valid value may still have been assigned
* but it may be followed by garbage thus an error will result. White
* space between the value and the terminating character is not considered
* to be invalid. If tokenList is null then the value must not be followed
* by any characters other than white space (i.e. EOF must happen)
*/
int ReadNumber( SDAI_Real &val, istream & in, ErrorDescriptor * err,
const char * tokenList ) {
SDAI_Real d = 0;
@@ -863,7 +863,7 @@ const char * ReadComment( istream & in, std::string & s ) {
<< "Will try to recover...\n";
std::string tmp;
SkipInstance( in, tmp );
return const_cast<char *>( s.c_str() );
return s.c_str();
}
// leave slash read from stream... assume caller already knew there was
// a slash, leave it off stream so they don't think this funct needs
+49 -46
View File
@@ -97,13 +97,10 @@ const char * StrToConstant( const char * word, std::string & s ) {
return const_cast<char *>( s.c_str() );
}
/******************************************************************
** Procedure: PrettyName (char * oldname)
** Parameters: oldname
** Returns: a new capitalized name
** Description: creates a new name with first character's in caps
** Side Effects: PrettyNewName allocates memory for the new name
PrettyTmpName returns new name in a static buffer
/**************************************************************//**
** \fn PrettyTmpName (char * oldname)
** \returns a new capitalized name in a static buffer
** Capitalizes first char of word, rest is lowercase. Removes '_'.
** Status: OK 7-Oct-1992 kcm
******************************************************************/
const char * PrettyTmpName( const char * oldname ) {
@@ -125,15 +122,21 @@ const char * PrettyTmpName( const char * oldname ) {
return newname;
}
/**************************************************************//**
** \fn PrettyNewName (char * oldname)
** \returns a new capitalized name
** Capitalizes first char of word, rest is lowercase. Removes '_'.
** Side Effects: allocates memory for the new name
** Status: OK 7-Oct-1992 kcm
******************************************************************/
char * PrettyNewName( const char * oldname ) {
char * name = new char [strlen( oldname ) + 1];
strcpy( name, PrettyTmpName( oldname ) );
return name;
}
/*
* Extract the string conform to P21 from the istream
/**
* Extract the string conforming to P21 from the istream
*/
std::string ToExpressStr( istream &in, ErrorDescriptor *err ) {
char c;
@@ -178,43 +181,43 @@ std::string ToExpressStr( istream &in, ErrorDescriptor *err ) {
return s;
}
// This function is used to check an input stream following a read. It writes
// error messages in the 'ErrorDescriptor &err' argument as appropriate.
// 'const char *tokenList' argument contains a string made up of delimiters
// that are used to move the file pointer in the input stream to the end of
// the value you are reading (i.e. the ending marked by the presence of the
// delimiter). The file pointer is moved just prior to the delimiter. If the
// tokenList argument is a null pointer then this function expects to find EOF.
//
// If input is being read from a stream then a tokenList should be provided so
// this function can push the file pointer up to but not past the delimiter
// (i.e. not removing the delimiter from the input stream). If you have a
// string containing a single value and you expect the whole string to contain
// a valid value, you can change the string to an istrstream, read the value
// then send the istrstream to this function with tokenList set to null
// and this function will set an error for you if any input remains following
// the value.
/**
*** This function is used to check an input stream following a read. It writes
*** error messages in the 'ErrorDescriptor &err' argument as appropriate.
*** 'const char *tokenList' argument contains a string made up of delimiters
*** that are used to move the file pointer in the input stream to the end of
*** the value you are reading (i.e. the ending marked by the presence of the
*** delimiter). The file pointer is moved just prior to the delimiter. If the
*** tokenList argument is a null pointer then this function expects to find EOF.
***
*** If input is being read from a stream then a tokenList should be provided so
*** this function can push the file pointer up to but not past the delimiter
*** (i.e. not removing the delimiter from the input stream). If you have a
*** string containing a single value and you expect the whole string to contain
*** a valid value, you can change the string to an istrstream, read the value
*** then send the istrstream to this function with tokenList set to null
*** and this function will set an error for you if any input remains following
*** the value.
// If the input stream can be readable again then
// - any error states set for the the stream are cleared.
// - white space skipped in the input stream
// - if EOF is encountered it returns
// otherwise it peeks at the next character
// - if the tokenList argument exists (i.e. is not null)
// then if looks to see if the char peeked at is in the tokenList string
// if it is then no error is set in the ErrorDescriptor
// if the char peeked at is not in the tokenList string that implies
// that there is garbage following the value that was successfully
// or unsuccessfully read. The garbage is read until EOF or a
// delimiter in the tokenList is found.
// - EOF is found you did not recover -> SEVERITY_INPUT_ERROR
// - delimiter found you recovered successfully => SEVERITY_WARNING
// - if tokenList does not exist then it expects to find EOF, if it does
// not then it is an error but the bad chars are not read since you have
// no way to know when to stop.
Severity
CheckRemainingInput( istream & in, ErrorDescriptor * err,
*** If the input stream can be readable again then
*** - any error states set for the the stream are cleared.
*** - white space skipped in the input stream
*** - if EOF is encountered it returns
*** otherwise it peeks at the next character
*** - if the tokenList argument exists (i.e. is not null)
*** then if looks to see if the char peeked at is in the tokenList string
*** if it is then no error is set in the ErrorDescriptor
*** if the char peeked at is not in the tokenList string that implies
*** that there is garbage following the value that was successfully
*** or unsuccessfully read. The garbage is read until EOF or a
*** delimiter in the tokenList is found.
*** - EOF is found you did not recover -> SEVERITY_INPUT_ERROR
*** - delimiter found you recovered successfully => SEVERITY_WARNING
*** - if tokenList does not exist then it expects to find EOF, if it does
*** not then it is an error but the bad chars are not read since you have
*** no way to know when to stop.
**/
Severity CheckRemainingInput( istream & in, ErrorDescriptor * err,
const char * typeName, // used in error message
const char * tokenList ) { // e.g. ",)"
std::string skipBuf;