2023-06-21 14:42:23 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-11-02 20:23:28 -07:00
|
|
|
#include "glacier/string/string_view.h"
|
|
|
|
|
2023-06-21 14:42:23 -07:00
|
|
|
namespace glcr {
|
|
|
|
|
|
|
|
class String {
|
|
|
|
public:
|
2023-10-13 15:03:35 -07:00
|
|
|
String();
|
2023-06-21 14:42:23 -07:00
|
|
|
String(const char* cstr);
|
2023-07-06 10:40:36 -07:00
|
|
|
String(const char* cstr, uint64_t str_len);
|
2023-11-02 20:23:28 -07:00
|
|
|
String(StringView str);
|
2023-06-21 14:42:23 -07:00
|
|
|
|
2023-11-19 19:14:37 -08:00
|
|
|
String(const String&) = delete;
|
|
|
|
|
2023-06-22 02:18:44 -07:00
|
|
|
const char* cstr() const { return cstr_; }
|
|
|
|
uint64_t length() const { return length_; }
|
|
|
|
|
2023-06-21 14:42:23 -07:00
|
|
|
bool operator==(const String& str);
|
|
|
|
|
2023-10-24 12:34:52 -07:00
|
|
|
char operator[](uint64_t offset) const;
|
2023-11-19 19:14:37 -08:00
|
|
|
|
2023-11-02 20:23:28 -07:00
|
|
|
operator StringView() const;
|
2023-11-19 19:14:37 -08:00
|
|
|
StringView view() const;
|
2023-10-24 12:34:52 -07:00
|
|
|
|
2023-06-21 14:42:23 -07:00
|
|
|
private:
|
|
|
|
char* cstr_;
|
|
|
|
uint64_t length_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace glcr
|