diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-27 09:43:26 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-27 09:43:26 +0100 |
| commit | 6e4007d383ffd910225941a91bbc929a259c8efb (patch) | |
| tree | fcaaa504d812f85e75afb6ec803ee10fe757d152 /Private/CompilerKit/StdKit/String.hpp | |
| parent | 7f07441646bba449d8ca60195c032720ce08aa13 (diff) | |
Strings: Fix destructor, add documentation to APIs.
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 | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/Private/CompilerKit/StdKit/String.hpp b/Private/CompilerKit/StdKit/String.hpp index 0b21b8d..eada24d 100644 --- a/Private/CompilerKit/StdKit/String.hpp +++ b/Private/CompilerKit/StdKit/String.hpp @@ -14,18 +14,33 @@ namespace CompilerKit { + /** + * @brief StringView class, contains a C string and manages it. + * @note No need to manage it it's getting deleted by default. + */ + class StringView final { public: - StringView() = delete; + explicit StringView() = delete; - explicit StringView(SizeType Sz) : m_Sz(Sz) + explicit StringView(SizeType Sz) noexcept + : m_Sz(Sz) { m_Data = new char[Sz]; assert(m_Data); } - ~StringView() = default; + ~StringView() noexcept + { + if (m_Data) + { + memset(m_Data, 0, m_Sz); + delete[] m_Data; + + m_Data = nullptr; + } + } CXXKIT_COPY_DEFAULT(StringView); @@ -61,6 +76,10 @@ namespace CompilerKit }; + /** + * @brief StringBuilder class + * @note These results shall call delete[] after they're used. + */ struct StringBuilder final { static StringView Construct(const CharType *data); |
