1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:37:34 +00:00

AK: Try to use StringViews more for substrings and splitting.

This commit is contained in:
Andreas Kling 2019-04-16 02:39:16 +02:00
parent a082738f04
commit 33920df299
9 changed files with 133 additions and 13 deletions

View file

@ -1,5 +1,11 @@
#pragma once
#include <AK/Vector.h>
namespace AK {
class String;
class StringView {
public:
StringView() { }
@ -19,7 +25,20 @@ public:
int length() const { return m_length; }
char operator[](int index) const { return m_characters[index]; }
StringView substring_view(int start, int length) const;
Vector<StringView> split_view(char) const;
unsigned to_uint(bool& ok) const;
bool operator==(const char* cstring) const { return !strcmp(m_characters, cstring); }
bool operator!=(const char* cstring) const { return strcmp(m_characters, cstring); }
bool operator==(const String&) const;
private:
const char* m_characters { nullptr };
int m_length { 0 };
};
}
using AK::StringView;