void StringIteratorTest::constIteratorStdCopyTest() { QString source; QString destination; StringConstIterator first, last; source = "abcd"; destination.clear(); first = source.cbegin(); last = source.cend(); std::copy( first, last, std::back_inserter(destination) ); QCOMPARE(destination, source); source = "éöàäèü$£"; destination.clear(); first = source.cbegin(); last = source.cend(); std::copy( first, last, std::back_inserter(destination) ); QCOMPARE(destination, source); }
bool Address::validateFragment(const QString& s) { // TODO refactor with ExpressionParser.cpp (auto base = +qi::char_("a-zA-Z0-9_~().-");) return std::all_of(s.cbegin(), s.cend(), [] (auto uc) { auto c = uc.toLatin1(); return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (c == '.') || (c == '~') || (c == '_') || (c == '(') || (c == ')') || (c == '-') ; }); }
void StringIteratorTest::constIteratorBenchmark() { QString source = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; std::vector<wchar_t> destination; destination.reserve(source.size()); QBENCHMARK { destination.clear(); StringConstIterator first(source.cbegin()); StringConstIterator last(source.cend()); while(first != last){ destination.push_back(*first); ++first; } } QCOMPARE((int)destination.size(), source.size()); }
bool OsmAnd::Utilities::extractFirstNumberPosition(const QString& value, int& first, int& last, bool allowSigned, bool allowDot) { first = -1; last = -1; int curPos = 0; for(auto itChr = value.cbegin(); itChr != value.cend() && (first == -1 || last == -1); ++itChr, curPos++) { auto chr = *itChr; if (first == -1 && chr.isDigit()) first = curPos; if (last == -1 && first != -1 && !chr.isDigit() && ((allowDot && chr != '.') || !allowDot)) last = curPos - 1; } if (first >= 1 && allowSigned && value[first - 1] == '-') first -= 1; if (first != -1 && last == -1) last = value.length() - 1; return first != -1; }