1 /*=========================================================================
4 Module: $RCSfile: bbtkUtilities.h,v $
6 Date: $Date: 2008/01/22 15:02:00 $
7 Version: $Revision: 1.1.1.1 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See doc/license.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
22 * \brief struct bbtk::Utilities : various usefull methods
26 * \class bbtk::Utilities
27 * \brief various usefull methods
30 #ifndef __bbtkUtilities_h_INCLUDED__
31 #define __bbtkUtilities_h_INCLUDED__
33 #include "bbtkSystem.h"
38 /// Holds various usefull methods
39 struct BBTK_EXPORT Utilities
41 static inline std::string get_file_name(const std::string& s)
43 std::string::size_type slash_position = s.find_last_of("/\\");
44 if (slash_position != std::string::npos)
46 return s.substr(slash_position+1,std::string::npos);
55 //========================================================================
56 // Usefull functions for html generation
58 //========================================================================
59 static inline void replace( std::string& str,
60 const std::string& from,
61 const std::string& to )
64 string::size_type pos = str.find( from );
65 while ( pos != string::npos )
67 str.replace( pos, from.size(), to );
68 pos = str.find( from, pos+from.size()-1 );
71 //========================================================================
73 //========================================================================
74 static inline void html_format(std::string& str)
76 replace( str, "&", "&" );
77 replace( str, "<", "<" );
78 replace( str, ">", ">" );
80 //========================================================================
86 #endif //#ifndef __bbtkUtilities_h_INCLUDED__