bbtk::Utilities Class Reference

Holds various usefull methods. More...

#include <bbtkUtilities.h>

List of all members.

Static Public Member Functions

static std::string GetExecutablePath ()
static bool FileExists (std::string strFilename)
static std::string ExtractPackageName (const std::string &name, std::string &path)
static std::string ExtractScriptName (const std::string &name, std::string &path)
static std::string ExpandLibName (const std::string &name, bool verbose)
static std::string MakeLibnameFromPath (std::string path, std::string pkgname)
static std::string MakePkgnameFromPath (std::string path, std::string pkgname, bool addExt)
static void MakeValidFileName (std::string &name)
static std::string GetUserSettingsDir ()
 Returns the user settings dir, e.g. /home/username/.bbtk.
static std::string MakeUserSettingsFullFileName (const std::string &name)
static bool IsAtRoot (std::string cwd)
static bool IsDirectory (std::string const &dirName)
static void CreateDirectoryIfNeeded (std::string const &dirName)
static void SplitAroundFirstDot (const std::string &in, std::string &left, std::string &right)
static void SplitString (const std::string &str, const std::string &delimiters, std::vector< std::string > &tokens)
static std::string get_file_name (const std::string &s)
static int Explore (std::string const &dirpath, bool recursive, std::vector< std::string > &Filenames)
 Explore a directory with possibility of recursion return number of files read.
static void SubsBackslashN (std::string &s)
static void replace (std::string &str, const std::string &what, const std::string &with)
static void html_format (std::string &str)
static bool loosematch (std::string stdLine, std::string stdOptions)


Detailed Description

Holds various usefull methods.

various usefull methods

Definition at line 73 of file bbtkUtilities.h.


Member Function Documentation

void bbtk::Utilities::CreateDirectoryIfNeeded ( std::string const &  dirName  )  [static]

Definition at line 357 of file bbtkUtilities.cxx.

References FileExists().

Referenced by bbtk::ConfigurationFile::InitializeDotBbtkStructure().

00358   {
00359     if (FileExists(dirName)) return;
00360     std::string cmd("mkdir \"");
00361     cmd += dirName;
00362     cmd += "\"";
00363     system(cmd.c_str());
00364   }  

Here is the call graph for this function:

Here is the caller graph for this function:

std::string bbtk::Utilities::ExpandLibName ( const std::string &  name,
bool  verbose 
) [static]

Definition at line 166 of file bbtkUtilities.cxx.

References bbtk::ConfigurationFile::Get_file_separator(), bbtk::ConfigurationFile::GetInstance(), and IsAtRoot().

Referenced by bbtk::Factory::LoadPackage(), and bbtk::InterpreterVirtual::SwitchToFile().

