Luna/libluna/include/luna/StringView.h

40 lines
577 B
C
Raw Normal View History

2023-03-29 15:43:10 +00:00
#pragma once
#include <luna/Result.h>
class String;
class StringView
{
public:
StringView(const char* c_str);
StringView(const char* c_str, usize length);
StringView();
StringView(const StringView&);
Result<String> to_string();
const char* chars() const
{
return m_string;
}
usize length() const
{
return m_length;
}
bool is_empty() const
{
return m_length == 0;
}
const char& operator[](usize) const;
private:
const char* m_string { nullptr };
usize m_length { 0 };
};