Luna/libluna/include/luna/OwnedStringView.h
apio 77887eed80
All checks were successful
continuous-integration/drone/push Build is passing
luna -> libluna
2023-02-27 15:22:39 +01:00

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 };
};