mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Fixed false signature change with multiple extensions
This commit is contained in:
parent
f81a1cf896
commit
fa65029dfa
7 changed files with 155 additions and 8 deletions
|
@ -67,6 +67,24 @@ bool StringView::operator!=(const StringImpl& strB) const
|
|||
return strncmp(this->mPtr, strB.GetPtr(), this->mLength) != 0;
|
||||
}
|
||||
|
||||
bool StringView::StartsWith(const StringView& b, StringView::CompareKind comparisonType) const
|
||||
{
|
||||
if (this->mLength < b.mLength)
|
||||
return false;
|
||||
if (comparisonType == String::CompareKind_OrdinalIgnoreCase)
|
||||
return String::EqualsIgnoreCaseHelper(mPtr, b.mPtr, b.mLength);
|
||||
return String::EqualsHelper(mPtr, b.mPtr, b.mLength);
|
||||
}
|
||||
|
||||
bool StringView::EndsWith(const StringView& b, StringView::CompareKind comparisonType) const
|
||||
{
|
||||
if (this->mLength < b.mLength)
|
||||
return false;
|
||||
if (comparisonType == String::CompareKind_OrdinalIgnoreCase)
|
||||
return String::EqualsIgnoreCaseHelper(this->mPtr + this->mLength - b.mLength, b.mPtr, b.mLength);
|
||||
return String::EqualsHelper(this->mPtr + this->mLength - b.mLength, b.mPtr, b.mLength);
|
||||
}
|
||||
|
||||
intptr StringView::IndexOf(const StringView& subStr, bool ignoreCase) const
|
||||
{
|
||||
for (intptr ofs = 0; ofs <= mLength - subStr.mLength; ofs++)
|
||||
|
|
|
@ -16,6 +16,17 @@ struct StringSplitEnumerator;
|
|||
|
||||
class StringView
|
||||
{
|
||||
public:
|
||||
enum CompareKind
|
||||
{
|
||||
CompareKind_CurrentCulture = 0,
|
||||
CompareKind_CurrentCultureIgnoreCase = 1,
|
||||
CompareKind_InvariantCulture = 2,
|
||||
CompareKind_InvariantCultureIgnoreCase = 3,
|
||||
CompareKind_Ordinal = 4,
|
||||
CompareKind_OrdinalIgnoreCase = 5,
|
||||
};
|
||||
|
||||
public:
|
||||
const char* mPtr;
|
||||
intptr mLength;
|
||||
|
@ -253,6 +264,23 @@ public:
|
|||
return mLength;
|
||||
}
|
||||
|
||||
bool StartsWith(const StringView& b, CompareKind comparisonType = CompareKind_Ordinal) const;
|
||||
bool EndsWith(const StringView& b, CompareKind comparisonType = CompareKind_Ordinal) const;
|
||||
|
||||
bool StartsWith(char c) const
|
||||
{
|
||||
if (this->mLength == 0)
|
||||
return false;
|
||||
return this->mPtr[0] == c;
|
||||
}
|
||||
|
||||
bool EndsWith(char c) const
|
||||
{
|
||||
if (this->mLength == 0)
|
||||
return false;
|
||||
return this->mPtr[this->mLength - 1] == c;
|
||||
}
|
||||
|
||||
intptr IndexOf(const StringView& subStr, bool ignoreCase = false) const;
|
||||
intptr IndexOf(const StringView& subStr, int32 startIdx) const;
|
||||
intptr IndexOf(const StringView& subStr, int64 startIdx) const;
|
||||
|
@ -488,6 +516,8 @@ public:
|
|||
CompareKind_OrdinalIgnoreCase = 5,
|
||||
};
|
||||
|
||||
friend class StringView;
|
||||
|
||||
public:
|
||||
typedef int int_strsize;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue