#include "util/StringUtils.hpp" #include #include using namespace std; bool stringicasecmp( const string &s1, const string &s2 ) { string::const_iterator i1 = s1.begin( ), e1 = s1.end( ), i2 = s2.begin( ), e2 = s2.end( ); while( i1 != e1 && i2 != e2 ) { if( toupper( *i1 ) != toupper( *i2 ) ) return false; i1++; i2++; } if( i1 == e1 && i2 == e2 ) return true; return false; } std::vector split( const string &s, const string &delimiter, bool keepEmpty ) { vector result; if( delimiter.empty( ) ) { result.push_back( s ); return result; } string::const_iterator b = s.begin( ), e; while( true ) { e = search( b, s.end( ), delimiter.begin( ), delimiter.end( ) ); string tmp( b, e ); if( keepEmpty || !tmp.empty( ) ) { result.push_back( tmp ); } if( e == s.end( ) ) { break; } b = e + delimiter.size( ); } return result; } bool endswith( const string &s, const string &endstring ) { unsigned int pos = s.rfind( endstring ); return pos != string::npos && pos + endstring.length( ) == s.length( ); } bool startswith( const string &s, const string &startstring ) { unsigned int pos = s.find( startstring ); return pos != string::npos; }