Core/StringExt: Don't pass string_view by ref

https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/
This commit is contained in:
SirLynix 2023-08-24 08:23:14 +02:00
parent 1b7a89213d
commit bd53245f42
51 changed files with 115 additions and 115 deletions

View File

@ -26,7 +26,7 @@ namespace Nz
template<typename T> ByteArray ComputeHash(HashType hash, T&& v); template<typename T> ByteArray ComputeHash(HashType hash, T&& v);
template<typename T> ByteArray ComputeHash(AbstractHash& hash, T&& v); template<typename T> ByteArray ComputeHash(AbstractHash& hash, T&& v);
inline bool HashAppend(AbstractHash* hash, const std::string_view& v); inline bool HashAppend(AbstractHash* hash, std::string_view v);
template<typename T> template<typename T>
bool Serialize(SerializationContext& context, T&& value); bool Serialize(SerializationContext& context, T&& value);

View File

@ -57,7 +57,7 @@ namespace Nz
return hash.End(); return hash.End();
} }
inline bool HashAppend(AbstractHash& hash, const std::string_view& v) inline bool HashAppend(AbstractHash& hash, std::string_view v)
{ {
hash.Append(reinterpret_cast<const UInt8*>(v.data()), v.size()); hash.Append(reinterpret_cast<const UInt8*>(v.data()), v.size());
return true; return true;

View File

@ -43,8 +43,8 @@ namespace Nz
template<typename... Args> static void Write(std::string_view str, Args&&... args); template<typename... Args> static void Write(std::string_view str, Args&&... args);
static void WriteError(ErrorType type, std::string_view error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr); static void WriteError(ErrorType type, std::string_view error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
NazaraStaticSignal(OnLogWrite, const std::string_view& /*string*/); NazaraStaticSignal(OnLogWrite, std::string_view /*string*/);
NazaraStaticSignal(OnLogWriteError, ErrorType /*type*/, const std::string_view& /*error*/, unsigned int /*line*/, const char* /*file*/, const char* /*function*/); NazaraStaticSignal(OnLogWriteError, ErrorType /*type*/, std::string_view /*error*/, unsigned int /*line*/, const char* /*file*/, const char* /*function*/);
private: private:
static bool Initialize(); static bool Initialize();

View File

@ -43,7 +43,7 @@ namespace Nz
void Clear(); void Clear();
bool IsExtensionSupported(const std::string_view& extension) const; bool IsExtensionSupported(std::string_view extension) const;
std::shared_ptr<Type> LoadFromFile(const std::filesystem::path& filePath, const Parameters& parameters = Parameters()) const; std::shared_ptr<Type> LoadFromFile(const std::filesystem::path& filePath, const Parameters& parameters = Parameters()) const;
std::shared_ptr<Type> LoadFromMemory(const void* data, std::size_t size, const Parameters& parameters = Parameters()) const; std::shared_ptr<Type> LoadFromMemory(const void* data, std::size_t size, const Parameters& parameters = Parameters()) const;

View File

@ -34,7 +34,7 @@ namespace Nz
* \param extension Extension of the file (ex: ".png") * \param extension Extension of the file (ex: ".png")
*/ */
template<typename Type, typename Parameters> template<typename Type, typename Parameters>
bool ResourceLoader<Type, Parameters>::IsExtensionSupported(const std::string_view& extension) const bool ResourceLoader<Type, Parameters>::IsExtensionSupported(std::string_view extension) const
{ {
NazaraAssert(extension.size() >= 2 || extension.front() != '.', "extension should start with a ."); NazaraAssert(extension.size() >= 2 || extension.front() != '.', "extension should start with a .");

View File

@ -29,7 +29,7 @@ namespace Nz
public: public:
struct Entry; struct Entry;
using FormatSupport = std::function<bool(const std::string_view& format)>; using FormatSupport = std::function<bool(std::string_view format)>;
using FileSaver = std::function<bool(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters)>; using FileSaver = std::function<bool(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters)>;
using StreamSaver = std::function<bool(const Type& resource, const std::string& format, Stream& stream, const Parameters& parameters)>; using StreamSaver = std::function<bool(const Type& resource, const std::string& format, Stream& stream, const Parameters& parameters)>;
@ -40,7 +40,7 @@ namespace Nz
void Clear(); void Clear();
bool IsExtensionSupported(const std::string_view& extension) const; bool IsExtensionSupported(std::string_view extension) const;
bool SaveToFile(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters = Parameters()) const; bool SaveToFile(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters = Parameters()) const;
bool SaveToStream(const Type& resource, Stream& stream, const std::string& format, const Parameters& parameters = Parameters()) const; bool SaveToStream(const Type& resource, Stream& stream, const std::string& format, const Parameters& parameters = Parameters()) const;

View File

@ -34,7 +34,7 @@ namespace Nz
* \param extension Extension of the file * \param extension Extension of the file
*/ */
template<typename Type, typename Parameters> template<typename Type, typename Parameters>
bool ResourceSaver<Type, Parameters>::IsExtensionSupported(const std::string_view& extension) const bool ResourceSaver<Type, Parameters>::IsExtensionSupported(std::string_view extension) const
{ {
NazaraAssert(extension.size() >= 2 || extension.front() != '.', "extension should start with a ."); NazaraAssert(extension.size() >= 2 || extension.front() != '.', "extension should start with a .");

View File

@ -18,55 +18,55 @@ namespace Nz
struct UnicodeAware {}; struct UnicodeAware {};
// std::string is assumed to contains UTF-8 // std::string is assumed to contains UTF-8
NAZARA_CORE_API std::size_t ComputeCharacterCount(const std::string_view& str); NAZARA_CORE_API std::size_t ComputeCharacterCount(std::string_view str);
inline bool EndsWith(const std::string_view& str, const std::string_view& s); inline bool EndsWith(std::string_view str, std::string_view s);
NAZARA_CORE_API bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent); NAZARA_CORE_API bool EndsWith(std::string_view lhs, std::string_view rhs, CaseIndependent);
NAZARA_CORE_API bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware); NAZARA_CORE_API bool EndsWith(std::string_view lhs, std::string_view rhs, UnicodeAware);
NAZARA_CORE_API bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware); NAZARA_CORE_API bool EndsWith(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware);
NAZARA_CORE_API std::string FromUtf16String(const std::u16string_view& u16str); NAZARA_CORE_API std::string FromUtf16String(std::u16string_view u16str);
NAZARA_CORE_API std::string FromUtf32String(const std::u32string_view& u32str); NAZARA_CORE_API std::string FromUtf32String(std::u32string_view u32str);
NAZARA_CORE_API std::string FromWideString(const std::wstring_view& str); NAZARA_CORE_API std::string FromWideString(std::wstring_view str);
NAZARA_CORE_API std::size_t GetCharacterPosition(const std::string_view& str, std::size_t characterIndex); NAZARA_CORE_API std::size_t GetCharacterPosition(std::string_view str, std::size_t characterIndex);
NAZARA_CORE_API std::string_view GetWord(const std::string_view& str, std::size_t wordIndex); NAZARA_CORE_API std::string_view GetWord(std::string_view str, std::size_t wordIndex);
NAZARA_CORE_API std::string_view GetWord(const std::string_view& str, std::size_t wordIndex, UnicodeAware); NAZARA_CORE_API std::string_view GetWord(std::string_view str, std::size_t wordIndex, UnicodeAware);
inline bool IsNumber(std::string_view str); inline bool IsNumber(std::string_view str);
NAZARA_CORE_API bool MatchPattern(const std::string_view& str, const std::string_view& pattern); NAZARA_CORE_API bool MatchPattern(std::string_view str, std::string_view pattern);
inline std::string NumberToString(long long number, UInt8 radix = 10); inline std::string NumberToString(long long number, UInt8 radix = 10);
NAZARA_CORE_API std::string PointerToString(const void* ptr); NAZARA_CORE_API std::string PointerToString(const void* ptr);
inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to); inline std::string& ReplaceStr(std::string& str, std::string_view from, std::string_view to);
inline bool StartsWith(const std::string_view& str, const std::string_view& s); inline bool StartsWith(std::string_view str, std::string_view s);
NAZARA_CORE_API bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent); NAZARA_CORE_API bool StartsWith(std::string_view lhs, std::string_view rhs, CaseIndependent);
NAZARA_CORE_API bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware); NAZARA_CORE_API bool StartsWith(std::string_view lhs, std::string_view rhs, UnicodeAware);
NAZARA_CORE_API bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware); NAZARA_CORE_API bool StartsWith(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware);
template<typename F> bool SplitString(const std::string_view& str, const std::string_view& token, F&& func); template<typename F> bool SplitString(std::string_view str, std::string_view token, F&& func);
template<typename F> bool SplitStringAny(const std::string_view& str, const std::string_view& token, F&& func); template<typename F> bool SplitStringAny(std::string_view str, std::string_view token, F&& func);
inline bool StringEqual(const std::string_view& lhs, const std::string_view& rhs); inline bool StringEqual(std::string_view lhs, std::string_view rhs);
inline bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent); inline bool StringEqual(std::string_view lhs, std::string_view rhs, CaseIndependent);
NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware); NAZARA_CORE_API bool StringEqual(std::string_view lhs, std::string_view rhs, UnicodeAware);
NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware); NAZARA_CORE_API bool StringEqual(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware);
inline long long StringToNumber(const std::string_view& str, UInt8 radix = 10, bool* ok = nullptr); inline long long StringToNumber(std::string_view str, UInt8 radix = 10, bool* ok = nullptr);
NAZARA_CORE_API std::string ToLower(const std::string_view& str); NAZARA_CORE_API std::string ToLower(std::string_view str);
NAZARA_CORE_API std::string ToLower(const std::string_view& str, UnicodeAware); NAZARA_CORE_API std::string ToLower(std::string_view str, UnicodeAware);
NAZARA_CORE_API std::string ToUpper(const std::string_view& str); NAZARA_CORE_API std::string ToUpper(std::string_view str);
NAZARA_CORE_API std::string ToUpper(const std::string_view& str, UnicodeAware); NAZARA_CORE_API std::string ToUpper(std::string_view str, UnicodeAware);
NAZARA_CORE_API std::u16string ToUtf16String(const std::string_view& str); NAZARA_CORE_API std::u16string ToUtf16String(std::string_view str);
NAZARA_CORE_API std::u32string ToUtf32String(const std::string_view& str); NAZARA_CORE_API std::u32string ToUtf32String(std::string_view str);
NAZARA_CORE_API std::wstring ToWideString(const std::string_view& str); NAZARA_CORE_API std::wstring ToWideString(std::string_view str);
inline std::string_view Trim(std::string_view str); inline std::string_view Trim(std::string_view str);
inline std::string_view Trim(std::string_view str, char c); inline std::string_view Trim(std::string_view str, char c);

