8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 06:43:04 +01:00

Added useful JString methods to Firebird::string

This commit is contained in:
alexpeshkoff 2008-04-24 15:44:54 +00:00
parent 5c4efdc6e3
commit 051eae391f
2 changed files with 33 additions and 1 deletions

View File

@ -436,10 +436,34 @@ extern "C" {
}
}
unsigned int AbstractString::hash(const_pointer string, size_t tableSize)
{
unsigned int value = 0;
unsigned char c;
while ((c = *string++))
{
c = toupper(c);
value = value * 11 + c;
}
return value % tableSize;
}
int PathNameComparator::compare(AbstractString::const_pointer s1, AbstractString::const_pointer s2, AbstractString::size_type n)
{
if (CASE_SENSITIVITY)
return memcmp(s1, s2, n);
return STRNCASECMP(s1, s2, n);
}
}
bool AbstractString::equalsNoCase(AbstractString::const_pointer string) const
{
size_t l = strlen(string);
if (l > length())
{
l = length();
}
return STRNCASECMP(c_str(), string, ++l);
}
} // namespace Firebird

View File

@ -414,6 +414,14 @@ namespace Firebird
return toSize;
}
static unsigned int hash(const_pointer string, size_type tableSize);
inline unsigned int hash(size_type tableSize) const
{
return hash(c_str(), tableSize);
}
bool equalsNoCase(const_pointer string) const;
inline ~AbstractString()
{
if (stringBuffer != inlineBuffer)