00167     {
00168       // -----   Think of expanding path name ( ./ ../ ../../ )
00169       
00170       char buf[2048]; // for getcwd
00171       char * currentDir = getcwd(buf, 2048);
00172       std::string cwd(currentDir);
00173       std::string libname(name);
00174       std::string fileSeparator;
00175       fileSeparator = ConfigurationFile::GetInstance().Get_file_separator();
00176       // tooHigh : true is user supplies a library pathname with too many "../"
00177       bool tooHigh = false;
00178       
00179       //std::cout << "------------------cwd ["  << cwd << "] name [" << name << "]" << std::endl;
00180       
00181       if ( name[0] == '/' ||  name[1] == ':' ) // Linux or Windows absolute name
00182         {
00183           return(libname);
00184         }
00185       else if  ( name =="." )
00186         {
00187           libname = cwd  + fileSeparator;
00188           return(libname);
00189         }
00190       else if  (name[0] == '.' && (name[1] == '/' || name[1] == '\\') )
00191         {
00192           libname = cwd  + fileSeparator + name.substr(2, name.length());
00193           return(libname);
00194         }
00195       else if ( name[0] == '.' &&  name[1] == '.' /*  && (name[2] == '/' || name[2] == '\\') */ ) 
00196         {
00197           if ( IsAtRoot(cwd) )  // hope it gets / (for Linux),  C: D: (for Windows)
00198       {  
00199      // if we are already at / or c: --> hopeless  
00200          if (verbose)
00201            std::cout << "   File path [" <<  name << "] doesn't exist" << std::endl;
00202          tooHigh = true;
00203       }
00204       else
00205       {
00206          // iterate on ../ and go up from the current working dir!
00207          std::string a(name); 
00208          bool alreadyProcessRoot = false;
00209 
00210           //if (a[a.size()-1] != fileSeparator[0])
00211           //   a.append(fileSeparator);
00212 //std::cout << "------------------a ["  << a << "]" << std::endl;
00213 
00214          for(;;)  // wild loop !
00215          {
00216             std::string::size_type slash_position = cwd.find_last_of(fileSeparator);
00217             if (slash_position != std::string::npos) {
00218              if (slash_position == 0)
00219                 slash_position = 1;
00220               cwd = cwd.substr(0,slash_position/*+1*/);
00221 //std::cout << "------------------cwd ["  << cwd << "]" << std::endl;
00222             //  if (a == "..") {
00223             //    a = "";
00224             //    break;
00225             //   }
00226             //   else
00227                  a = a.substr(3, /*name.length()*/ a.length());  // remove ../
00228 //std::cout << "------------------a ["  << a << "]" << std::endl;  
00229               if (a == "" || alreadyProcessRoot)
00230               {
00231                 if (verbose)
00232                   std::cout << "   File path : [" <<  name << "] doesn't exist" << std::endl;
00233                 tooHigh = true;
00234                 break;
00235               }
00236              // std::string b = cwd + a;
00237               libname =  cwd;
00238               char c = cwd[cwd.size()-1];
00239               if (c != '/' && c != '\\' )
00240                 libname += fileSeparator;
00241               libname += a;
00242 
00243               if ( a[0] != '.' ) // if . (probabely ../), loop again
00244                 break;
00245 
00246               if (IsAtRoot(cwd))
00247                 alreadyProcessRoot = true;
00248             }
00249          } // end iterating on ../
00250       }
00251 //std::cout << "------------------out of loop]" << std::endl;        
00252       if (tooHigh)
00253          libname="";
00254       return (libname);
00255 
00256     }  // -----   End of expanding path name   ( ./ ../ ../../ )
00257 
00258     std::cout <<"* ERROR in ExpandLibName : should never get here!" << std::endl;
00259     // To avoid warning
00260     return(""); // Will never get here!
00261   }

Here is the call graph for this function:

Here is the caller graph for this function:

int bbtk::Utilities::Explore ( std::string const &  dirpath,
bool  recursive,
std::vector< std::string > &  Filenames 
) [static]

Explore a directory with possibility of recursion return number of files read.

Parameters:
dirpath directory to explore
recursive whether we want recursion or not

Definition at line 468 of file bbtkUtilities.cxx.

Referenced by bbtk::InterpreterVirtual::SwitchToFile().

00469   {
00470     int numberOfFiles = 0;
00471     std::string fileName;
00472       
00473       std::string dirName = dirpath;
00474       
00475 #ifdef _MSC_VER
00476       WIN32_FIND_DATA fileData;
00477    HANDLE hFile = FindFirstFile((dirName+"\\*").c_str(), &fileData);
00478 
00479    for(BOOL b = (hFile != INVALID_HANDLE_VALUE); b;
00480        b = FindNextFile(hFile, &fileData))
00481    {
00482       fileName = fileData.cFileName;
00483       if ( fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
00484       {
00485          // Need to check for . and .. to avoid infinite loop
00486          if ( fileName != "." && fileName != ".." && recursive )
00487          {
00488             numberOfFiles += Explore(dirName+ "\\"+fileName,recursive,Filenames);
00489          }
00490       }
00491       else
00492       {
00493          Filenames.push_back(dirName+"\\"+fileName);
00494          numberOfFiles++;
00495       }
00496    }
00497    DWORD dwError = GetLastError();
00498    if (hFile != INVALID_HANDLE_VALUE) 
00499       FindClose(hFile);
00500    if (dwError != ERROR_NO_MORE_FILES) 
00501    {
00502       LPVOID lpMsgBuf;
00503       FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
00504                     FORMAT_MESSAGE_FROM_SYSTEM|
00505                     FORMAT_MESSAGE_IGNORE_INSERTS,
00506                     NULL,GetLastError(),
00507                     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00508                     (LPTSTR) &lpMsgBuf,0,NULL);
00509 
00510      // ErrorMacro("FindNextFile error. Error is " << (char *)lpMsgBuf
00511      //             <<" for the directory : "<<dirName);
00512       
00513       return 0;
00514    }
00515 
00516 #else
00517   // Real POSIX implementation: scandir is a BSD extension only, and doesn't 
00518   // work on debian for example
00519 //std::cout <<"in Explor dirname[" << dirName << "]" << std::endl; 
00520    DIR* dir = opendir(dirName.c_str());
00521    if (!dir)
00522    {
00523       return 0;
00524    }
00525 //std::cout <<"Open OK" << std::endl; 
00526    // According to POSIX, the dirent structure contains a field char d_name[]
00527    // of unspecified size, with at most NAME_MAX characters preceeding the
00528    // terminating null character. Use of other fields will harm the  porta-
00529    // bility of your programs.
00530 
00531    struct stat buf;
00532    dirent *d;
00533    for (d = readdir(dir); d; d = readdir(dir))
00534    {
00535       fileName = dirName + "/" + d->d_name;
00536 //std::cout <<"in Explor filename[" << fileName << "]" << std::endl;      
00537       if( stat(fileName.c_str(), &buf) != 0 )
00538       {
00539          //ErrorMacro( strerror(errno) );
00540       }
00541       if ( S_ISREG(buf.st_mode) )    //is it a regular file?
00542       {
00543          Filenames.push_back( fileName );
00544          numberOfFiles++;
00545       }
00546       else if ( S_ISDIR(buf.st_mode) ) //directory?
00547       {
00548          if ( d->d_name[0] != '.' && recursive ) //we also skip hidden files
00549          {
00550             numberOfFiles += Explore( fileName, recursive, Filenames);
00551          }
00552       }
00553       else
00554       {
00555          //ErrorMacro( "Unexpected error" );
00556          return -1;
00557       }
00558    }
00559    if( closedir(dir) != 0 )
00560    {
00561      // ErrorMacro( strerror(errno) );
00562    }
00563 #endif
00564 
00565   return numberOfFiles;
00566 
00567 }