View File

@ -10,7 +10,7 @@
namespace Nz namespace Nz
{ {
inline bool EndsWith(const std::string_view& str, const std::string_view& s) inline bool EndsWith(std::string_view str, std::string_view s)
{ {
#if NAZARA_CPP_VER >= NAZARA_CPP20 #if NAZARA_CPP_VER >= NAZARA_CPP20
// C++20 // C++20
@ -77,7 +77,7 @@ namespace Nz
return str; return str;
} }
inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to) inline std::string& ReplaceStr(std::string& str, std::string_view from, std::string_view to)
{ {
if (str.empty()) if (str.empty())
return str; return str;
@ -92,7 +92,7 @@ namespace Nz
return str; return str;
} }
inline bool StartsWith(const std::string_view& str, const std::string_view& s) inline bool StartsWith(std::string_view str, std::string_view s)
{ {
#if NAZARA_CPP_VER >= NAZARA_CPP20 #if NAZARA_CPP_VER >= NAZARA_CPP20
// C++20 // C++20
@ -103,7 +103,7 @@ namespace Nz
} }
template<typename F> template<typename F>
bool SplitString(const std::string_view& str, const std::string_view& token, F&& func) bool SplitString(std::string_view str, std::string_view token, F&& func)
{ {
std::size_t pos = 0; std::size_t pos = 0;
std::size_t previousPos = 0; std::size_t previousPos = 0;
@ -123,7 +123,7 @@ namespace Nz
} }
template<typename F> template<typename F>
bool SplitStringAny(const std::string_view& str, const std::string_view& token, F&& func) bool SplitStringAny(std::string_view str, std::string_view token, F&& func)
{ {
std::size_t pos = 0; std::size_t pos = 0;
std::size_t previousPos = 0; std::size_t previousPos = 0;
@ -139,12 +139,12 @@ namespace Nz
return func(str.substr(previousPos)); return func(str.substr(previousPos));
} }
inline bool StringEqual(const std::string_view& lhs, const std::string_view& rhs) inline bool StringEqual(std::string_view lhs, std::string_view rhs)
{ {
return lhs == rhs; return lhs == rhs;
} }
inline bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent) inline bool StringEqual(std::string_view lhs, std::string_view rhs, CaseIndependent)
{ {
if (lhs.size() != rhs.size()) if (lhs.size() != rhs.size())
return false; return false;
@ -170,7 +170,7 @@ namespace Nz
* \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior * \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior
* \remark With NAZARA_MATH_SAFE, a NazaraError is produced and 0 is returned * \remark With NAZARA_MATH_SAFE, a NazaraError is produced and 0 is returned
*/ */
inline long long StringToNumber(const std::string_view& str, UInt8 radix, bool* ok) inline long long StringToNumber(std::string_view str, UInt8 radix, bool* ok)
{ {
NazaraAssert(radix >= 2 && radix <= 36, "base must be between 2 and 36"); NazaraAssert(radix >= 2 && radix <= 36, "base must be between 2 and 36");

View File

@ -38,7 +38,7 @@ namespace Nz
OpenGLCommandBuffer(OpenGLCommandBuffer&&) = delete; OpenGLCommandBuffer(OpenGLCommandBuffer&&) = delete;
~OpenGLCommandBuffer() = default; ~OpenGLCommandBuffer() = default;
inline void BeginDebugRegion(const std::string_view& regionName, const Color& color); inline void BeginDebugRegion(std::string_view regionName, const Color& color);
inline void BindComputePipeline(const OpenGLComputePipeline* pipeline); inline void BindComputePipeline(const OpenGLComputePipeline* pipeline);
inline void BindComputeShaderBinding(const OpenGLRenderPipelineLayout& pipelineLayout, UInt32 set, const OpenGLShaderBinding* binding); inline void BindComputeShaderBinding(const OpenGLRenderPipelineLayout& pipelineLayout, UInt32 set, const OpenGLShaderBinding* binding);

View File

@ -23,7 +23,7 @@ namespace Nz
{ {
} }
inline void OpenGLCommandBuffer::BeginDebugRegion(const std::string_view& regionName, const Color& color) inline void OpenGLCommandBuffer::BeginDebugRegion(std::string_view regionName, const Color& color)
{ {
BeginDebugRegionCommand beginDebugRegion; BeginDebugRegionCommand beginDebugRegion;
beginDebugRegion.color = color; beginDebugRegion.color = color;

View File

@ -24,7 +24,7 @@ namespace Nz
OpenGLCommandBufferBuilder(OpenGLCommandBufferBuilder&&) noexcept = default; OpenGLCommandBufferBuilder(OpenGLCommandBufferBuilder&&) noexcept = default;
~OpenGLCommandBufferBuilder() = default; ~OpenGLCommandBufferBuilder() = default;
void BeginDebugRegion(const std::string_view& regionName, const Color& color) override; void BeginDebugRegion(std::string_view regionName, const Color& color) override;
void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) override; void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) override;
void BindComputePipeline(const ComputePipeline& pipeline) override; void BindComputePipeline(const ComputePipeline& pipeline) override;

View File

@ -208,7 +208,7 @@ namespace Nz::GL
virtual const Loader& GetLoader() = 0; virtual const Loader& GetLoader() = 0;
void OnContextRelease(); void OnContextRelease();
virtual bool ImplementFallback(const std::string_view& function); virtual bool ImplementFallback(std::string_view function);
static void NotifyContextDestruction(Context* context); static void NotifyContextDestruction(Context* context);

View File

@ -34,7 +34,7 @@ namespace Nz::GL
const Context* GetContext() const; const Context* GetContext() const;
GLuint GetObjectId() const; GLuint GetObjectId() const;
void SetDebugName(const std::string_view& name); void SetDebugName(std::string_view name);
ContextObject& operator=(const ContextObject&) = delete; ContextObject& operator=(const ContextObject&) = delete;
ContextObject& operator=(ContextObject&& object) noexcept = default; ContextObject& operator=(ContextObject&& object) noexcept = default;

View File

@ -85,7 +85,7 @@ namespace Nz::GL
} }
template<typename C, GLenum ObjectType, typename... CreateArgs> template<typename C, GLenum ObjectType, typename... CreateArgs>
void ContextObject<C, ObjectType, CreateArgs...>::SetDebugName(const std::string_view& name) void ContextObject<C, ObjectType, CreateArgs...>::SetDebugName(std::string_view name)
{ {
EnsureContext(); EnsureContext();

View File

@ -35,7 +35,7 @@ namespace Nz::GL
OpenGLDevice* GetDevice() const; OpenGLDevice* GetDevice() const;
GLuint GetObjectId() const; GLuint GetObjectId() const;
void SetDebugName(const std::string_view& name); void SetDebugName(std::string_view name);
DeviceObject& operator=(const DeviceObject&) = delete; DeviceObject& operator=(const DeviceObject&) = delete;
DeviceObject& operator=(DeviceObject&& object) noexcept = default; DeviceObject& operator=(DeviceObject&& object) noexcept = default;

View File

@ -91,7 +91,7 @@ namespace Nz::GL
} }
template<typename C, GLenum ObjectType, typename... CreateArgs> template<typename C, GLenum ObjectType, typename... CreateArgs>
void DeviceObject<C, ObjectType, CreateArgs...>::SetDebugName(const std::string_view& name) void DeviceObject<C, ObjectType, CreateArgs...>::SetDebugName(std::string_view name)
{ {
const Context& context = EnsureDeviceContext(); const Context& context = EnsureDeviceContext();

View File

@ -57,7 +57,7 @@ namespace Nz::GL
EGLSurface m_surface; EGLSurface m_surface;
private: private:
bool ImplementFallback(const std::string_view& function) override; bool ImplementFallback(std::string_view function) override;
bool Activate() const override; bool Activate() const override;
void Desactivate() const override; void Desactivate() const override;

View File

@ -41,7 +41,7 @@ namespace Nz::GL
static const char* TranslateError(EGLint errorId); static const char* TranslateError(EGLint errorId);
private: private:
bool ImplementFallback(const std::string_view& function); bool ImplementFallback(std::string_view function);
ContextType m_preferredContextType; ContextType m_preferredContextType;
EGLDisplay m_defaultDisplay; EGLDisplay m_defaultDisplay;

View File

@ -31,7 +31,7 @@ namespace Nz::GL
inline void SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length); inline void SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length);
inline void SetSource(const char* source, GLint length); inline void SetSource(const char* source, GLint length);
inline void SetSource(const std::string_view& source); inline void SetSource(std::string_view source);
// GL_ARB_gl_spirv // GL_ARB_gl_spirv
inline void SpecializeShader(const GLchar* pEntryPoint, GLuint numSpecializationConstants, const GLuint* pConstantIndex, const GLuint* pConstantValue); inline void SpecializeShader(const GLchar* pEntryPoint, GLuint numSpecializationConstants, const GLuint* pConstantIndex, const GLuint* pConstantValue);

View File

@ -80,7 +80,7 @@ namespace Nz::GL
m_device->GetReferenceContext().glShaderSource(m_objectId, 1U, &source, &length); m_device->GetReferenceContext().glShaderSource(m_objectId, 1U, &source, &length);
} }
inline void Shader::SetSource(const std::string_view& source) inline void Shader::SetSource(std::string_view source)
{ {
return SetSource(source.data(), GLint(source.size())); return SetSource(source.data(), GLint(source.size()));
} }

