see CHANGELOG

- added Poco::istring (case-insensitive string) and Poco::isubstr
(case-insensitive substring search)
- improved SQLite execute() return (affected rows) value
- added SQLite sys.dual (in-memory system table)
- applied SF Patch #120: The ExpireLRUCache does not compile with a
tuple as key on Visual Studio 2010
- fixed SF Bug #599: JSON::Array and JSON::Object size() member can
implicitly lose precision
- fixed SF Bug #602: iterating database table rows not correct if no
data in table
- fixed SF Bug #603: count() is missing in HashMap
- fixed GH #23: JSON::Object::stringify throw BadCastException
- fixed GH #16: NetworkInterface::firstAddress() should not throw on
unconfigured interfaces
- Android compile/build support (by Rangel Reale)
- TypeHandler::prepare() now takes const-reference
This commit is contained in:
aleks-f
2012-12-04 23:33:44 -06:00
parent 1138f439af
commit eaa74307a6
19 changed files with 473 additions and 255 deletions

View File

@@ -43,6 +43,7 @@
#include "Poco/Foundation.h"
#include "Poco/Ascii.h"
#include <cstring>
#include <locale>
namespace Poco {
@@ -642,6 +643,64 @@ S cat(const S& delim, const It& begin, const It& end)
}
//
// case-insensitive string equality
//
template <typename charT>
struct i_char_traits : public std::char_traits<charT>
{
static bool eq(charT c1, charT c2)
{
return Ascii::toLower(c1) == Ascii::toLower(c2);
}
static bool ne(charT c1, charT c2)
{
return !eq(c1, c2);
}
static bool lt(charT c1, charT c2)
{
return Ascii::toLower(c1) < Ascii::toLower(c2);
}
static int compare(const charT* s1, const charT* s2, size_t n)
{
for (int i = 0; i < n && s1 && s2; ++i, ++s1, ++s2)
{
if (Ascii::toLower(*s1) == Ascii::toLower(*s2)) continue;
else if (Ascii::toLower(*s1) < Ascii::toLower(*s2)) return -1;
else return 1;
}
return 0;
}
static const charT* find(const charT* s, int n, charT a)
{
while(n-- > 0 && Ascii::toLower(*s) != Ascii::toLower(a)) { ++s; }
return s;
}
};
typedef std::basic_string<char, i_char_traits<char> > istring;
template<typename T>
int isubstr(const T& str, const T& sought)
{
typename T::const_iterator it = std::search(str.begin(), str.end(),
sought.begin(), sought.end(),
i_char_traits<typename T::value_type>::eq);
if (it != str.end()) return it - str.begin();
else return T::npos;
}
} // namespace Poco