00001 #ifndef strings_h
00002 #define strings_h
00003
00004 #include <string>
00005 #include <list>
00006
00007 #include <strstream>
00008
00009 #include <cstring>
00010
00011
00012 #ifdef toupper
00013 # undef toupper
00014 #endif
00015
00017 namespace Strings
00018 {
00020 extern bool old_macro_style;
00021
00022 typedef std::list<std::string> string_list;
00023 typedef string_list::iterator string_list_it;
00024
00026 std::string strip( const std::string& str, const std::string& what = " \t\0\n" );
00027
00029 string_list split( std::string line, std::string what );
00030
00032 string_list split_simple( std::string str, std::string seperator = " \t\n", int max = -1 );
00033
00035 string_list split_string( std::string str, std::string seperator = " ", int max = -1 );
00036
00038 template<class T>std::string x2s( T what )
00039 {
00040 std::strstream str;
00041
00042 str << what << std::ends;
00043 std::string s( str.str() );
00044 str.freeze(0);
00045 return s;
00046 }
00047
00049 std::string substitude( std::string str, std::string what, std::string with );
00050 std::string substitude( std::string str,
00051 std::string what,
00052 std::string with,
00053 std::string ignore);
00054
00056 std::string macro_substitution( std::string text );
00057
00058
00060 template <class T> T s2x( const std::string& s )
00061 {
00062 std::strstream str;
00063
00064 str << s << std::ends;
00065 T t;
00066 str >> t;
00067 str.freeze(0);
00068 return t;
00069 }
00070
00071
00073 inline void toupper( std::string &s )
00074 {
00075 for( unsigned int i=0; i< s.size(); i++ )
00076 s[i] = std::toupper( s[i] );
00077 }
00078
00079
00080 bool isnum( const std::string& s );
00081 std::strstream& operator >> ( std::strstream& in, bool& w );
00082 }
00083
00084 #endif