From 825b4f09ca6f551551c4f3be5d72517eab504860 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 2 Dec 2025 15:57:26 -0500 Subject: chore: new Kernel API for KString, ArrayList and ErrorOr. Signed-off-by: Amlal El Mahrouss --- src/kernel/NeKit/KString.inl | 51 +++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'src/kernel/NeKit/KString.inl') diff --git a/src/kernel/NeKit/KString.inl b/src/kernel/NeKit/KString.inl index 3a73e90f..70380ebe 100644 --- a/src/kernel/NeKit/KString.inl +++ b/src/kernel/NeKit/KString.inl @@ -18,23 +18,24 @@ inline void ort_string_append(CharKind* lhs, const CharKind* rhs, Int32 cur) { } } -template -inline CharKind* KBasicString::Data() { +template +inline CharKind* KBasicString::Data() { return this->fData; } -template -inline const CharKind* KBasicString::CData() const { +template +inline const CharKind* KBasicString::CData() const { return const_cast(this->fData); } -template -inline SizeT KBasicString::Length() const { +template +inline SizeT KBasicString::Length() const { return this->fDataSz; } -template -inline bool KBasicString::operator==(const KBasicString& rhs) const { +template +inline bool KBasicString::operator==( + const KBasicString& rhs) const { if (rhs.Length() != this->Length()) return false; for (Size index = 0; index < this->Length(); ++index) { @@ -44,8 +45,8 @@ inline bool KBasicString::operator==(const KBasicString& rhs return true; } -template -inline bool KBasicString::operator==(const CharKind* rhs) const { +template +inline bool KBasicString::operator==(const CharKind* rhs) const { if (oe_string_len(rhs) != this->Length()) return false; for (Size index = 0; index < oe_string_len(rhs); ++index) { @@ -55,8 +56,9 @@ inline bool KBasicString::operator==(const CharKind* rhs) const { return true; } -template -inline bool KBasicString::operator!=(const KBasicString& rhs) const { +template +inline bool KBasicString::operator!=( + const KBasicString& rhs) const { if (rhs.Length() != this->Length()) return false; for (Size index = 0; index < rhs.Length(); ++index) { @@ -66,8 +68,8 @@ inline bool KBasicString::operator!=(const KBasicString& rhs return true; } -template -inline bool KBasicString::operator!=(const CharKind* rhs) const { +template +inline bool KBasicString::operator!=(const CharKind* rhs) const { if (oe_string_len(rhs) != this->Length()) return false; for (Size index = 0; index < oe_string_len(rhs); ++index) { @@ -77,9 +79,9 @@ inline bool KBasicString::operator!=(const CharKind* rhs) const { return true; } -template -inline KBasicString& KBasicString::operator+=( - const KBasicString& rhs) { +template +inline KBasicString& KBasicString::operator+=( + const KBasicString& rhs) { if (oe_string_len(rhs.fData) > this->Length()) return *this; ort_string_append(this->fData, const_cast(rhs.fData), this->fCur); @@ -88,22 +90,23 @@ inline KBasicString& KBasicString::operator+=( return *this; } -template -inline KBasicString& KBasicString::operator+=(const CharKind* rhs) { +template +inline KBasicString& KBasicString::operator+=( + const CharKind* rhs) { ort_string_append(this->fData, const_cast(rhs), this->fCur); this->fCur += oe_string_len(const_cast(rhs)); return *this; } -template -inline ErrorOr> KStringBuilder::Construct(const CharKind* data) { - if (!data || *data == 0) return ErrorOr>(nullptr); +template +inline ErrorOr> KStringBuilder::Construct(const CharKind* data) { + if (!data || *data == 0) return ErrorOr>(-kErrorInvalidData); - KBasicString* view = new KBasicString(oe_string_len(data)); + KBasicString* view = new KBasicString(oe_string_len(data)); (*view) += data; - return ErrorOr>(*view); + return ErrorOr>(*view); } template inline const CharKind* KStringBuilder::FromBool(const CharKind* fmt, bool i) { -- cgit v1.2.3