From 59a2e775507d01f3ebc8435bf749ab6d3d5b3eeb Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 27 Jan 2024 09:12:14 +0100 Subject: Breaking changes: Reworked structure of project. Signed-off-by: Amlal El Mahrouss --- Private/CompilerKit/StdKit/String.hpp | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Private/CompilerKit/StdKit/String.hpp (limited to 'Private/CompilerKit/StdKit/String.hpp') 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 +#include + +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 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 -- cgit v1.2.3