Here is the caller graph for this function:

std::string bbtk::Utilities::ExtractPackageName ( const std::string &  name,
std::string &  path 
) [static]

Definition at line 86 of file bbtkUtilities.cxx.

References bbtkError.

Referenced by bbtk::Factory::LoadPackage().

00088     {
00089       std::string pkgname;
00090       path = "";
00091       
00092       std::string::size_type slash_position = name.find_last_of("/\\");
00093       if (slash_position != std::string::npos) 
00094         {
00095           pkgname = name.substr(slash_position+1,std::string::npos);
00096           path = name.substr(0,slash_position);
00097           //    std::cout << "F:P='"<<path<<"'"<<std::endl;//+1,std::string::npos);
00098         }
00099       else 
00100         {
00101           pkgname = name;
00102         }
00103       
00104       // remove {.so | dll} if any
00105       std::string::size_type dot_position = pkgname.find_last_of('.');      
00106       if (dot_position != std::string::npos){
00107         pkgname = pkgname.substr(0,dot_position);
00108       }      
00109 #if defined(__GNUC__)
00110       
00111       // GCC mechanism
00112       // shared lib name = libbb<name>.so
00113       
00114       // remove {libbb} if any
00115       if (memcmp ( pkgname.c_str(), "libbb", 5) == 0) {
00116         pkgname =  pkgname.substr(5, pkgname.length());
00117       }
00118       /*
00121       */
00122 #elif defined(_WIN32)
00123       
00124       // WIN 32 mechanism
00125       // shared lib name = <name>.dll
00126       
00127       // EED Problem loading package call bbtkTools
00128       //     // remove {bb} if any
00129       if (memcmp (pkgname.c_str(), "bb", 2) == 0) {
00130         pkgname =  pkgname.substr(2, pkgname.length());  
00131       }
00132       
00133       /*
00136      */
00137 #else
00138       bbtkError("neither __GNUC__ nor _WIN32 ?!? How did you compile ?");
00139 #endif      
00140       return pkgname;
00141     }

Here is the caller graph for this function:

std::string bbtk::Utilities::ExtractScriptName ( const std::string &  name,
std::string &  path 
) [static]

Definition at line 144 of file bbtkUtilities.cxx.

Referenced by main(), bbtk::InterpreterVirtual::SwitchToFile(), and bbtk::Transcriptor::Transcriptor().

00146     {
00147       std::string pkgname;
00148       
00149       std::string::size_type slash_position = name.find_last_of("/\\");
00150       if (slash_position != std::string::npos) {
00151         pkgname =name.substr(slash_position+1,std::string::npos);
00152         path = name.substr(0,slash_position);      
00153       } else {
00154         pkgname = name;
00155       }
00156       // remove {.bbs } if any
00157       std::string::size_type dot_position = pkgname.find_last_of('.');
00158       if (dot_position != std::string::npos){
00159         pkgname = pkgname.substr(0,dot_position);
00160       }
00161       return pkgname;
00162     }

