diff --git a/src/Magnum/Platform/AbstractXApplication.cpp b/src/Magnum/Platform/AbstractXApplication.cpp index 168fa91b1..ca224d2d2 100644 --- a/src/Magnum/Platform/AbstractXApplication.cpp +++ b/src/Magnum/Platform/AbstractXApplication.cpp @@ -37,6 +37,8 @@ namespace Magnum { namespace Platform { +using namespace Containers::Literals; + AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, const Configuration& configuration, const GLConfiguration& glConfiguration): AbstractXApplication{contextHandler, arguments, NoCreate} { create(configuration, glConfiguration); } @@ -202,7 +204,8 @@ AbstractXApplication::GLConfiguration::GLConfiguration(): _version(GL::Version:: AbstractXApplication::GLConfiguration::~GLConfiguration() = default; AbstractXApplication::Configuration::Configuration(): - _title("Magnum X Application"), _size(800, 600) {} + _title{Containers::String::nullTerminatedGlobalView("Magnum X Application"_s)}, + _size(800, 600) {} AbstractXApplication::Configuration::~Configuration() = default; }} diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index 4dd8eb890..cfa22db03 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -33,10 +33,10 @@ #include "Magnum/configure.h" #ifdef MAGNUM_TARGET_GL -#include #include #include #include +#include #include #include @@ -64,6 +64,11 @@ typedef int Bool; #include "Magnum/Math/Vector2.h" #include "Magnum/Platform/GLContext.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* Some APIs used to take or return a std::string before */ +#include +#endif + namespace Magnum { namespace Platform { namespace Implementation { @@ -457,8 +462,14 @@ class AbstractXApplication::Configuration { /*implicit*/ Configuration(); ~Configuration(); - /** @brief Window title */ - std::string title() const { return _title; } + /** + * @brief Window title + * + * The returned view is always + * @relativeref{Corrade,Containers::StringViewFlag::NullTerminated} and + * is valid until the next call to @ref setTitle(). + */ + Containers::StringView title() const { return _title; } /** * @brief Set window title @@ -466,8 +477,8 @@ class AbstractXApplication::Configuration { * * Default is @cpp "Magnum X Application" @ce. */ - Configuration& setTitle(std::string title) { - _title = std::move(title); + Configuration& setTitle(Containers::StringView title) { + _title = Containers::String::nullTerminatedGlobalView(title); return *this; } @@ -486,7 +497,7 @@ class AbstractXApplication::Configuration { } private: - std::string _title; + Containers::String _title; Vector2i _size; }; diff --git a/src/Magnum/Platform/Test/GlxApplicationTest.cpp b/src/Magnum/Platform/Test/GlxApplicationTest.cpp index b2691d594..d9c954d13 100644 --- a/src/Magnum/Platform/Test/GlxApplicationTest.cpp +++ b/src/Magnum/Platform/Test/GlxApplicationTest.cpp @@ -29,6 +29,8 @@ namespace Magnum { namespace Platform { namespace Test { namespace { +using namespace Containers::Literals; + struct GlxApplicationTest: Platform::Application { explicit GlxApplicationTest(const Arguments& arguments); @@ -50,10 +52,12 @@ GlxApplicationTest::GlxApplicationTest(const Arguments& arguments): Platform::Ap return; } + Configuration conf; + conf.setTitle("Window title that should have no exclamation mark!!"_s.exceptSuffix(2)); if(args.isSet("quiet")) - create(Configuration{}, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog)); + create(conf, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog)); else - create(); + create(conf); } }}}} diff --git a/src/Magnum/Platform/Test/XEglApplicationTest.cpp b/src/Magnum/Platform/Test/XEglApplicationTest.cpp index 2346a2926..bc8259077 100644 --- a/src/Magnum/Platform/Test/XEglApplicationTest.cpp +++ b/src/Magnum/Platform/Test/XEglApplicationTest.cpp @@ -29,6 +29,8 @@ namespace Magnum { namespace Platform { namespace Test { namespace { +using namespace Containers::Literals; + struct XEglApplicationTest: Platform::Application { explicit XEglApplicationTest(const Arguments& arguments); @@ -50,10 +52,12 @@ XEglApplicationTest::XEglApplicationTest(const Arguments& arguments): Platform:: return; } + Configuration conf; + conf.setTitle("Window title that should have no exclamation mark!!"_s.exceptSuffix(2)); if(args.isSet("quiet")) - create(Configuration{}, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog)); + create(conf, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog)); else - create(); + create(conf); } }}}}