mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 23:34:10 +02:00
Add methods PadLeft/PadRight and Equals(StringView) to String class
This commit is contained in:
parent
8e543d8cc5
commit
bf9753f8a2
1 changed files with 46 additions and 0 deletions
|
@ -1965,6 +1965,22 @@ namespace System
|
|||
return EqualsIgnoreCaseHelper(a.Ptr, b.Ptr, a.mLength);
|
||||
return EqualsHelper(a.Ptr, b.Ptr, a.mLength);
|
||||
}
|
||||
|
||||
public bool Equals(StringView str)
|
||||
{
|
||||
if (mLength != str.[Friend]mLength)
|
||||
return false;
|
||||
return EqualsHelper(str.Ptr, mPtr, mLength);
|
||||
}
|
||||
|
||||
public bool Equals(StringView str, StringComparison comparisonType = StringComparison.Ordinal)
|
||||
{
|
||||
if (mLength != str.[Friend]mLength)
|
||||
return false;
|
||||
if (comparisonType == StringComparison.OrdinalIgnoreCase)
|
||||
return EqualsIgnoreCaseHelper(str.Ptr, mPtr, mLength);
|
||||
return EqualsHelper(str.Ptr, mPtr, mLength);
|
||||
}
|
||||
|
||||
public bool StartsWith(StringView b, StringComparison comparisonType = StringComparison.Ordinal)
|
||||
{
|
||||
|
@ -2278,6 +2294,36 @@ namespace System
|
|||
TrimStart((.)trimChar);
|
||||
TrimEnd((.)trimChar);
|
||||
}
|
||||
|
||||
public void PadLeft(int totalWidth, char8 paddingChar)
|
||||
{
|
||||
Insert(0, paddingChar, totalWidth - Length);
|
||||
}
|
||||
|
||||
public void PadLeft(int totalWidth, char32 paddingChar)
|
||||
{
|
||||
Insert(0, paddingChar, totalWidth - Length);
|
||||
}
|
||||
|
||||
public void PadLeft(int totalWidth)
|
||||
{
|
||||
Insert(0, ' ', totalWidth - Length);
|
||||
}
|
||||
|
||||
public void PadRight(int totalWidth, char8 paddingChar)
|
||||
{
|
||||
Append(paddingChar, totalWidth - Length);
|
||||
}
|
||||
|
||||
public void PadRight(int totalWidth, char32 paddingChar)
|
||||
{
|
||||
Append(paddingChar, totalWidth - Length);
|
||||
}
|
||||
|
||||
public void PadRight(int totalWidth)
|
||||
{
|
||||
Append(' ', totalWidth - Length);
|
||||
}
|
||||
|
||||
public void Join(StringView sep, IEnumerator<String> enumerable)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue