forked from qt-creator/qt-creator
34 lines
592 B
C++
34 lines
592 B
C++
|
|
#include "PPToken.h"
|
||
|
|
|
||
|
|
#include <cstring>
|
||
|
|
|
||
|
|
using namespace CPlusPlus::Internal;
|
||
|
|
|
||
|
|
bool ByteArrayRef::startsWith(const char *s) const
|
||
|
|
{
|
||
|
|
int l = std::strlen(s);
|
||
|
|
if (l > m_length)
|
||
|
|
return false;
|
||
|
|
return !qstrncmp(start(), s, l);
|
||
|
|
}
|
||
|
|
|
||
|
|
int ByteArrayRef::count(char ch) const
|
||
|
|
{
|
||
|
|
int num = 0;
|
||
|
|
const char *b = start();
|
||
|
|
const char *i = b + m_length;
|
||
|
|
while (i != b)
|
||
|
|
if (*--i == ch)
|
||
|
|
++num;
|
||
|
|
return num;
|
||
|
|
}
|
||
|
|
|
||
|
|
void PPToken::squeeze()
|
||
|
|
{
|
||
|
|
if (isValid()) {
|
||
|
|
m_src = m_src.mid(offset, length());
|
||
|
|
m_src.squeeze();
|
||
|
|
offset = 0;
|
||
|
|
}
|
||
|
|
}
|