Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/01/28 09:12:49 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/01/28 10:50:54 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#define BBTK_USE_TERMIOS_BASED_PROMPT
#endif
+#include <string>
namespace bbtk
{
// ===================================================================================
-
void Interpreter::SwitchToFile( const std::string& name,
bool use_configuration_file, bool verbose)
{
std::string pkgname; // e.g. <scriptname>.bbs
pkgname = Utilities::ExtractScriptName(name);
-std::cout << "pkgname [" << pkgname << "] name [" << name << "]" << std::endl;
if (use_configuration_file)
{
if (verbose)
{ // ------------------------------------- check user supplied location
fullnameGiven = true;
libname = Utilities::ExpandLibName(name, verbose);
+
+ // allow user to always forget ".bbs"
+ int l = libname.size();
+ if (l>4)
+ {
+ if (libname.substr(l-4, 4) != ".bbs")
+ {
+ libname = libname + ".bbs";
+ }
+ }
+ else
+ {
+ libname = libname + ".bbs";
+ }
+
if (libname != "") {
if ( Utilities::FileExists(libname))
{
}
libname = Utilities::MakePkgnameFromPath(path, pkgname);
-
// Check if library exists
if ( ! Utilities::FileExists(libname) )
{
Program: bbtk
Module: $RCSfile: bbtkInterpreter.h,v $ $
Language: C++
- Date: $Date: 2008/01/22 16:55:04 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/01/28 10:50:54 $
+ Version: $Revision: 1.3 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace bbtk
{
-
class BBTK_EXPORT Interpreter
{
void FindCommandsWithPrefix( char* buf,
int n,
std::vector<std::string>& commands );
-
+
/// Sets the bool that indicates wether we are in command line context
void SetCommandLine(bool v = true) { mCommandLine = v; }
private:
-
+
private:
-
+
//==================================================================
// ATTRIBUTES
/// The factory
// bbtk::Factory* mFactory;
- /// The command executer
- // bbtk::Executer* mExecuter;
+ /// The command executer
bbtk::VirtualExec* mExecuter;
- /// Vector of opened files
+ /// Vector of opened files
std::vector<std::ifstream*> mFile;
- /// Vector of names of open files
+ /// Vector of names of open files
std::vector<std::string> mFileName;
/// Stores the current line number in each open file
/// Are we in a command line context ?
bool mCommandLine;
-
- /// The history of commands
- std::deque< char* > mHistory;
-
+
+ /// The history of commands
+ std::deque< char* > mHistory;
+
bool verbose; // true -> displays the search results (for packages)
};
QuitException() : bbtk::Exception("","","") {}
};
-
-
}
#endif