summaryrefslogtreecommitdiffhomepage
path: root/CompilerKit/StdKit/String.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-04 21:36:54 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-04 21:48:09 +0100
commit6cda526bd4efcee31b1ea7405dc46d7985ba64e6 (patch)
treef7d138fd5652cdc0e7a2c4918b36d754969d6cf5 /CompilerKit/StdKit/String.hpp
parent60271b79a91a06772241aed737426f5d097ca533 (diff)
masm: fix assembler bug where addr1, 0x0 (add r1, 0x0) doesn't error
out. cc/ccplus: minor compiler changes, will get to them very soon... refactor: rename C++Kit to CompilerKit. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'CompilerKit/StdKit/String.hpp')
-rw-r--r--CompilerKit/StdKit/String.hpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/CompilerKit/StdKit/String.hpp b/CompilerKit/StdKit/String.hpp
new file mode 100644
index 0000000..592c244
--- /dev/null
+++ b/CompilerKit/StdKit/String.hpp
@@ -0,0 +1,72 @@
+/*
+ * ========================================================
+ *
+ * CompilerKit
+ * Copyright Western Company, 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