View File

@ -47,7 +47,7 @@ namespace Nz::GL
private: private:
bool CreateInternal(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext = nullptr); bool CreateInternal(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext = nullptr);
bool ImplementFallback(const std::string_view& function) override; bool ImplementFallback(std::string_view function) override;
bool Activate() const override; bool Activate() const override;
void Desactivate() const override; void Desactivate() const override;

View File

@ -51,7 +51,7 @@ namespace Nz::GL
const WebLoader& m_loader; const WebLoader& m_loader;
private: private:
bool ImplementFallback(const std::string_view& function) override; bool ImplementFallback(std::string_view function) override;
bool Activate() const override; bool Activate() const override;
void Desactivate() const override; void Desactivate() const override;

View File

@ -31,7 +31,7 @@ namespace Nz::GL
static const char* TranslateError(EMSCRIPTEN_RESULT errorId); static const char* TranslateError(EMSCRIPTEN_RESULT errorId);
private: private:
bool ImplementFallback(const std::string_view& function); bool ImplementFallback(std::string_view function);
}; };
} }

View File

@ -38,7 +38,7 @@ namespace Nz
CommandBufferBuilder(CommandBufferBuilder&&) = default; CommandBufferBuilder(CommandBufferBuilder&&) = default;
virtual ~CommandBufferBuilder(); virtual ~CommandBufferBuilder();
virtual void BeginDebugRegion(const std::string_view& regionName, const Color& color) = 0; virtual void BeginDebugRegion(std::string_view regionName, const Color& color) = 0;
virtual void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) = 0; virtual void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) = 0;
inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect); inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect);
inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, std::initializer_list<ClearValues> clearValues); inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, std::initializer_list<ClearValues> clearValues);

