From 1d357adfa19725ee69fb267a363f1fd217b1272f Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sat, 4 Jan 2025 12:02:45 -0600 Subject: Various style fixes. --- include/fud_string.hpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include/fud_string.hpp') diff --git a/include/fud_string.hpp b/include/fud_string.hpp index a20b067..4b3dbe2 100644 --- a/include/fud_string.hpp +++ b/include/fud_string.hpp @@ -31,6 +31,7 @@ #include #include +// NOLINTNEXTLINE(readability-magic-numbers) static_assert(CHAR_BIT == 8); /** @file */ @@ -132,6 +133,7 @@ class String { if constexpr (std::is_same_v) { cString = cStringItem; } else if constexpr (std::is_same_v) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) cString = reinterpret_cast(cStringItem); } else { static_assert(!std::is_same_v); @@ -155,6 +157,7 @@ class String { fudAssert(totalLength < maxStringLength); String output{}; + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) output.m_allocator = reinterpret_cast(allocator); utf8* data{nullptr}; size_t outputCapacity = totalLength + 1; @@ -208,6 +211,8 @@ class String { */ String& operator=(String&& rhs) noexcept; + static StringResult withAllocator(Allocator& allocator); + /** \brief Create a String by copying from an existing rhs, optionally * specifying a different allocator. If allocatorOption is NullOpt, the * allocator from rhs is used. @@ -269,12 +274,13 @@ class String { } /** \brief The underlying data as an explicit c string. */ - [[nodiscard]] inline const char* c_str() const + [[nodiscard]] const char* c_str() const { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) return reinterpret_cast(data()); } - [[nodiscard]] inline StringView asView() const + [[nodiscard]] StringView asView() const { return StringView(*this); } @@ -336,9 +342,9 @@ class String { FudStatus clear(); - const utf8* begin() const; + [[nodiscard]] const utf8* begin() const; - const utf8* end() const; + [[nodiscard]] const utf8* end() const; private: static constexpr size_t maxStringLength = (static_cast(1) << 63) - 1; @@ -349,11 +355,13 @@ class String { [[nodiscard]] static bool allocatorValid(Allocator* allocator) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) return (reinterpret_cast(allocator) & isLargeMask) == 0; } - Allocator* allocator() const + [[nodiscard]] Allocator* allocator() const { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast,performance-no-int-to-ptr) auto* allocPtr = reinterpret_cast(m_allocator & allocatorMask); fudAssert(allocPtr != nullptr); return allocPtr; @@ -380,6 +388,7 @@ class String { /** \brief The allocator used to get storage for characters when the string * is large. */ + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) uintptr_t m_allocator{reinterpret_cast(&globalFudAllocator)}; using BufType = Array; -- cgit v1.2.3