|
|
|
@ -44,12 +44,39 @@ public:
|
|
|
|
|
{
|
|
|
|
|
return mpData[i];
|
|
|
|
|
}
|
|
|
|
|
bool operator<(const StringView& right) const
|
|
|
|
|
{
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
while (i < mSize && i < right.mSize && mpData[i] == right.mpData[i])
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
return mpData[i] < right.mpData[i];
|
|
|
|
|
}
|
|
|
|
|
size_t size() {
|
|
|
|
|
return mSize;
|
|
|
|
|
}
|
|
|
|
|
StringView substr(size_t pos, size_t count) {
|
|
|
|
|
if (pos > mSize)
|
|
|
|
|
throw std::out_of_range("Error! Index is out of bounds.");
|
|
|
|
|
if (pos + count > mSize)
|
|
|
|
|
count = mSize - pos;
|
|
|
|
|
StringView result;
|
|
|
|
|
result.mpData = mpData + pos;
|
|
|
|
|
result.mSize = count;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
void remove_prefix(size_t n) {
|
|
|
|
|
mSize -= n;
|
|
|
|
|
}
|
|
|
|
|
void remove_suffix(size_t n) {
|
|
|
|
|
mSize -= n;
|
|
|
|
|
mpData += n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& out, mipt::StringView sv) {
|
|
|
|
|
size_t size = sv.size();
|
|
|
|
|