View File

@ -23,7 +23,7 @@ namespace Nz
inline SimpleTextDrawer(SimpleTextDrawer&& drawer) noexcept; inline SimpleTextDrawer(SimpleTextDrawer&& drawer) noexcept;
~SimpleTextDrawer() = default; ~SimpleTextDrawer() = default;
inline void AppendText(const std::string_view& str); inline void AppendText(std::string_view str);
void Clear() override; void Clear() override;
@ -75,7 +75,7 @@ namespace Nz
inline void DisconnectFontSlots(); inline void DisconnectFontSlots();
bool GenerateGlyph(Glyph& glyph, char32_t character, float outlineThickness, bool lineWrap, Color color, int renderOrder, int* advance) const; bool GenerateGlyph(Glyph& glyph, char32_t character, float outlineThickness, bool lineWrap, Color color, int renderOrder, int* advance) const;
void GenerateGlyphs(const std::string_view& text) const; void GenerateGlyphs(std::string_view text) const;
inline float GetLineHeight(const Font::SizeInfo& sizeInfo) const; inline float GetLineHeight(const Font::SizeInfo& sizeInfo) const;

View File

@ -42,7 +42,7 @@ namespace Nz
operator=(std::move(drawer)); operator=(std::move(drawer));
} }
inline void SimpleTextDrawer::AppendText(const std::string_view& str) inline void SimpleTextDrawer::AppendText(std::string_view str)
{ {
m_text.append(str); m_text.append(str);
if (m_glyphUpdated) if (m_glyphUpdated)

View File

@ -24,7 +24,7 @@ namespace Nz
VulkanCommandBufferBuilder(VulkanCommandBufferBuilder&&) noexcept = default; VulkanCommandBufferBuilder(VulkanCommandBufferBuilder&&) noexcept = default;
~VulkanCommandBufferBuilder() = default; ~VulkanCommandBufferBuilder() = default;
void BeginDebugRegion(const std::string_view& regionName, const Color& color) override; void BeginDebugRegion(std::string_view regionName, const Color& color) override;
void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) override; void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) override;
void BindComputePipeline(const ComputePipeline& pipeline) override; void BindComputePipeline(const ComputePipeline& pipeline) override;

