From d7a922bfb5fc0fd278c8a0d1fe1314df1e8fe630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 8 Sep 2015 13:22:27 +0200 Subject: [PATCH] Remove old std::u32string-related MinGW workarounds. --- src/Magnum/Text/AbstractFont.cpp | 7 +--- src/Magnum/Text/AbstractFont.h | 7 ---- src/Magnum/Text/AbstractFontConverter.cpp | 29 ++------------ src/Magnum/Text/AbstractFontConverter.h | 26 +------------ .../Text/Test/AbstractFontConverterTest.cpp | 38 ++----------------- .../MagnumFontConverter.cpp | 7 +--- .../MagnumFontConverter/MagnumFontConverter.h | 4 -- 7 files changed, 9 insertions(+), 109 deletions(-) diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index 8b2af4c12..1eabeeba8 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -127,12 +127,7 @@ void AbstractFont::fillGlyphCache(GlyphCache& cache, const std::string& characte doFillGlyphCache(cache, Utility::Unicode::utf32(characters)); } -#ifndef __MINGW32__ -void AbstractFont::doFillGlyphCache(GlyphCache&, const std::u32string&) -#else -void AbstractFont::doFillGlyphCache(GlyphCache&, const std::vector&) -#endif -{ +void AbstractFont::doFillGlyphCache(GlyphCache&, const std::u32string&) { CORRADE_ASSERT(false, "Text::AbstractFont::fillGlyphCache(): feature advertised but not implemented", ); } diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index f639fed4e..ce9ed573f 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -277,15 +277,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * * The string is converted from UTF-8 to UTF-32, unique characters are * *not* removed. - * @note On MinGW uses `std::vector` instead of - * `std::u32string`. See @ref Corrade::Utility::Unicode::utf32() - * for more information. */ - #ifndef __MINGW32__ virtual void doFillGlyphCache(GlyphCache& cache, const std::u32string& characters); - #else - virtual void doFillGlyphCache(GlyphCache& cache, const std::vector& characters); - #endif /** @brief Implementation for @ref createGlyphCache() */ virtual std::unique_ptr doCreateGlyphCache(); diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index 2a706d8df..b5dd6baee 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -37,18 +37,10 @@ namespace Magnum { namespace Text { namespace { -#ifndef __MINGW32__ std::u32string uniqueUnicode(const std::string& characters) -#else -std::vector uniqueUnicode(const std::string& characters) -#endif { /* Convert UTF-8 to UTF-32 */ - #ifndef __MINGW32__ std::u32string result = Utility::Unicode::utf32(characters); - #else - std::vector result = Utility::Unicode::utf32(characters); - #endif /* Remove duplicate glyphs */ std::sort(result.begin(), result.end()); @@ -70,12 +62,7 @@ std::vector>> AbstractFontConvert return doExportFontToData(font, cache, filename, uniqueUnicode(characters)); } -#ifndef __MINGW32__ -std::vector>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const -#else -std::vector>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const -#endif -{ +std::vector>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const { CORRADE_ASSERT(!(features() & Feature::MultiFile), "Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", {}); @@ -93,12 +80,7 @@ Containers::Array AbstractFontConverter::exportFontToSingleData(AbstractFo return doExportFontToSingleData(font, cache, uniqueUnicode(characters)); } -#ifndef __MINGW32__ -Containers::Array AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const -#else -Containers::Array AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector&) const -#endif -{ +Containers::Array AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const { CORRADE_ASSERT(false, "Text::AbstractFontConverter::exportFontToSingleData(): feature advertised but not implemented", nullptr); return nullptr; @@ -111,12 +93,7 @@ bool AbstractFontConverter::exportFontToFile(AbstractFont& font, GlyphCache& cac return doExportFontToFile(font, cache, filename, uniqueUnicode(characters)); } -#ifndef __MINGW32__ -bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const -#else -bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const -#endif -{ +bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const { CORRADE_ASSERT(features() & Feature::ConvertData, "Text::AbstractFontConverter::exportFontToFile(): not implemented", false); diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index eb907cb88..f9e715916 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -272,28 +272,11 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * * If the plugin doesn't have @ref Feature::MultiFile, default * implementation calls @ref doExportFontToSingleData(). - * @note On MinGW uses `std::vector` instead of - * `std::u32string`. See @ref Corrade::Utility::Unicode::utf32() - * for more information. */ - #ifndef __MINGW32__ virtual std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const; - #else - virtual std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const; - #endif - /** - * @brief Implementation for @ref exportFontToSingleData() - * - * @note On MinGW uses `std::vector` instead of - * `std::u32string`. See @ref Corrade::Utility::Unicode::utf32() - * for more information. - */ - #ifndef __MINGW32__ + /** @brief Implementation for @ref exportFontToSingleData() */ virtual Containers::Array doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const; - #else - virtual Containers::Array doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::vector& characters) const; - #endif /** * @brief Implementation for @ref exportFontToFile() @@ -301,15 +284,8 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * If @ref Feature::ConvertData is supported, default implementation * calls @ref doExportFontToData() and saves the result to given * file(s). - * @note On MinGW uses `std::vector` instead of - * `std::u32string`. See @ref Corrade::Utility::Unicode::utf32() - * for more information. */ - #ifndef __MINGW32__ virtual bool doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const; - #else - virtual bool doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const; - #endif /** * @brief Implementation for @ref exportGlyphCacheToData() diff --git a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp index ba70229b0..78c063868 100644 --- a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp @@ -74,45 +74,23 @@ namespace { void AbstractFontConverterTest::convertGlyphs() { class GlyphExporter: public AbstractFontConverter { public: - #ifndef __MINGW32__ GlyphExporter(std::u32string& characters): characters(characters) {} - #else - GlyphExporter(std::vector& characters): characters(characters) {} - #endif private: Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } - #ifndef __MINGW32__ - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override - #else - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector& characters) const override - #endif - { + Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override { this->characters = characters; return nullptr; } - #ifndef __MINGW32__ std::u32string& characters; - #else - std::vector& characters; - #endif }; - #ifndef __MINGW32__ std::u32string characters; - #else - std::vector characters; - #endif GlyphExporter exporter(characters); exporter.exportFontToSingleData(nullFont, nullGlyphCache, "abC01a0 "); - #ifndef __MINGW32__ CORRADE_COMPARE(characters, U" 01Cab"); - #else - CORRADE_COMPARE(characters, (std::vector{ - U' ', U'0', U'1', U'C', U'a', U'b'})); - #endif } void AbstractFontConverterTest::exportFontToSingleData() { @@ -120,12 +98,7 @@ void AbstractFontConverterTest::exportFontToSingleData() { private: Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } - #ifndef __MINGW32__ - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override - #else - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector&) const override - #endif - { + Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override { Containers::Array data(1); data[0] = '\xee'; return data; @@ -146,12 +119,7 @@ void AbstractFontConverterTest::exportFontToFile() { private: Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont|Feature::MultiFile; } - #ifndef __MINGW32__ - std::vector>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override - #else - std::vector>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::vector&) const override - #endif - { + std::vector>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override { /* Why the hell GCC 4.9 fails to do proper move so I need to work around that this ugly way?! */ std::vector>> ret; diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp index efa11a6ee..a961e754e 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp @@ -45,12 +45,7 @@ auto MagnumFontConverter::doFeatures() const -> Features { return Feature::ExportFont|Feature::ConvertData|Feature::MultiFile; } -#ifndef __MINGW32__ -std::vector>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const -#else -std::vector>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const -#endif -{ +std::vector>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const { Utility::Configuration configuration; configuration.setValue("version", 1); diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h index f82583770..b98957ec1 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h @@ -60,11 +60,7 @@ class MagnumFontConverter: public Text::AbstractFontConverter { private: Features doFeatures() const override; - #ifndef __MINGW32__ std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override; - #else - std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const override; - #endif }; }}