Here is the caller graph for this function:

bool bbtk::Utilities::FileExists ( std::string  strFilename  )  [static]

Definition at line 55 of file bbtkUtilities.cxx.

Referenced by bbtk::Interpreter::commandHelp(), bbtk::ConfigurationFile::ConfigurationFile(), CreateDirectoryIfNeeded(), bbtk::ConfigurationFile::InitializeDotBbtkStructure(), bbtk::ConfigurationFile::InstallPath(), bbtk::Factory::LoadPackage(), bbtk::WxGUIScriptingInterface::LoadPerspective(), bbtk::WxGUIScriptingInterface::OnMenuPlugPackage(), bbtk::Executer::ShowGraph(), and bbtk::InterpreterVirtual::SwitchToFile().

00056     {
00057       struct stat stFileInfo;
00058      bool blnReturn;
00059      int intStat;
00060      
00061      // Attempt to get the file attributes
00062      intStat = stat(strFilename.c_str(),&stFileInfo);
00063      if(intStat == 0) 
00064        {
00065          // We were able to get the file attributes
00066          // so the file obviously exists.
00067          blnReturn = true;
00068        } 
00069      else 
00070        {
00071          // We were not able to get the file attributes.
00072          // This may mean that we don't have permission to
00073          // access the folder which contains this file. If you
00074          // need to do that level of checking, lookup the
00075          // return values of stat which will give you
00076          // more details on why stat failed.
00077          blnReturn = false;
00078        }
00079      
00080      return(blnReturn);
00081     }

Here is the caller graph for this function:

std::string bbtk::Utilities::get_file_name ( const std::string &  s  )  [static]

Definition at line 446 of file bbtkUtilities.cxx.

Referenced by bbtk::WxGUITextEditor::NewPage().

00447   { 
00448     std::string::size_type slash_position = s.find_last_of("/\\");
00449     if (slash_position != std::string::npos) 
00450       {
00451         return  s.substr(slash_position+1,std::string::npos);   
00452       }
00453     else 
00454       {
00455         return s;
00456       }
00457   }

Here is the caller graph for this function:

std::string bbtk::Utilities::GetExecutablePath (  )  [static]

Definition at line 743 of file bbtkUtilities.cxx.

References bbtkGlobalError, bbtk::get_app_path(), PATH_MAX, and VALID_FILE_SEPARATOR_CHAR.

Referenced by bbtk::ConfigurationFile::ConfigurationFile(), and bbtk::ConfigurationFile::InstallPath().

00744   {
00745     char name[PATH_MAX];
00746     int err = get_app_path(name, PATH_MAX);
00747     if (err) 
00748       {
00749         bbtkGlobalError("Could not determine current executable path ?");  
00750       }
00751     
00752     // remove the exe name
00753     char *slash;                
00754     slash = strrchr(name, VALID_FILE_SEPARATOR_CHAR);
00755     if (slash)
00756       {
00757         *slash = 0;
00758       }
00759     return name;
00760   }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string bbtk::Utilities::GetUserSettingsDir (  )  [static]

Returns the user settings dir, e.g. /home/username/.bbtk.

Definition at line 326 of file bbtkUtilities.cxx.

References MakeValidFileName().

Referenced by bbtk::ConfigurationFile::InitializeDotBbtkStructure().

00327   {
00328 #if defined(__GNUC__)
00329     std::string str_home(getenv("HOME"));
00330 #elif defined(_WIN32)
00331     std::string str_home(getenv("USERPROFILE"));
00332 #endif
00333     std::string fullname = str_home + "/.bbtk";
00334     MakeValidFileName(fullname);
00335     return fullname;
00336   }

Here is the call graph for this function:

Here is the caller graph for this function:

static void bbtk::Utilities::html_format ( std::string &  str  )  [inline, static]

Definition at line 178 of file bbtkUtilities.h.

Referenced by bbtk::Factory::CreateHtmlIndex(), bbtk::Package::CreateHtmlPage(), bbtk::ComplexBlackBoxDescriptor::InsertHtmlHelp(), and bbtk::BlackBoxDescriptor::InsertHtmlHelp().

00179     {
00180       replace( str, "&", "&amp;" );
00181       replace( str, "<", "&lt;" );
00182       replace( str, ">", "&gt;" );
00183     }

Here is the caller graph for this function:

bool bbtk::Utilities::IsAtRoot ( std::string  cwd  )  [static]

Definition at line 369 of file bbtkUtilities.cxx.

