diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-29 10:51:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-29 10:51:53 +0200 |
| commit | 5c0bb7ee7b1b0fee02cc179fb21f4c57a61d6c2d (patch) | |
| tree | cb17577bcdc9714c97a84ce417a075117097f146 /dev/kernel/NewKit/KString.h | |
| parent | d608230b1350b064ceb01e6572519b108f6139b0 (diff) | |
| parent | 3167f59dbb401d6a79b1524537e04218baf49ee3 (diff) | |
Merge pull request #32 from nekernel-org/dev
0.0.2e3
Diffstat (limited to 'dev/kernel/NewKit/KString.h')
| -rw-r--r-- | dev/kernel/NewKit/KString.h | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/dev/kernel/NewKit/KString.h b/dev/kernel/NewKit/KString.h deleted file mode 100644 index 08f783c0..00000000 --- a/dev/kernel/NewKit/KString.h +++ /dev/null @@ -1,82 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include <CompilerKit/CompilerKit.h> -#include <NewKit/Defines.h> -#include <NewKit/ErrorOr.h> -#include <NewKit/KernelPanic.h> -#include <NewKit/Utils.h> - -#define kMinimumStringSize (8196U) - -namespace Kernel { -/// @brief Kernel string class, not dynamic. -class KString final { - public: - explicit KString() { - fDataSz = kMinimumStringSize; - - fData = new Char[fDataSz]; - MUST_PASS(fData); - - rt_set_memory(fData, 0, fDataSz); - } - - explicit KString(SizeT Sz) : fDataSz(Sz) { - MUST_PASS(Sz > 1); - - fData = new Char[Sz]; - MUST_PASS(fData); - - rt_set_memory(fData, 0, Sz); - } - - ~KString() { - if (fData) { - delete[] fData; - fData = nullptr; - } - } - - NE_COPY_DEFAULT(KString) - - Char* Data(); - const Char* CData() const; - Size Length() const; - - bool operator==(const Char* rhs) const; - bool operator!=(const Char* rhs) const; - - bool operator==(const KString& rhs) const; - bool operator!=(const KString& rhs) const; - - KString& operator+=(const Char* rhs); - KString& operator+=(const KString& rhs); - - operator bool() { return fData; } - - bool operator!() { return fData; } - - private: - Char* fData{nullptr}; - Size fDataSz{0}; - Size fCur{0}; - - friend class KStringBuilder; -}; - -class KStringBuilder final { - public: - static ErrorOr<KString> Construct(const Char* data); - static const Char* FromBool(const Char* fmt, bool n); - static const Char* Format(const Char* fmt, const Char* from); - static bool Equals(const Char* lhs, const Char* rhs); - static bool Equals(const Utf8Char* lhs, const Utf8Char* rhs); - static bool Equals(const WideChar* lhs, const WideChar* rhs); -}; -} // namespace Kernel |
