Luna/luna/include/luna/OwnedStringView.h
apio be22cf6267
Introduce OwnedStringView
A managed String which uses RAII to free its contents. It's not a proper string though, since it's read-only.
So it's a StringView... but an owned one.

Can't be copied automatically, must be either moved or copied manually by calling clone() on it.
2022-12-16 18:17:15 +01:00

27 lines
446 B
C++

#pragma once
class OwnedStringView
{
public:
OwnedStringView(char* c_str);
OwnedStringView();
OwnedStringView(OwnedStringView&&);
OwnedStringView(const OwnedStringView&) = delete;
~OwnedStringView();
Result<OwnedStringView> clone();
const char* chars()
{
return m_string;
}
usize length()
{
return m_length;
}
private:
char* m_string{nullptr};
usize m_length{0};
};