2022-12-13 20:41:32 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <BAN/Forward.h>
|
|
|
|
#include <BAN/Formatter.h>
|
|
|
|
|
|
|
|
namespace BAN
|
|
|
|
{
|
|
|
|
|
|
|
|
class StringView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using size_type = size_t;
|
|
|
|
|
|
|
|
public:
|
|
|
|
StringView();
|
|
|
|
StringView(const String&);
|
|
|
|
StringView(const char*, size_type = -1);
|
|
|
|
|
|
|
|
char operator[](size_type) const;
|
|
|
|
|
2022-12-13 20:55:09 +02:00
|
|
|
bool operator==(const String&) const;
|
|
|
|
bool operator==(StringView) const;
|
|
|
|
bool operator==(const char*) const;
|
2022-12-13 20:41:32 +02:00
|
|
|
|
|
|
|
StringView Substring(size_type, size_type = -1) const;
|
|
|
|
|
2022-12-20 11:37:28 +02:00
|
|
|
ErrorOr<Vector<StringView>> Split(char, bool = false);
|
2022-12-20 11:50:32 +02:00
|
|
|
ErrorOr<Vector<StringView>> Split(bool(*comp)(char), bool = false);
|
2022-12-13 20:41:32 +02:00
|
|
|
|
|
|
|
size_type Count(char) const;
|
|
|
|
|
|
|
|
bool Empty() const;
|
|
|
|
size_type Size() const;
|
|
|
|
|
|
|
|
const char* Data() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char* m_data = nullptr;
|
|
|
|
size_type m_size = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace BAN::Formatter
|
|
|
|
{
|
|
|
|
|
|
|
|
template<void(*PUTC_LIKE)(char)> void print_argument_impl(const StringView& sv, const ValueFormat&)
|
|
|
|
{
|
|
|
|
for (StringView::size_type i = 0; i < sv.Size(); i++)
|
|
|
|
PUTC_LIKE(sv[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|