forked from qt-creator/qt-creator
Utils: Add startWith to string view
We will add more function if they are needed. Change-Id: Iac6b432327be32a0778a82c23ed2de5996c555a1 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -116,6 +116,19 @@ public:
|
||||
return std::string(data(), size());
|
||||
}
|
||||
|
||||
bool startsWith(SmallStringView subStringToSearch) const noexcept
|
||||
{
|
||||
if (size() >= subStringToSearch.size())
|
||||
return !std::memcmp(m_pointer, subStringToSearch.data(), subStringToSearch.size());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool startsWith(char characterToSearch) const noexcept
|
||||
{
|
||||
return m_pointer[0] == characterToSearch;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *m_pointer;
|
||||
size_type m_size;
|
||||
|
||||
Reference in New Issue
Block a user