Ejemplo n.º 1
0
int LocaleStringComparison::compare(const char *a, size_t a_len, const char *b, size_t b_len) const
{
	size_t ac_off = 0, bc_off = 0;
	if (m_ignore_the)
	{
		if (hasTheWord(a))
			ac_off += 4;
		if (hasTheWord(b))
			bc_off += 4;
	}
	return std::use_facet<std::collate<char>>(m_locale).compare(
		a+ac_off, a+a_len, b+bc_off, b+b_len
	);
}
Ejemplo n.º 2
0
int CaseInsensitiveStringComparison::operator()(const std::string &a, const std::string &b)
{
	const char *i = a.c_str();
	const char *j = b.c_str();
	if (Config.ignore_leading_the)
	{
		if (hasTheWord(a))
			i += 4;
		if (hasTheWord(b))
			j += 4;
	}
	int dist;
	while (!(dist = tolower(*i)-tolower(*j)) && *j)
		++i, ++j;
	return dist;
}
Ejemplo n.º 3
0
int LocaleStringComparison::operator()(const std::string &a, const std::string &b) const
{
	const char *ac = a.c_str();
	const char *bc = b.c_str();
	size_t ac_off = 0, bc_off = 0;
	if (m_ignore_the)
	{
		if (hasTheWord(a))
			ac_off += 4;
		if (hasTheWord(b))
			bc_off += 4;
	}
	return std::use_facet<std::collate<char>>(m_locale).compare(
		ac+ac_off, ac+a.length(), bc+bc_off, bc+b.length()
	);
}