[GME-commit] GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep
Dumper.cpp,1.29,1.30 Dumper.h,1.9,1.10 Sheet.cpp,1.11,1.12
Sheet.h,1.6,1.7
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Mon Jun 27 16:54:04 CDT 2005
Update of /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep
In directory escher:/tmp/cvs-serv2070/MetaInterpreter2004/Rep
Modified Files:
Dumper.cpp Dumper.h Sheet.cpp Sheet.h
Log Message:
Preventing giving erroneous default filename to CFileSaveDlg (would crash.)
Notifying user about erroneous paradigm name (special characters, spaces in rootfolder.)
CVS User: Zoltan Molnar, ISIS (zolmol)
Index: Sheet.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Sheet.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Sheet.h 30 Jul 2004 00:10:23 -0000 1.6
--- Sheet.h 27 Jun 2005 15:54:02 -0000 1.7
***************
*** 58,61 ****
--- 58,62 ----
static BON::Folder m_BON_Project_Root_Folder;
+ static bool makeValidParadigmName( const std::string& pInName, std::string& result);
protected:
Index: Dumper.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Dumper.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** Dumper.cpp 21 Jun 2005 17:16:46 -0000 1.29
--- Dumper.cpp 27 Jun 2005 15:54:02 -0000 1.30
***************
*** 1588,1594 ****
}
! /*static*/ int Dumper::selectOutputFiles( const BON::Project& proj, const std::string& proj_name, const std::string& proj_path)
{
try {
global_vars.xmp_file_name = proj_name + ".xmp";
--- 1588,1608 ----
}
+ /*static*/ std::string Dumper::makeValidFileName( const std::string& pInFile)
+ {
+ std::string res;
+ std::string badchars(_T("\\/:*?\"<>|"));
+ for( unsigned int i = 0; i < pInFile.length(); ++i)
+ {
+ if( badchars.find( pInFile[i] ) == std::string::npos)
+ res += pInFile[i];
+ else
+ res += '_';
+ }
+ return res;
+ }
! /*static*/ int Dumper::selectOutputFiles( const BON::Project& proj, const std::string& p_proj_name, const std::string& proj_path)
{
+ std::string proj_name = makeValidFileName( p_proj_name);
try {
global_vars.xmp_file_name = proj_name + ".xmp";
Index: Sheet.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Sheet.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Sheet.cpp 21 Jun 2005 17:16:46 -0000 1.11
--- Sheet.cpp 27 Jun 2005 15:54:02 -0000 1.12
***************
*** 155,168 ****
m_projComment = project->getComment();
! // check the paradigm's name
! int pos = m_projName.find(' ');
! if( pos != std::string::npos)
{
! global_vars.err << MSG_ERROR << "Error: Incorrect paradigm name: \"" << m_projName << "\". Please remove the spaces.\n";
! while( pos != std::string::npos)
! {
! m_projName[ pos] = '_';
! pos = m_projName.find(' ', pos); // search for the next space starting from the last one
! }
}
}
--- 155,164 ----
m_projComment = project->getComment();
! // check the paradigm's name, containing spaces, other special chars, excluding '.' and '_'
! std::string new_name;
! if( !Sheet::makeValidParadigmName( m_projName, new_name))
{
! global_vars.err << MSG_ERROR << "Error: Incorrect paradigm name: \"" << m_projName << "\". Use only alphanumerics, '.' and '_'. No spaces please. Using modified name: \"" << new_name << "\".\n";
! m_projName = new_name;
}
}
***************
*** 734,735 ****
--- 730,752 ----
}
+ /*static*/ bool Sheet::makeValidParadigmName( const std::string& pInName, std::string& res)
+ {
+ res = pInName;
+ bool inv(false); // invalid name?
+ // check the paradigm's name, containing spaces, other special chars, excluding '.', '_'
+ for( unsigned int i = 0; i < res.length(); ++i)
+ {
+ bool v = res[i] >= 'a' && res[i] <= 'z' ||
+ res[i] >= 'A' && res[i] <= 'Z' ||
+ res[i] >= '0' && res[i] <= '9' ||
+ res[i] == '.' ||
+ res[i] >= '_';
+
+ if( !v)
+ {
+ res[i] = '_';
+ inv = true;
+ }
+ }
+ return !inv;
+ }
Index: Dumper.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Dumper.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Dumper.h 5 Nov 2004 21:25:08 -0000 1.9
--- Dumper.h 27 Jun 2005 15:54:02 -0000 1.10
***************
*** 19,22 ****
--- 19,23 ----
+ static std::string makeValidFileName( const std::string& pInFile);
static int selectOutputFiles( const BON::Project&, const std::string& proj_name, const std::string& project_path);
static int selectOptions( const BON::Project&);
More information about the GME-commit
mailing list