Luna/libluna/include/luna/StringView.h
apio d68f6bd76b
All checks were successful
continuous-integration/drone/push Build is passing
ArgumentParser+ls: Add switch arguments
2023-03-29 19:25:11 +02:00

55 lines
843 B
C++

#pragma once
#include <luna/Result.h>
class String;
class StringView
{
typedef const char* Iterator;
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;
bool operator==(const char* other) const;
bool operator==(StringView other) const;
Iterator begin() const
{
return m_string;
}
Iterator end() const
{
return m_string + m_length;
}
private:
const char* m_string { nullptr };
usize m_length { 0 };
};