View File

@ -49,7 +49,7 @@ namespace Nz
} }
} }
bool IsWavSupported(const std::string_view& extension) bool IsWavSupported(std::string_view extension)
{ {
return extension == ".riff" || extension == ".rf64" || extension == ".wav" || extension == ".w64"; return extension == ".riff" || extension == ".rf64" || extension == ".wav" || extension == ".w64";
} }

View File

@ -136,7 +136,7 @@ namespace Nz
return DecodeFlacFrameSamples(frame, buffer, samples, 0, frame->header.blocksize); return DecodeFlacFrameSamples(frame, buffer, samples, 0, frame->header.blocksize);
} }
bool IsFlacSupported(const std::string_view& extension) bool IsFlacSupported(std::string_view extension)
{ {
return extension == ".flac"; return extension == ".flac";
} }

View File

@ -51,7 +51,7 @@ namespace Nz
return (stream->SetCursorPos(position)) ? 0 : MP3D_E_IOERROR; return (stream->SetCursorPos(position)) ? 0 : MP3D_E_IOERROR;
} }
bool IsMP3Supported(const std::string_view& extension) bool IsMP3Supported(std::string_view extension)
{ {
return extension == ".mp3"; return extension == ".mp3";
} }

View File

@ -61,7 +61,7 @@ namespace Nz
return FromUtf16String(std::u16string_view(reinterpret_cast<const char16_t*>(wstr), size)); return FromUtf16String(std::u16string_view(reinterpret_cast<const char16_t*>(wstr), size));
} }
static std::wstring To(const std::string_view& str) static std::wstring To(std::string_view str)
{ {
std::wstring result; std::wstring result;
utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result)); utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result));
@ -81,7 +81,7 @@ namespace Nz
return FromUtf32String(std::u32string_view(reinterpret_cast<const char32_t*>(wstr), size)); return FromUtf32String(std::u32string_view(reinterpret_cast<const char32_t*>(wstr), size));
} }
static std::wstring To(const std::string_view& str) static std::wstring To(std::string_view str)
{ {
std::wstring result; std::wstring result;
utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result)); utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result));
@ -92,12 +92,12 @@ namespace Nz
#endif #endif
} }
std::size_t ComputeCharacterCount(const std::string_view& str) std::size_t ComputeCharacterCount(std::string_view str)
{ {
return utf8::distance(str.data(), str.data() + str.size()); return utf8::distance(str.data(), str.data() + str.size());
} }
bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent) bool EndsWith(std::string_view lhs, std::string_view rhs, CaseIndependent)
{ {
NAZARA_USE_ANONYMOUS_NAMESPACE NAZARA_USE_ANONYMOUS_NAMESPACE
@ -110,7 +110,7 @@ namespace Nz
}); });
} }
bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware) bool EndsWith(std::string_view lhs, std::string_view rhs, UnicodeAware)
{ {
if (lhs.empty()) if (lhs.empty())
return lhs == rhs; return lhs == rhs;
@ -136,7 +136,7 @@ namespace Nz
return true; return true;
} }
bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware) bool EndsWith(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware)
{ {
if (lhs.empty()) if (lhs.empty())
return lhs == rhs; return lhs == rhs;
@ -162,7 +162,7 @@ namespace Nz
return true; return true;
} }
std::string FromUtf16String(const std::u16string_view& u16str) std::string FromUtf16String(std::u16string_view u16str)
{ {
std::string result; std::string result;
utf8::utf16to8(u16str.begin(), u16str.end(), std::back_inserter(result)); utf8::utf16to8(u16str.begin(), u16str.end(), std::back_inserter(result));
@ -170,7 +170,7 @@ namespace Nz
return result; return result;
} }
std::string FromUtf32String(const std::u32string_view& u32str) std::string FromUtf32String(std::u32string_view u32str)
{ {
std::string result; std::string result;
utf8::utf32to8(u32str.begin(), u32str.end(), std::back_inserter(result)); utf8::utf32to8(u32str.begin(), u32str.end(), std::back_inserter(result));
@ -178,14 +178,14 @@ namespace Nz
return result; return result;
} }
std::string FromWideString(const std::wstring_view& wstr) std::string FromWideString(std::wstring_view wstr)
{ {
NAZARA_USE_ANONYMOUS_NAMESPACE NAZARA_USE_ANONYMOUS_NAMESPACE
return WideConverter<sizeof(wchar_t)>::From(wstr.data(), wstr.size()); return WideConverter<sizeof(wchar_t)>::From(wstr.data(), wstr.size());
} }
std::size_t GetCharacterPosition(const std::string_view& str, std::size_t characterIndex) std::size_t GetCharacterPosition(std::string_view str, std::size_t characterIndex)
{ {
const char* ptr = str.data(); const char* ptr = str.data();
const char* end = ptr + str.size(); const char* end = ptr + str.size();
@ -212,7 +212,7 @@ namespace Nz
return std::string::npos; return std::string::npos;
} }
std::string_view GetWord(const std::string_view& str, std::size_t wordIndex) std::string_view GetWord(std::string_view str, std::size_t wordIndex)
{ {
std::size_t pos = 0; std::size_t pos = 0;
std::size_t previousPos = 0; std::size_t previousPos = 0;
@ -228,7 +228,7 @@ namespace Nz
return {}; return {};
} }
std::string_view GetWord(const std::string_view& str, std::size_t wordIndex, UnicodeAware) std::string_view GetWord(std::string_view str, std::size_t wordIndex, UnicodeAware)
{ {
NAZARA_USE_ANONYMOUS_NAMESPACE NAZARA_USE_ANONYMOUS_NAMESPACE
@ -259,7 +259,7 @@ namespace Nz
return {}; return {};
} }
bool MatchPattern(const std::string_view& str, const std::string_view& pattern) bool MatchPattern(std::string_view str, std::string_view pattern)
{ {
if (str.empty() || pattern.empty()) if (str.empty() || pattern.empty())
return false; return false;
@ -321,7 +321,7 @@ namespace Nz
return str; return str;
} }
bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent) bool StartsWith(std::string_view lhs, std::string_view rhs, CaseIndependent)
{ {
NAZARA_USE_ANONYMOUS_NAMESPACE NAZARA_USE_ANONYMOUS_NAMESPACE
@ -334,7 +334,7 @@ namespace Nz
}); });
} }
bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware) bool StartsWith(std::string_view lhs, std::string_view rhs, UnicodeAware)
{ {
if (lhs.empty()) if (lhs.empty())
return lhs == rhs; return lhs == rhs;
@ -358,7 +358,7 @@ namespace Nz
return true; return true;
} }
bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware) bool StartsWith(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware)
{ {
if (lhs.empty()) if (lhs.empty())
return lhs == rhs; return lhs == rhs;
@ -382,7 +382,7 @@ namespace Nz
return true; return true;
} }
bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware) bool StringEqual(std::string_view lhs, std::string_view rhs, UnicodeAware)
{ {
if (lhs.empty() || rhs.empty()) if (lhs.empty() || rhs.empty())
return lhs == rhs; return lhs == rhs;
@ -399,7 +399,7 @@ namespace Nz
return true; return true;
} }
bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware) bool StringEqual(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware)
{ {
if (lhs.empty() || rhs.empty()) if (lhs.empty() || rhs.empty())
return lhs == rhs; return lhs == rhs;
@ -416,7 +416,7 @@ namespace Nz
return true; return true;
} }
std::string ToLower(const std::string_view& str) std::string ToLower(std::string_view str)
{ {
NAZARA_USE_ANONYMOUS_NAMESPACE NAZARA_USE_ANONYMOUS_NAMESPACE
@ -427,7 +427,7 @@ namespace Nz
return result; return result;
} }
std::string ToLower(const std::string_view& str, UnicodeAware) std::string ToLower(std::string_view str, UnicodeAware)
{ {
if (str.empty()) if (str.empty())
return std::string(); return std::string();
@ -443,7 +443,7 @@ namespace Nz
return result; return result;
} }
std::string ToUpper(const std::string_view& str) std::string ToUpper(std::string_view str)
{ {
NAZARA_USE_ANONYMOUS_NAMESPACE NAZARA_USE_ANONYMOUS_NAMESPACE
@ -454,7 +454,7 @@ namespace Nz
return result; return result;
} }
std::string ToUpper(const std::string_view& str, UnicodeAware) std::string ToUpper(std::string_view str, UnicodeAware)
{ {
if (str.empty()) if (str.empty())
return std::string(); return std::string();
@ -470,7 +470,7 @@ namespace Nz
return result; return result;
} }
std::u16string ToUtf16String(const std::string_view& str) std::u16string ToUtf16String(std::string_view str)
{ {
std::u16string result; std::u16string result;
utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result)); utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result));
@ -478,7 +478,7 @@ namespace Nz
return result; return result;
} }
std::u32string ToUtf32String(const std::string_view& str) std::u32string ToUtf32String(std::string_view str)
{ {
std::u32string result; std::u32string result;
utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result)); utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result));
@ -486,7 +486,7 @@ namespace Nz
return result; return result;
} }
std::wstring ToWideString(const std::string_view& str) std::wstring ToWideString(std::string_view str)
{ {
NAZARA_USE_ANONYMOUS_NAMESPACE NAZARA_USE_ANONYMOUS_NAMESPACE

View File

@ -17,7 +17,7 @@
namespace Nz namespace Nz
{ {
void OpenGLCommandBufferBuilder::BeginDebugRegion(const std::string_view& regionName, const Color& color) void OpenGLCommandBufferBuilder::BeginDebugRegion(std::string_view regionName, const Color& color)
{ {
m_commandBuffer.BeginDebugRegion(regionName, color); m_commandBuffer.BeginDebugRegion(regionName, color);
} }

View File

@ -88,7 +88,7 @@ namespace Nz
env.glES = (contextParams.type == GL::ContextType::OpenGL_ES); env.glES = (contextParams.type == GL::ContextType::OpenGL_ES);
env.glMajorVersion = contextParams.glMajorVersion; env.glMajorVersion = contextParams.glMajorVersion;
env.glMinorVersion = contextParams.glMinorVersion; env.glMinorVersion = contextParams.glMinorVersion;
env.extCallback = [&](const std::string_view& ext) env.extCallback = [&](std::string_view ext)
{ {
return context.IsExtensionSupported(std::string(ext)); return context.IsExtensionSupported(std::string(ext));
}; };

View File

@ -1027,7 +1027,7 @@ namespace Nz::GL
m_vaoCache.Clear(); m_vaoCache.Clear();
} }
bool Context::ImplementFallback(const std::string_view& function) bool Context::ImplementFallback(std::string_view function)
{ {
SymbolLoader loader(*this); SymbolLoader loader(*this);

View File

@ -296,7 +296,7 @@ namespace Nz::GL
return true; return true;
} }
bool EGLContextBase::ImplementFallback(const std::string_view& function) bool EGLContextBase::ImplementFallback(std::string_view function)
{ {
if (Context::ImplementFallback(function)) if (Context::ImplementFallback(function))
return true; return true;

View File

@ -245,7 +245,7 @@ namespace Nz::GL
} }
} }
bool EGLLoader::ImplementFallback(const std::string_view& /*function*/) bool EGLLoader::ImplementFallback(std::string_view /*function*/)
{ {
return false; return false;
} }

