ParsingUtilities.h [plain text]
#pragma once
#include <wtf/text/StringCommon.h>
namespace WebCore {
inline bool isNotASCIISpace(UChar c)
{
return !isASCIISpace(c);
}
template<typename CharType>
bool skipExactly(const CharType*& position, const CharType* end, CharType delimiter)
{
if (position < end && *position == delimiter) {
++position;
return true;
}
return false;
}
template<typename CharType, bool characterPredicate(CharType)>
bool skipExactly(const CharType*& position, const CharType* end)
{
if (position < end && characterPredicate(*position)) {
++position;
return true;
}
return false;
}
template<typename CharType>
void skipUntil(const CharType*& position, const CharType* end, CharType delimiter)
{
while (position < end && *position != delimiter)
++position;
}
template<typename CharType, bool characterPredicate(CharType)>
void skipUntil(const CharType*& position, const CharType* end)
{
while (position < end && !characterPredicate(*position))
++position;
}
template<typename CharType, bool characterPredicate(CharType)>
void skipWhile(const CharType*& position, const CharType* end)
{
while (position < end && characterPredicate(*position))
++position;
}
template<typename CharType, bool characterPredicate(CharType)>
void reverseSkipWhile(const CharType*& position, const CharType* start)
{
while (position >= start && characterPredicate(*position))
--position;
}
template<typename CharacterType, unsigned lowercaseLettersLength>
bool skipExactlyIgnoringASCIICase(const CharacterType*& position, const CharacterType* end, const char (&lowercaseLetters)[lowercaseLettersLength])
{
if (position + lowercaseLettersLength > end)
return false;
bool result = WTF::equalLettersIgnoringASCIICase(position, lowercaseLettersLength - 1, lowercaseLetters);
if (result)
position += (lowercaseLettersLength - 1);
return result;
}
}