static string
do_strip( const string& s, int striptype )
{
- // if (s.empty())
- // return s;
-
string::size_type len = s.length();
+ if( len == 0 ) // empty string is trivial
+ return s;
string::size_type i = 0;
if (striptype != RIGHTSTRIP)
{
return reply.insert( 0, length-l, c );
}
+ bool
+ starts_with( const string & s, const string & substr )
+ {
+ return s.find( substr ) == 0;
+ }
+
+ bool
+ ends_with( const string & s, const string & substr )
+ {
+ size_t n = s.rfind( substr );
+ return (n != string::npos) && (n == s.length() - substr.length());
+ }
+
} // end namespace strutils
} // end namespace simgear