Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/03/17 07:04:08 $
- Version: $Revision: 1.45 $
+ Date: $Date: 2008/03/18 12:51:26 $
+ Version: $Revision: 1.46 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//=======================================================================
+ //=======================================================================
+ /**
+ *
+ */
+ void Interpreter::InterpretBuffer( std::stringstream* buffer )
+ {
+ bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretBuffer()"<<std::endl);
+ // std::cout << "==========================================Entree InterpretFile ["<<filename<<"] try SwitchToFile "<<std::endl;
+ bool exm = mCommandLine;
+ mCommandLine = false;
+
+ try
+ {
+ SwitchToStream(buffer);
+
+/*
+ for( std::vector<std::string>::iterator it =mFileName.begin(); it!=mFileName.end(); ++it)
+ {
+ std::cout << "A=== [" << (*it) << "]" << std::endl;
+ }
+*/
+ bool insideComment = false; // for multiline comment
+ while (mFile.size()>0)
+ {
+/*
+ for( std::vector<std::string>::iterator it =mFileName.begin(); it!=mFileName.end(); ++it)
+ {
+ std::cout << "B=== [" << (*it) << "]" << std::endl;
+ }
+*/
+
+ //while ((mFile.size()>0) && !mFile.back()->eof() )
+ //{
+// std::cout << "mFile.size() "<< mFile.size() << " mFileName.back() [" << mFileName.back() << "]" << std::endl;
+ while (!mFile.back()->eof()) {
+ mLine.back()++;
+ char buf[500];
+ mFile.back()->getline(buf,500);
+ std::string str(buf);
+// std::cout << " in InterpretFile mFile.back()->getline [" << str << "]" << std::endl;
+ int size=str.length();
+ if ( str[ size-1 ]==13 )
+ {
+ str.erase(size-1,1);
+ }
+
+ InterpretLine(str, insideComment);
+
+ }//while
+ //if (mFile.size()>0)
+ CloseCurrentFile();
+ }
+ }
+ catch (QuitException e)
+ {
+ // std::cout << "**QuitException caught**"<<std::endl;
+ }
+ catch (bbtk::Exception e)
+ {
+ std::cerr << "* ERROR : "<<e.GetMessage()<<std::endl;
+ if (mFileName.size()) {
+ std::cerr << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
+ std::cerr << "* LINE : "<<mLine.back()<<std::endl;
+ }
+ }
+ catch (std::exception& e)
+ {
+ std::cerr << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
+ if (mFileName.size()) {
+ std::cerr << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
+ std::cerr << "* LINE : "<<mLine.back()<<std::endl;
+ }
+ }
+ catch (...)
+ {
+ std::cout << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
+ if (mFileName.size()) {
+ std::cout << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
+ std::cout << "* LINE : "<<mLine.back()<<std::endl;
+ }
+ }
+
+ CloseAllFiles();
+ bbtkDebugMessage("Interpreter",9,"EO Interpreter::InterpretBuffer()"<<std::endl);
+ bbtkDecTab("Interpreter",9);
+
+ mCommandLine = exm;
+ }
+ //=======================================================================
+
+
//=======================================================================
/**