Referenced by ExpandLibName().

00370   {
00371     if ( cwd == "/"              // hope it gets /     (for Linux)
00372          || (cwd.size() <= 3 && cwd[1] == ':') ) // hope it gets C: D: (for Windows)
00373       return (true);
00374     else
00375       return(false);
00376   }

Here is the caller graph for this function:

bool bbtk::Utilities::IsDirectory ( std::string const &  dirName  )  [static]

Definition at line 380 of file bbtkUtilities.cxx.

Referenced by bbtk::InterpreterVirtual::SwitchToFile().

00381   {
00382     struct stat fs;
00383     
00384     if ( stat(dirName.c_str(), &fs) == 0 )
00385       {
00386 #if _WIN32
00387         return ((fs.st_mode & _S_IFDIR) != 0);
00388 #else
00389         return S_ISDIR(fs.st_mode);
00390 #endif
00391       }
00392     else
00393       {
00394         return false;
00395       }
00396   }

Here is the caller graph for this function:

bool bbtk::Utilities::loosematch ( std::string  stdLine,
std::string  stdOptions 
) [static]

Definition at line 590 of file bbtkUtilities.cxx.

References bbtk::i, and SplitString().

00591   {
00592     bool result=false;
00593     std::vector<std::string> tokens;
00594     SplitString ( stdOptions,"|", tokens);
00595     int i,size=tokens.size();  
00596     for (i=0; i<size; i++)
00597       {           
00598 #ifdef WIN32
00599         if ( strcmpi(stdLine.c_str(),tokens[i].c_str())==0) 
00600           { 
00601             result=true; 
00602           }               
00603 #else
00604         if ( strcasecmp(stdLine.c_str(),tokens[i].c_str())==0) 
00605           { 
00606             result=true; 
00607           }               
00608 #endif
00609         
00610       }
00611     return result;
00612   }

Here is the call graph for this function:

std::string bbtk::Utilities::MakeLibnameFromPath ( std::string  path,
std::string  pkgname 
) [static]

Definition at line 265 of file bbtkUtilities.cxx.

Referenced by bbtk::Factory::LoadPackage().

00266   {
00267     std::string libname = path;
00268         if(path.size()>0){
00269                 char c = path[path.size()-1];    
00270 #if defined(__GNUC__)
00271        if (c != '/')
00272           libname += "/libbb";
00273        else
00274           libname += "libbb";
00275        libname += pkgname;
00276 #if defined(MACOSX)
00277           libname += ".dylib";
00278 #else
00279           libname += ".so";
00280 #endif  
00281           
00282 #elif defined(_WIN32)
00283        if (c != '\\') 
00284           libname += "\\bb";
00285        else
00286           libname += "bb";
00287        libname += pkgname;
00288        libname += ".dll";
00289 #endif
00290         }
00291     
00292     return libname;    
00293   }

Here is the caller graph for this function:

std::string bbtk::Utilities::MakePkgnameFromPath ( std::string  path,
std::string  pkgname,
bool  addExt 
) [static]

Definition at line 297 of file bbtkUtilities.cxx.

References bbtk::ConfigurationFile::Get_file_separator(), and bbtk::ConfigurationFile::GetInstance().

Referenced by bbtk::InterpreterVirtual::SwitchToFile().

00298   {
00299     std::string libname = path;
00300         if(path.size()>0){
00301                 char c = path[path.size()-1];
00302                 if (c != '/' && c != '\\')
00303                 {
00304                    libname +=  ConfigurationFile::GetInstance().Get_file_separator ();
00305                 }
00306                 libname += pkgname;
00307                 if (addExt)
00308                 {
00309                    int l = libname.size();
00310                    if (l>4)
00311                    {
00312                           if (libname.substr(l-4, 4) != ".bbs")
00313                           {
00314                                    libname = libname + ".bbs";
00315                           }
00316                    }
00317                 }
00318         }
00319     
00320     return libname;
00321   }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string bbtk::Utilities::MakeUserSettingsFullFileName ( const std::string &  name  )  [static]

Builds the complete path to the file 'name' located in user settings dir, e.g. /home/username/.bbtk/

Builds the complete path to the file 'name' located in user settings dir, e.g. /home/username/.bbtk/

Definition at line 342 of file bbtkUtilities.cxx.

References MakeValidFileName().

Referenced by bbtk::ConfigurationFile::ConfigurationFile(), bbtk::ConfigurationFile::InitializeDotBbtkStructure(), bbtk::WxGUIScriptingInterface::LoadPerspective(), and bbtk::WxGUIScriptingInterface::SavePerspective().

