Added find(str, what, from) to the default_string_adaptor

This commit is contained in:
Jez Higgins 2010-12-23 22:50:43 +00:00
parent dbfcf1c41b
commit 2e1f279786
3 changed files with 21 additions and 4 deletions

View file

@ -57,6 +57,8 @@ public:
static bool empty(const string_type& str) { return str.empty(); }
static size_type find(const string_type& str, value_type what) { return str.find(what); }
static size_type find(const string_type& str, const string_type& what) { return str.find(what); }
static size_type find(const string_type& str, value_type what, size_type from) { return str.find(what, from); }
static size_type find(const string_type& str, const string_type& what, size_type from) { return str.find(what, from); }
static string_type substr(const string_type& str, const size_type& offset) { return str.substr(offset); }
static string_type substr(const string_type& str, const size_type& offset, const size_type& count) { return str.substr(offset, count); }
static void append(string_type& str, const string_type& a) { str.append(a); }

View file

@ -95,6 +95,16 @@ silly_string_adaptor::size_type silly_string_adaptor::find(const silly_string& s
return str.s_.find(c);
} // find
silly_string_adaptor::size_type silly_string_adaptor::find(const silly_string& str, const silly_string& what, silly_string_adaptor::size_type from)
{
return str.s_.find(what.s_, from);
} // find
silly_string_adaptor::size_type silly_string_adaptor::find(const silly_string& str, value_type c, silly_string_adaptor::size_type from)
{
return str.s_.find(c, from);
} // find
silly_string silly_string_adaptor::substr(const silly_string& str, const size_type& offset)
{
return silly_string_adaptor::construct_from_utf8(str.s_.substr(offset).c_str());

View file

@ -72,6 +72,8 @@ public:
static bool empty(const silly_string& s);
static size_type find(const silly_string& str, const silly_string& what);
static size_type find(const silly_string& str, value_type c);
static size_type find(const silly_string& str, const silly_string& what, size_type from);
static size_type find(const silly_string& str, value_type c, size_type from);
static silly_string substr(const silly_string& str, const size_type& offset);
static silly_string substr(const silly_string& str, const size_type& offset, const size_type& count);
static size_type length(const silly_string& str);
@ -101,12 +103,15 @@ namespace std {
template<>
struct less<silly_string> : public binary_function<silly_string, silly_string, bool>
{ // functor for operator<
bool operator()(const silly_string& lhs, const silly_string& rhs) const
{ // apply operator< to operands
{
// functor for operator<
bool operator()(const silly_string& lhs, const silly_string& rhs) const
{
// apply operator< to operands
return (silly_string_adaptor::asStdString(lhs) < silly_string_adaptor::asStdString(rhs));
}
} // operator()
};
} // namespace std
#endif