View File

@ -238,7 +238,7 @@ namespace Nz::GL
return true; return true;
} }
bool WGLContext::ImplementFallback(const std::string_view& function) bool WGLContext::ImplementFallback(std::string_view function)
{ {
if (Context::ImplementFallback(function)) if (Context::ImplementFallback(function))
return true; return true;

View File

@ -18,7 +18,7 @@ namespace Nz
DDSLoader() = delete; DDSLoader() = delete;
~DDSLoader() = delete; ~DDSLoader() = delete;
static bool IsSupported(const std::string_view& extension) static bool IsSupported(std::string_view extension)
{ {
return (extension == ".dds"); return (extension == ".dds");
} }

View File

@ -378,7 +378,7 @@ namespace Nz
mutable unsigned int m_characterSize; mutable unsigned int m_characterSize;
}; };
bool IsFreetypeSupported(const std::string_view& extension) bool IsFreetypeSupported(std::string_view extension)
{ {
constexpr auto s_supportedExtensions = frozen::make_unordered_set<frozen::string>({ ".afm", ".bdf", ".cff", ".cid", ".dfont", ".fnt", ".fon", ".otf", ".pfa", ".pfb", ".pfm", ".pfr", ".sfnt", ".ttc", ".tte", ".ttf" }); constexpr auto s_supportedExtensions = frozen::make_unordered_set<frozen::string>({ ".afm", ".bdf", ".cff", ".cid", ".dfont", ".fnt", ".fon", ".otf", ".pfa", ".pfb", ".pfm", ".pfr", ".sfnt", ".ttc", ".tte", ".ttf" });

View File

@ -704,7 +704,7 @@ namespace Nz
bool m_requiresFrameHistory; bool m_requiresFrameHistory;
}; };
bool CheckGIFExtension(const std::string_view& extension) bool CheckGIFExtension(std::string_view extension)
{ {
return extension == ".gif"; return extension == ".gif";
} }

