/*========================================================================= Program: bbtk Module: $RCSfile: bbtkUtilities.h,v $ Language: C++ Date: $Date: 2008/01/22 15:02:00 $ Version: $Revision: 1.1.1.1 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * \file * \brief struct bbtk::Utilities : various usefull methods */ /** * \class bbtk::Utilities * \brief various usefull methods */ #ifndef __bbtkUtilities_h_INCLUDED__ #define __bbtkUtilities_h_INCLUDED__ #include "bbtkSystem.h" #include 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; } } //======================================================================== // Usefull functions for html generation //======================================================================== static inline void replace( std::string& str, const std::string& from, const std::string& to ) { using std::string; string::size_type pos = str.find( from ); while ( pos != string::npos ) { str.replace( pos, from.size(), to ); pos = str.find( from, pos+from.size()-1 ); } } //======================================================================== //======================================================================== static inline void html_format(std::string& str) { replace( str, "&", "&" ); replace( str, "<", "<" ); replace( str, ">", ">" ); } //======================================================================== }; } // namespace bbtk #endif //#ifndef __bbtkUtilities_h_INCLUDED__ //EOF