diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-27 09:12:14 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-27 09:12:14 +0100 |
| commit | 59a2e775507d01f3ebc8435bf749ab6d3d5b3eeb (patch) | |
| tree | 2061a6494b2cd14b1109030ba9540685cf60a551 /Private/CompilerKit/StdKit/String.hpp | |
| parent | f1746ae6c3e305f1be21c68a79e01f57d6ec911a (diff) | |
Breaking changes: Reworked structure of project.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/CompilerKit/StdKit/String.hpp')
| -rw-r--r-- | Private/CompilerKit/StdKit/String.hpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Private/CompilerKit/StdKit/String.hpp b/Private/CompilerKit/StdKit/String.hpp new file mode 100644 index 0000000..a3d528f --- /dev/null +++ b/Private/CompilerKit/StdKit/String.hpp @@ -0,0 +1,72 @@ +/* + * ======================================================== + * + * CompilerKit + * Copyright 2024, Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include <CompilerKit/Defines.hpp> +#include <CompilerKit/StdKit/ErrorOr.hpp> + +namespace CompilerKit +{ + class StringView final + { + public: + StringView() = delete; + + explicit StringView(SizeType Sz) : m_Sz(Sz) + { + + } + + ~StringView() = default; + + CXXKIT_COPY_DEFAULT(StringView); + + CharType *Data(); + const CharType *CData() const; + SizeType Length() const; + + bool operator==(const CharType *rhs) const; + bool operator!=(const CharType *rhs) const; + + bool operator==(const StringView &rhs) const; + bool operator!=(const StringView &rhs) const; + + StringView &operator+=(const CharType *rhs); + StringView &operator+=(const StringView &rhs); + + operator bool() + { + return m_Data.empty() == false; + } + + bool operator!() + { + return m_Data.empty() == true; + } + + private: + std::basic_string<char> m_Data{""}; + SizeType m_Sz{0}; + SizeType m_Cur{0}; + + friend class StringBuilder; + + }; + + struct StringBuilder final + { + static StringView Construct(const CharType *data); + static const char* FromInt(const char *fmt, int n); + 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); + + }; +} // namespace CompilerKit |
