Use std::string_view for strings
This commit is contained in:
parent
0cd8cff53e
commit
2125b80b8d
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <NazaraUtils/Prerequisites.hpp>
|
#include <NazaraUtils/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/ApplicationComponent.hpp>
|
#include <Nazara/Core/ApplicationComponent.hpp>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +27,7 @@ namespace Nz
|
||||||
private:
|
private:
|
||||||
void InstallSignalHandler();
|
void InstallSignalHandler();
|
||||||
|
|
||||||
static void HandleInterruptSignal(const char* signalName);
|
static void HandleInterruptSignal(std::string_view signalName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Nz
|
||||||
~NodeComponent() = default;
|
~NodeComponent() = default;
|
||||||
|
|
||||||
void SetParent(entt::handle entity, bool keepDerived = false);
|
void SetParent(entt::handle entity, bool keepDerived = false);
|
||||||
void SetParentJoint(entt::handle entity, const std::string& jointName, bool keepDerived = false);
|
void SetParentJoint(entt::handle entity, std::string_view jointName, bool keepDerived = false);
|
||||||
void SetParentJoint(entt::handle entity, std::size_t jointIndex, bool keepDerived = false);
|
void SetParentJoint(entt::handle entity, std::size_t jointIndex, bool keepDerived = false);
|
||||||
using Node::SetParent;
|
using Node::SetParent;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Nz
|
||||||
SkeletonComponentBase(SkeletonComponentBase&&) noexcept = default;
|
SkeletonComponentBase(SkeletonComponentBase&&) noexcept = default;
|
||||||
~SkeletonComponentBase() = default;
|
~SkeletonComponentBase() = default;
|
||||||
|
|
||||||
inline std::size_t FindJointByName(const std::string& jointName) const;
|
inline std::size_t FindJointByName(std::string_view jointName) const;
|
||||||
|
|
||||||
inline const Joint& GetAttachedJoint(std::size_t jointIndex) const;
|
inline const Joint& GetAttachedJoint(std::size_t jointIndex) const;
|
||||||
inline const std::shared_ptr<Skeleton>& GetSkeleton() const;
|
inline const std::shared_ptr<Skeleton>& GetSkeleton() const;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::size_t SkeletonComponentBase::FindJointByName(const std::string& jointName) const
|
inline std::size_t SkeletonComponentBase::FindJointByName(std::string_view jointName) const
|
||||||
{
|
{
|
||||||
return m_referenceSkeleton->GetJointIndex(jointName);
|
return m_referenceSkeleton->GetJointIndex(jointName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Nz
|
||||||
inline void ConnectFontSlots();
|
inline void ConnectFontSlots();
|
||||||
inline void DisconnectFontSlots();
|
inline void DisconnectFontSlots();
|
||||||
bool GenerateGlyph(Glyph& glyph, char32_t character, float outlineThickness, bool lineWrap, const Font& font, const Color& color, TextStyleFlags style, float lineSpacingOffset, unsigned int characterSize, int renderOrder, int* advance) const;
|
bool GenerateGlyph(Glyph& glyph, char32_t character, float outlineThickness, bool lineWrap, const Font& font, const Color& color, TextStyleFlags style, float lineSpacingOffset, unsigned int characterSize, int renderOrder, int* advance) const;
|
||||||
void GenerateGlyphs(const Font& font, const Color& color, TextStyleFlags style, unsigned int characterSize, const Color& outlineColor, float characterSpacingOffset, float lineSpacingOffset, float outlineThickness, const std::string& text) const;
|
void GenerateGlyphs(const Font& font, const Color& color, TextStyleFlags style, unsigned int characterSize, const Color& outlineColor, float characterSpacingOffset, float lineSpacingOffset, float outlineThickness, std::string_view text) const;
|
||||||
inline float GetLineHeight(const Block& block) const;
|
inline float GetLineHeight(const Block& block) const;
|
||||||
inline float GetLineHeight(float lineSpacingOffset, const Font::SizeInfo& sizeInfo) const;
|
inline float GetLineHeight(float lineSpacingOffset, const Font::SizeInfo& sizeInfo) const;
|
||||||
inline std::size_t HandleFontAddition(const std::shared_ptr<Font>& font);
|
inline std::size_t HandleFontAddition(const std::shared_ptr<Font>& font);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <Nazara/Core/ApplicationBase.hpp>
|
#include <Nazara/Core/ApplicationBase.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Core/Log.hpp>
|
#include <Nazara/Core/Log.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
@ -27,16 +28,14 @@ namespace Nz
|
||||||
{
|
{
|
||||||
switch (ctrlType)
|
switch (ctrlType)
|
||||||
{
|
{
|
||||||
case CTRL_C_EVENT: HandleInterruptSignal("CTRL_C"); break;
|
case CTRL_C_EVENT: HandleInterruptSignal("CTRL_C"); break;
|
||||||
case CTRL_BREAK_EVENT: HandleInterruptSignal("CTRL_BREAK"); break;
|
case CTRL_BREAK_EVENT: HandleInterruptSignal("CTRL_BREAK"); break;
|
||||||
case CTRL_CLOSE_EVENT: HandleInterruptSignal("CTRL_CLOSE"); break;
|
case CTRL_CLOSE_EVENT: HandleInterruptSignal("CTRL_CLOSE"); break;
|
||||||
case CTRL_LOGOFF_EVENT: HandleInterruptSignal("CTRL_LOGOFF"); break;
|
case CTRL_LOGOFF_EVENT: HandleInterruptSignal("CTRL_LOGOFF"); break;
|
||||||
case CTRL_SHUTDOWN_EVENT: HandleInterruptSignal("CTRL_SHUTDOWN"); break;
|
case CTRL_SHUTDOWN_EVENT: HandleInterruptSignal("CTRL_SHUTDOWN"); break;
|
||||||
default:
|
default:
|
||||||
{
|
HandleInterruptSignal(Format("<unknown CTRL signal {0}>", ctrlType));
|
||||||
std::string signalName = "<unknown CTRL signal " + std::to_string(ctrlType) + ">";
|
break;
|
||||||
HandleInterruptSignal(signalName.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
@ -61,10 +60,10 @@ namespace Nz
|
||||||
NazaraError("failed to install interruption signal handlers");
|
NazaraError("failed to install interruption signal handlers");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignalHandlerAppComponent::HandleInterruptSignal(const char* signalName)
|
void SignalHandlerAppComponent::HandleInterruptSignal(std::string_view signalName)
|
||||||
{
|
{
|
||||||
assert(ApplicationBase::Instance());
|
assert(ApplicationBase::Instance());
|
||||||
NazaraNotice("received interruption signal " + std::string(signalName) + ", exiting...");
|
NazaraNotice("received interruption signal {0}, exiting...", signalName);
|
||||||
|
|
||||||
ApplicationBase::Instance()->Quit();
|
ApplicationBase::Instance()->Quit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ namespace Nz
|
||||||
void Renderer::Config::Override(const CommandLineParameters& parameters)
|
void Renderer::Config::Override(const CommandLineParameters& parameters)
|
||||||
{
|
{
|
||||||
std::string_view value;
|
std::string_view value;
|
||||||
auto GetParameter = [&](const std::string& paramName, const char* envName, std::string_view* var)
|
auto GetParameter = [&](std::string_view paramName, const char* envName, std::string_view* var)
|
||||||
{
|
{
|
||||||
if (parameters.GetParameter(paramName, var))
|
if (parameters.GetParameter(paramName, var))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
Node::SetParent(nodeComponent, keepDerived);
|
Node::SetParent(nodeComponent, keepDerived);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeComponent::SetParentJoint(entt::handle entity, const std::string& jointName, bool keepDerived)
|
void NodeComponent::SetParentJoint(entt::handle entity, std::string_view jointName, bool keepDerived)
|
||||||
{
|
{
|
||||||
SkeletonComponentBase* skeletonComponent = entity.try_get<SkeletonComponent>();
|
SkeletonComponentBase* skeletonComponent = entity.try_get<SkeletonComponent>();
|
||||||
if (!skeletonComponent)
|
if (!skeletonComponent)
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ namespace Nz
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void RichTextDrawer::GenerateGlyphs(const Font& font, const Color& color, TextStyleFlags style, unsigned int characterSize, const Color& outlineColor, float characterSpacingOffset, float lineSpacingOffset, float outlineThickness, const std::string& text) const
|
void RichTextDrawer::GenerateGlyphs(const Font& font, const Color& color, TextStyleFlags style, unsigned int characterSize, const Color& outlineColor, float characterSpacingOffset, float lineSpacingOffset, float outlineThickness, std::string_view text) const
|
||||||
{
|
{
|
||||||
if (text.empty())
|
if (text.empty())
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue