X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkUtilities.h;h=910f4da4c1180ad72659d5043a8632ce1cfc7efe;hb=9525de09e988104a05a98acc18ba1ebc773b5f49;hp=b83193fd91e4aee1d9ec002fea8d31317cb5f13e;hpb=a26195c366a89795288009cf7e20f11afa494970;p=bbtk.git diff --git a/kernel/src/bbtkUtilities.h b/kernel/src/bbtkUtilities.h index b83193f..910f4da 100644 --- a/kernel/src/bbtkUtilities.h +++ b/kernel/src/bbtkUtilities.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkUtilities.h,v $ Language: C++ - Date: $Date: 2008/01/22 15:02:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008/05/06 13:45:12 $ + Version: $Revision: 1.15 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -26,61 +26,137 @@ * \class bbtk::Utilities * \brief various usefull methods */ - + #ifndef __bbtkUtilities_h_INCLUDED__ #define __bbtkUtilities_h_INCLUDED__ +#include "bbtkConfigurationFile.h" #include "bbtkSystem.h" #include +#include +#ifdef CMAKE_HAVE_TERMIOS_H +#include +#define BBTK_USE_TERMIOS_BASED_PROMPT +#endif + +#ifdef _MSC_VER + #include + #include +#else + #include + #include +#endif + +#include // std::toupper +//#include "bbtkMessageManager.h" namespace bbtk { /// Holds various usefull methods struct BBTK_EXPORT Utilities - { - static inline std::string get_file_name(const std::string& s) - { - std::string::size_type slash_position = s.find_last_of("/\\"); - if (slash_position != std::string::npos) - { - return s.substr(slash_position+1,std::string::npos); - } - else - { - return s; - } - } + { + + // ====================================================================== + // See : http://www.techbytes.ca/techbyte103.html for more O.S. + 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); + + // ======================================================================== - //======================================================================== - // Usefull functions for html generation + 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 bool IsAtRoot(std::string cwd); + // ====================================================================== + + static bool IsDirectory(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& tokens); + //======================================================================= + + + // =================================================================================== + + static std::string get_file_name(const std::string& s) ; + + + // =================================================================================== + /** + * \brief Explore a directory with possibility of recursion + * return number of files read + * @param dirpath directory to explore + * @param recursive whether we want recursion or not + */ + static int Explore(std::string const &dirpath, bool recursive, std::vector &Filenames); + + + //======================================================================= + // Replaces substrings "\\n" by a real carriage return "\n" + static void SubsBackslashN ( std::string& s ); + //======================================================================= + + + //======================================================================== + // Usefull functions for html generation + //======================================================================== + static inline void replace( std::string& str, - const std::string& from, - const std::string& to ) + const std::string& what, + const std::string& with ) { - using std::string; - string::size_type pos = str.find( from ); - while ( pos != string::npos ) + std::string::size_type pos = str.find( what ); + while ( pos != std::string::npos ) { - str.replace( pos, from.size(), to ); - pos = str.find( from, pos+from.size()-1 ); + str.replace( pos, what.size(), with ); + pos = str.find( what, pos+what.size()-1 ); } } //======================================================================== - //======================================================================== static inline void html_format(std::string& str) { replace( str, "&", "&" ); replace( str, "<", "<" ); replace( str, ">", ">" ); } + + + //======================================================================== + // Usefull functions OPTIONS string //======================================================================== + + static bool loosematch(std::string stdLine,std::string stdOptions); + + + + }; + } // namespace bbtk #endif //#ifndef __bbtkUtilities_h_INCLUDED__