From 91847f04a552098883541d2c4ab5d0a05120c8f5 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 27 Feb 2023 19:48:51 -0400 Subject: TArray: Add some extra functions --- context.h | 18 ++++++++++++++++++ include/pso/TArray.h | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/context.h b/context.h index 007aa61..de848b6 100644 --- a/context.h +++ b/context.h @@ -178,15 +178,33 @@ public: return m_data[i]; }; + T *start() { + return m_data; + }; + + T *end() { + return &m_data[size()-1]; + }; + template T2 *as() { return reinterpret_cast(m_data); }; + template + TArray &to() { + typedef TArray to_type; + return reinterpret_cast(*this); + }; + u8 *as_bytes() { return reinterpret_cast(m_data); }; + void fill(u8 val) { + memset(m_data, val, byte_size()); + }; + void fill_with(u8 val) { _fill_with(val); }; diff --git a/include/pso/TArray.h b/include/pso/TArray.h index fb7a903..29dc01e 100644 --- a/include/pso/TArray.h +++ b/include/pso/TArray.h @@ -27,15 +27,33 @@ public: return m_data[i]; }; + T *start() { + return m_data; + }; + + T *end() { + return &m_data[size()-1]; + }; + template T2 *as() { return reinterpret_cast(m_data); }; + template + TArray &to() { + typedef TArray to_type; + return reinterpret_cast(*this); + }; + u8 *as_bytes() { return reinterpret_cast(m_data); }; + void fill(u8 val) { + memset(m_data, val, byte_size()); + }; + void fill_with(u8 val) { _fill_with(val); }; -- cgit v1.2.3-13-gbd6f