Проблема с бустом в том, что вы должны связываться с бустом и зависеть от него. Нелегко в некоторых случаях (например, Android).
А использование char_traits означает все ваши сравнения без учета регистра, что обычно не то, что вы хотите.
Этого должно быть достаточно. Это должно быть достаточно эффективным. Не обрабатывает Unicode или что-то еще.
bool iequals(const string& a, const string& b)
{
unsigned int sz = a.size();
if (b.size() != sz)
return false;
for (unsigned int i = 0; i < sz; ++i)
if (tolower(a[i]) != tolower(b[i]))
return false;
return true;
}
Обновление: Бонус C ++ 14 версия (#include <algorithm>
):
bool iequals(const string& a, const string& b)
{
return std::equal(a.begin(), a.end(),
b.begin(), b.end(),
[](char a, char b) {
return tolower(a) == tolower(b);
});
}
I faced a similar problem repeatedly (in my case it was a rollback that was not possible) when I was inside a loop looping over table entries. As long as the cursor is processing the entries, an SQL statement is "in progress". I don't know exactly, if this also prohibits commits, but it could be.
When you try to process table entries and insert entries in the same or a different table, you might want to try to collect the data in memory and after the loop do the inserts or updates.
Addtitional info: "Autocommit" normally defaults to "True" in SQLite (it of course could also depend on the access layer you use -- I am using Python and apsw, so I can't tell you more about this in Java). This means, that every insert is autocommited immediatly.
==> this could be an other solution. Instead of storing the data in memory, you could try to explicitly open a transaction and commit it after the loop -- this way, the problem should go also away.