View File

@ -21,7 +21,7 @@ namespace Nz
{ {
namespace namespace
{ {
bool IsMD2Supported(const std::string_view& extension) bool IsMD2Supported(std::string_view extension)
{ {
return (extension == ".md2"); return (extension == ".md2");
} }

View File

@ -12,7 +12,7 @@ namespace Nz
{ {
namespace namespace
{ {
bool IsMD5AnimSupported(const std::string_view& extension) bool IsMD5AnimSupported(std::string_view extension)
{ {
return extension == ".md5anim"; return extension == ".md5anim";
} }

View File

@ -20,7 +20,7 @@ namespace Nz
{ {
namespace namespace
{ {
bool IsMD5MeshSupported(const std::string_view& extension) bool IsMD5MeshSupported(std::string_view extension)
{ {
return (extension == ".md5mesh"); return (extension == ".md5mesh");
} }

View File

@ -22,7 +22,7 @@ namespace Nz
{ {
namespace namespace
{ {
bool IsOBJSupported(const std::string_view& extension) bool IsOBJSupported(std::string_view extension)
{ {
return (extension == ".obj"); return (extension == ".obj");
} }

View File

@ -52,7 +52,7 @@ namespace Nz
T* m_buffer; T* m_buffer;
}; };
bool IsOBJSupportedSave(const std::string_view& extension) bool IsOBJSupportedSave(std::string_view extension)
{ {
return (extension == ".obj"); return (extension == ".obj");
} }

View File

@ -40,7 +40,7 @@ namespace Nz
static_assert(sizeof(PCXHeader) == (6+48+54)*sizeof(UInt8) + 10*sizeof(UInt16), "pcx_header struct must be packed"); static_assert(sizeof(PCXHeader) == (6+48+54)*sizeof(UInt8) + 10*sizeof(UInt16), "pcx_header struct must be packed");
bool IsPCXSupported(const std::string_view& extension) bool IsPCXSupported(std::string_view extension)
{ {
return (extension == ".pcx"); return (extension == ".pcx");
} }

View File

@ -41,7 +41,7 @@ namespace Nz
static stbi_io_callbacks s_stbiCallbacks = { StbiRead, StbiSkip, StbiEof }; static stbi_io_callbacks s_stbiCallbacks = { StbiRead, StbiSkip, StbiEof };
bool IsSTBSupported(const std::string_view& extension) bool IsSTBSupported(std::string_view extension)
{ {
constexpr auto s_supportedExtensions = frozen::make_unordered_set<frozen::string>({ ".bmp", ".gif", ".hdr", ".jpg", ".jpeg", ".pic", ".png", ".ppm", ".pgm", ".psd", ".tga" }); constexpr auto s_supportedExtensions = frozen::make_unordered_set<frozen::string>({ ".bmp", ".gif", ".hdr", ".jpg", ".jpeg", ".pic", ".png", ".ppm", ".pgm", ".psd", ".tga" });

View File

@ -230,7 +230,7 @@ namespace Nz
{ ".tga", &SaveTGA } { ".tga", &SaveTGA }
}); });
bool FormatQuerier(const std::string_view& extension) bool FormatQuerier(std::string_view extension)
{ {
return s_formatHandlers.find(extension) != s_formatHandlers.end(); return s_formatHandlers.find(extension) != s_formatHandlers.end();
} }

View File

@ -182,7 +182,7 @@ namespace Nz
return false; return false;
}; };
void SimpleTextDrawer::GenerateGlyphs(const std::string_view& text) const void SimpleTextDrawer::GenerateGlyphs(std::string_view text) const
{ {
if (text.empty()) if (text.empty())
return; return;

View File

@ -19,7 +19,7 @@
namespace Nz namespace Nz
{ {
void VulkanCommandBufferBuilder::BeginDebugRegion(const std::string_view& regionName, const Color& color) void VulkanCommandBufferBuilder::BeginDebugRegion(std::string_view regionName, const Color& color)
{ {
// Ensure \0 at the end of string // Ensure \0 at the end of string
StackArray<char> regionNameEOS = NazaraStackArrayNoInit(char, regionName.size() + 1); StackArray<char> regionNameEOS = NazaraStackArrayNoInit(char, regionName.size() + 1);