Browse Source

Remove old std::u32string-related MinGW workarounds.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
d7a922bfb5
  1. 7
      src/Magnum/Text/AbstractFont.cpp
  2. 7
      src/Magnum/Text/AbstractFont.h
  3. 29
      src/Magnum/Text/AbstractFontConverter.cpp
  4. 26
      src/Magnum/Text/AbstractFontConverter.h
  5. 38
      src/Magnum/Text/Test/AbstractFontConverterTest.cpp
  6. 7
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp
  7. 4
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h

7
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<char32_t>&)
#endif
{
void AbstractFont::doFillGlyphCache(GlyphCache&, const std::u32string&) {
CORRADE_ASSERT(false, "Text::AbstractFont::fillGlyphCache(): feature advertised but not implemented", );
}

7
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<char32_t>` 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<char32_t>& characters);
#endif
/** @brief Implementation for @ref createGlyphCache() */
virtual std::unique_ptr<GlyphCache> doCreateGlyphCache();

29
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<char32_t> uniqueUnicode(const std::string& characters)
#endif
{
/* Convert UTF-8 to UTF-32 */
#ifndef __MINGW32__
std::u32string result = Utility::Unicode::utf32(characters);
#else
std::vector<char32_t> result = Utility::Unicode::utf32(characters);
#endif
/* Remove duplicate glyphs */
std::sort(result.begin(), result.end());
@ -70,12 +62,7 @@ std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConvert
return doExportFontToData(font, cache, filename, uniqueUnicode(characters));
}
#ifndef __MINGW32__
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
#endif
{
std::vector<std::pair<std::string, Containers::Array<char>>> 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<char> AbstractFontConverter::exportFontToSingleData(AbstractFo
return doExportFontToSingleData(font, cache, uniqueUnicode(characters));
}
#ifndef __MINGW32__
Containers::Array<char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const
#else
Containers::Array<char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>&) const
#endif
{
Containers::Array<char> 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<char32_t>& 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);

26
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<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/
#ifndef __MINGW32__
virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const;
#else
virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const;
#endif
/**
* @brief Implementation for @ref exportFontToSingleData()
*
* @note On MinGW uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/
#ifndef __MINGW32__
/** @brief Implementation for @ref exportFontToSingleData() */
virtual Containers::Array<char> doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const;
#else
virtual Containers::Array<char> doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::vector<char32_t>& 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<char32_t>` 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<char32_t>& characters) const;
#endif
/**
* @brief Implementation for @ref exportGlyphCacheToData()

38
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<char32_t>& characters): characters(characters) {}
#endif
private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; }
#ifndef __MINGW32__
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override
#else
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>& characters) const override
#endif
{
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override {
this->characters = characters;
return nullptr;
}
#ifndef __MINGW32__
std::u32string& characters;
#else
std::vector<char32_t>& characters;
#endif
};
#ifndef __MINGW32__
std::u32string characters;
#else
std::vector<char32_t> characters;
#endif
GlyphExporter exporter(characters);
exporter.exportFontToSingleData(nullFont, nullGlyphCache, "abC01a0 ");
#ifndef __MINGW32__
CORRADE_COMPARE(characters, U" 01Cab");
#else
CORRADE_COMPARE(characters, (std::vector<char32_t>{
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<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override
#else
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>&) const override
#endif
{
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override {
Containers::Array<char> 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<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override
#else
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::vector<char32_t>&) const override
#endif
{
std::vector<std::pair<std::string, Containers::Array<char>>> 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<std::pair<std::string, Containers::Array<char>>> ret;

7
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<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
#endif
{
std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const {
Utility::Configuration configuration;
configuration.setValue("version", 1);

4
src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h

@ -60,11 +60,7 @@ class MagnumFontConverter: public Text::AbstractFontConverter {
private:
Features doFeatures() const override;
#ifndef __MINGW32__
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override;
#else
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const override;
#endif
};
}}

Loading…
Cancel
Save