00343   {
00344 #if defined(__GNUC__)
00345     std::string str_home(getenv("HOME"));
00346 #elif defined(_WIN32)
00347     std::string str_home(getenv("USERPROFILE"));
00348 #endif
00349     std::string fullname = str_home + "/.bbtk/" + name;
00350     MakeValidFileName(fullname);
00351     return fullname;
00352   }

Here is the call graph for this function:

Here is the caller graph for this function:

static void bbtk::Utilities::MakeValidFileName ( std::string &  name  )  [inline, static]

Makes a valid filename with string (replaces invalid file seps by valid ones)

Definition at line 105 of file bbtkUtilities.h.

References INVALID_FILE_SEPARATOR, and VALID_FILE_SEPARATOR.

Referenced by GetUserSettingsDir(), bbtk::ConfigurationFile::InitializeDotBbtkStructure(), and MakeUserSettingsFullFileName().

00106     {
00107       replace( name, 
00108                INVALID_FILE_SEPARATOR , 
00109                VALID_FILE_SEPARATOR);
00110     }

Here is the caller graph for this function:

static void bbtk::Utilities::replace ( std::string &  str,
const std::string &  what,
const std::string &  with 
) [inline, static]

Definition at line 165 of file bbtkUtilities.h.

Referenced by bbtk::ConfigurationFile::AddPackagePathsAndWrite(), bbtk::ConfigurationFile::ConfigurationFile(), and bbtk::InterpreterVirtual::LoadScript().

00168     {
00169       std::string::size_type pos = str.find( what );
00170           while ( pos != std::string::npos )
00171       {
00172         str.replace( pos, what.size(), with );
00173         pos = str.find( what, pos+what.size()-1 );
00174       } 
00175     }

Here is the caller graph for this function:

void bbtk::Utilities::SplitAroundFirstDot ( const std::string &  in,
std::string &  left,
std::string &  right 
) [static]

Definition at line 400 of file bbtkUtilities.cxx.

References bbtkGlobalError.

Referenced by bbtk::InterpreterVirtual::DoInterpretLine(), and bbtk::Executer::Print().

00403   {
00404     std::string delimiter = ".";
00405     std::string::size_type pos = in.find_first_of(delimiter);
00406     if (std::string::npos != pos) 
00407       {
00408         left = in.substr(0,pos);
00409         right = in.substr(pos+1,in.size());
00410         
00411       }
00412     else
00413       {
00414         left ="";
00415         right = "";
00416         bbtkGlobalError("Token '"<<in<<"' : expected 'a.b' format but no dot found");
00417       }
00418   }

Here is the caller graph for this function:

void bbtk::Utilities::SplitString ( const std::string &  str,
const std::string &  delimiters,
std::vector< std::string > &  tokens 
) [static]

Definition at line 422 of file bbtkUtilities.cxx.

Referenced by bbtk::Factory::CreateHtmlIndex(), bbtk::ComplexBlackBoxDescriptor::InsertHtmlHelp(), bbtk::BlackBoxDescriptor::InsertHtmlHelp(), loosematch(), and bbtk::InterpreterVirtual::SplitLine().

00425   {
00426     // Skip delimiters at beginning.
00427     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00428     // Find first delimiter.
00429     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
00430     
00431     while (std::string::npos != pos || std::string::npos != lastPos)
00432       {
00433         // Found a token, add it to the vector.
00434         tokens.push_back(str.substr(lastPos, pos - lastPos));
00435         // Skip delimiters.  Note the "not_of"
00436         lastPos = str.find_first_not_of(delimiters, pos);
00437         // Find next delimiter
00438         pos = str.find_first_of(delimiters, lastPos);
00439       }
00440     
00441   }

Here is the caller graph for this function:

void bbtk::Utilities::SubsBackslashN ( std::string &  s  )  [static]

Definition at line 573 of file bbtkUtilities.cxx.

Referenced by bbtk::Executer::Print().

00574     {
00575       std::string ss("\\n");
00576       std::string::size_type pos = 0;
00577       pos = s.find(ss,0);
00578       const char* cr = "\n";
00579       while ( pos != std::string::npos )
00580         {
00581           s.replace(pos,2,cr,1);
00582           pos = s.find(ss, pos-1);
00583         }
00584     }

Here is the caller graph for this function:


The documentation for this class was generated from the following files:

Generated on Thu May 31 14:15:08 2012 for BBTK by  doxygen 1.5.7.1