New StringView function: SpanWhile
This commit is contained in:
parent
10be4dfbbf
commit
a30f259121
2 changed files with 10 additions and 0 deletions
|
@ -132,6 +132,15 @@ StringView StringView_TakeWhile(StringView string, StringViewContinue function)
|
||||||
return StringView_Take(string, length);
|
return StringView_Take(string, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringView StringView_SpanWhile(StringView* source, StringViewContinue function)
|
||||||
|
{
|
||||||
|
StringView result = StringView_TakeWhile(*source, function);
|
||||||
|
|
||||||
|
*source = StringView_Slice(*source, result.length, source->length);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
StringView StringView_Take(StringView string, size_t length)
|
StringView StringView_Take(StringView string, size_t length)
|
||||||
{
|
{
|
||||||
return StringView_Slice(string, 0, length);
|
return StringView_Slice(string, 0, length);
|
||||||
|
|
|
@ -50,6 +50,7 @@ StringView StringView_Slice(StringView string, size_t start, size_t end); // sta
|
||||||
StringView StringView_Drop(StringView string, size_t length);
|
StringView StringView_Drop(StringView string, size_t length);
|
||||||
StringView StringView_Take(StringView string, size_t length);
|
StringView StringView_Take(StringView string, size_t length);
|
||||||
StringView StringView_TakeWhile(StringView string, StringViewContinue function);
|
StringView StringView_TakeWhile(StringView string, StringViewContinue function);
|
||||||
|
StringView StringView_SpanWhile(StringView* source, StringViewContinue function);
|
||||||
|
|
||||||
bool StringView_Partition(StringView* left, StringView* right, StringView source, StringView delim);
|
bool StringView_Partition(StringView* left, StringView* right, StringView source, StringView delim);
|
||||||
bool StringView_NextSplit(StringView* dest, StringView* source, StringView delim);
|
bool StringView_NextSplit(StringView* dest, StringView* source, StringView delim);
|
||||||
|
|
Loading…
Reference in a new issue