mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-22 02:45:49 -04:00
add begin and end to gd::vector
This commit is contained in:
parent
342bbb3622
commit
9e38af5070
2 changed files with 17 additions and 16 deletions
loader
|
@ -16,9 +16,9 @@ namespace geode::base {
|
|||
#if defined(GEODE_IS_MACOS) || defined(GEODE_IS_ANDROID)
|
||||
namespace gd {
|
||||
struct _internal_string {
|
||||
uintptr_t m_len;
|
||||
uintptr_t m_capacity;
|
||||
int m_refcount;
|
||||
size_t m_len;
|
||||
size_t m_capacity;
|
||||
int m_refcount;
|
||||
};
|
||||
|
||||
class GEODE_DLL string {
|
||||
|
@ -26,18 +26,17 @@ namespace gd {
|
|||
string();
|
||||
string(char const* ok);
|
||||
string(std::string ok) : string(ok.c_str()) {}
|
||||
operator std::string() {
|
||||
return std::string((char*)m_data, m_data[-1].m_len);
|
||||
}
|
||||
operator std::string() const {
|
||||
return std::string((char*)m_data, m_data[-1].m_len);
|
||||
}
|
||||
bool operator==(string const& other) const;
|
||||
string(string const& ok);
|
||||
string& operator=(char const* ok);
|
||||
string& operator=(string const& ok);
|
||||
__attribute__((noinline)) ~string();
|
||||
char const* c_str() const {return (char const*)m_data; }
|
||||
protected:
|
||||
char const* c_str() const { return (char const*)m_data; }
|
||||
size_t size() const { return m_data[-1].m_len; }
|
||||
protected:
|
||||
_internal_string* m_data;
|
||||
};
|
||||
|
||||
|
@ -285,14 +284,6 @@ namespace gd {
|
|||
public:
|
||||
using value_type = T;
|
||||
|
||||
operator std::vector<T>() {
|
||||
std::vector<T> out;
|
||||
|
||||
for (auto i = m_start; i != m_finish; ++i) {
|
||||
out.push_back(*i);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
operator std::vector<T>() const {
|
||||
std::vector<T> out;
|
||||
|
||||
|
@ -317,6 +308,11 @@ namespace gd {
|
|||
T& front() {
|
||||
return *m_start;
|
||||
}
|
||||
|
||||
auto begin() { return m_start; }
|
||||
auto end() { return m_finish; }
|
||||
auto begin() const { return static_cast<const T*>(m_start); }
|
||||
auto end() const { return static_cast<const T*>(m_finish); }
|
||||
|
||||
vector(vector const& lol) : vector(std::vector<T>(lol)) {}
|
||||
|
||||
|
|
|
@ -35,6 +35,11 @@ namespace gd {
|
|||
reinterpret_cast<void(*)(_internal_string*, void*)>(geode::base::get() + 0x489f78)(&m_data[-1], al);
|
||||
}
|
||||
}
|
||||
bool string::operator==(string const& other) const {
|
||||
if (size() != other.size()) return false;
|
||||
return strcmp(c_str(), other.c_str()) == 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue