Luna/libluna/include/luna/OwnedStringView.h

36 lines
731 B
C
Raw Normal View History

#pragma once
#include <luna/Result.h>
class OwnedStringView
{
public:
OwnedStringView(char* c_str);
OwnedStringView(char* c_str, usize length);
OwnedStringView();
OwnedStringView(OwnedStringView&&);
OwnedStringView(const OwnedStringView&) = delete;
~OwnedStringView();
Result<OwnedStringView> clone() const;
Result<OwnedStringView> substring(usize begin, usize size) const;
static Result<OwnedStringView> from_string_literal(const char* str);
const char* chars() const
{
return m_string;
}
usize length() const
{
return m_length;
}
const char& operator[](usize) const;
2022-12-16 19:37:57 +00:00
private:
2022-12-21 19:22:44 +00:00
char* m_string { nullptr };
usize m_length { 0 };
2023-01-02 12:07:29 +00:00
};