36 lines
731 B
C++
36 lines
731 B
C++
#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;
|
|
|
|
private:
|
|
char* m_string { nullptr };
|
|
usize m_length { 0 };
|
|
};
|