Browse Source

Move Feature[s] enums from inside plugin classes outside.

Too annoyingly long to type. Also added a debug output operator for the
FontConverterFeature enums, for some reason there were none.
dpi-change-events
Vladimír Vondruš 8 years ago
parent
commit
19dd7a0176
  1. 10
      doc/changelog.dox
  2. 16
      src/Magnum/Audio/AbstractImporter.cpp
  3. 73
      src/Magnum/Audio/AbstractImporter.h
  4. 38
      src/Magnum/Audio/Test/AbstractImporterTest.cpp
  5. 30
      src/Magnum/Text/AbstractFont.cpp
  6. 185
      src/Magnum/Text/AbstractFont.h
  7. 64
      src/Magnum/Text/AbstractFontConverter.cpp
  8. 261
      src/Magnum/Text/AbstractFontConverter.h
  9. 41
      src/Magnum/Text/Test/AbstractFontConverterTest.cpp
  10. 84
      src/Magnum/Text/Test/AbstractFontTest.cpp
  11. 4
      src/Magnum/Text/Test/RendererGLTest.cpp
  12. 38
      src/Magnum/Trade/AbstractImageConverter.cpp
  13. 166
      src/Magnum/Trade/AbstractImageConverter.h
  14. 28
      src/Magnum/Trade/AbstractImporter.cpp
  15. 194
      src/Magnum/Trade/AbstractImporter.h
  16. 70
      src/Magnum/Trade/Test/AbstractImageConverterTest.cpp
  17. 362
      src/Magnum/Trade/Test/AbstractImporterTest.cpp
  18. 2
      src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp
  19. 2
      src/MagnumPlugins/AnyAudioImporter/AnyImporter.h
  20. 4
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp
  21. 2
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h
  22. 2
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp
  23. 2
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h
  24. 2
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp
  25. 2
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h
  26. 2
      src/MagnumPlugins/MagnumFont/MagnumFont.cpp
  27. 2
      src/MagnumPlugins/MagnumFont/MagnumFont.h
  28. 4
      src/MagnumPlugins/MagnumFont/Test/MagnumFontTest.cpp
  29. 4
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp
  30. 2
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h
  31. 4
      src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp
  32. 2
      src/MagnumPlugins/ObjImporter/ObjImporter.cpp
  33. 2
      src/MagnumPlugins/ObjImporter/ObjImporter.h
  34. 2
      src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp
  35. 2
      src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h
  36. 2
      src/MagnumPlugins/TgaImporter/TgaImporter.cpp
  37. 2
      src/MagnumPlugins/TgaImporter/TgaImporter.h
  38. 2
      src/MagnumPlugins/WavAudioImporter/WavImporter.cpp
  39. 2
      src/MagnumPlugins/WavAudioImporter/WavImporter.h

10
doc/changelog.dox

@ -291,6 +291,16 @@ See also:
@cpp Platform::Sdl2Application::Configuration::isMouseLocked() @ce is @cpp Platform::Sdl2Application::Configuration::isMouseLocked() @ce is
deprecated in favor of the new @ref Platform::Sdl2Application::setCursor() deprecated in favor of the new @ref Platform::Sdl2Application::setCursor()
together with @ref Platform::Sdl2Application::Cursor::HiddenLocked together with @ref Platform::Sdl2Application::Cursor::HiddenLocked
- @cpp Audio::AbstractImporter::Features @ce,
@cpp Text::AbstractFont::Features @ce,
@cpp Text::AbstractFontConverter::Features @ce,
@cpp Trade::AbstractImporter::Features @ce,
@cpp Trade::AbstractImageConverter::Features @ce enum sets and their
corresponding `Feature` enums are deprecated in favor of
@ref Audio::ImporterFeatures, @ref Text::FontFeatures,
@ref Text::FontConverterFeatures, @ref Trade::ImporterFeatures,
@ref Trade::ImageConverterFeatures enum sets and their corresponding enums
placed directly in the namespace to have them shorter and unambiguous
@subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs

16
src/Magnum/Audio/AbstractImporter.cpp

@ -81,7 +81,7 @@ AbstractImporter::AbstractImporter(PluginManager::Manager<AbstractImporter>& man
AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, const std::string& plugin): PluginManager::AbstractManagingPlugin<AbstractImporter>{manager, plugin} {} AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, const std::string& plugin): PluginManager::AbstractManagingPlugin<AbstractImporter>{manager, plugin} {}
bool AbstractImporter::openData(Containers::ArrayView<const char> data) { bool AbstractImporter::openData(Containers::ArrayView<const char> data) {
CORRADE_ASSERT(features() & Feature::OpenData, CORRADE_ASSERT(features() & ImporterFeature::OpenData,
"Audio::AbstractImporter::openData(): feature not supported", {}); "Audio::AbstractImporter::openData(): feature not supported", {});
close(); close();
@ -100,7 +100,7 @@ bool AbstractImporter::openFile(const std::string& filename) {
} }
void AbstractImporter::doOpenFile(const std::string& filename) { void AbstractImporter::doOpenFile(const std::string& filename) {
CORRADE_ASSERT(features() & Feature::OpenData, "Audio::AbstractImporter::openFile(): not implemented", ); CORRADE_ASSERT(features() & ImporterFeature::OpenData, "Audio::AbstractImporter::openFile(): not implemented", );
/* Open file */ /* Open file */
if(!Utility::Directory::exists(filename)) { if(!Utility::Directory::exists(filename)) {
@ -136,12 +136,12 @@ Containers::Array<char> AbstractImporter::data() {
return out; return out;
} }
Debug& operator<<(Debug& debug, const AbstractImporter::Feature value) { Debug& operator<<(Debug& debug, const ImporterFeature value) {
debug << "Audio::AbstractImporter::Feature" << Debug::nospace; debug << "Audio::ImporterFeature" << Debug::nospace;
switch(value) { switch(value) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
#define _c(v) case AbstractImporter::Feature::v: return debug << "::" #v; #define _c(v) case ImporterFeature::v: return debug << "::" #v;
_c(OpenData) _c(OpenData)
#undef _c #undef _c
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
@ -150,9 +150,9 @@ Debug& operator<<(Debug& debug, const AbstractImporter::Feature value) {
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")"; return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
} }
Debug& operator<<(Debug& debug, const AbstractImporter::Features value) { Debug& operator<<(Debug& debug, const ImporterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, "Audio::AbstractImporter::Features{}", { return Containers::enumSetDebugOutput(debug, value, "Audio::ImporterFeatures{}", {
AbstractImporter::Feature::OpenData}); ImporterFeature::OpenData});
} }
}} }}

73
src/Magnum/Audio/AbstractImporter.h

@ -36,6 +36,33 @@
namespace Magnum { namespace Audio { namespace Magnum { namespace Audio {
/**
@brief Features supported by an audio importer
@m_since_latest
@see @ref ImporterFeatures, @ref AbstractImporter::features()
*/
enum class ImporterFeature: UnsignedByte {
/** Opening files from raw data using @ref AbstractImporter::openData() */
OpenData = 1 << 0
};
/**
@brief Features supported by an audio importer
@m_since_latest
@see @ref AbstractImporter::features()
*/
typedef Containers::EnumSet<ImporterFeature> ImporterFeatures;
CORRADE_ENUMSET_OPERATORS(ImporterFeatures)
/** @debugoperatorenum{ImporterFeatures} */
MAGNUM_AUDIO_EXPORT Debug& operator<<(Debug& debug, ImporterFeature value);
/** @debugoperatorenum{ImporterFeatures} */
MAGNUM_AUDIO_EXPORT Debug& operator<<(Debug& debug, ImporterFeatures value);
/** /**
@brief Base for audio importer plugins @brief Base for audio importer plugins
@ -64,8 +91,8 @@ checked by the implementation:
- Functions @ref doOpenData() and @ref doOpenFile() are called after the - Functions @ref doOpenData() and @ref doOpenFile() are called after the
previous file was closed, function @ref doClose() is called only if there previous file was closed, function @ref doClose() is called only if there
is any file opened. is any file opened.
- Function @ref doOpenData() is called only if @ref Feature::OpenData is - Function @ref doOpenData() is called only if @ref ImporterFeature::OpenData
supported. is supported.
- All `do*()` implementations working on opened file are called only if - All `do*()` implementations working on opened file are called only if
there is any file opened. there is any file opened.
@ -81,22 +108,17 @@ checked by the implementation:
*/ */
class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlugin<AbstractImporter> { class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlugin<AbstractImporter> {
public: public:
/** #ifdef MAGNUM_BUILD_DEPRECATED
* @brief Features supported by this importer /** @brief @copybrief ImporterFeature
* * @m_deprecated_since_latest Use @ref ImporterFeature instead.
* @see @ref Features, @ref features()
*/ */
enum class Feature: UnsignedByte { typedef CORRADE_DEPRECATED("use ImporterFeature instead") ImporterFeature Feature;
/** Opening files from raw data using @ref openData() */
OpenData = 1 << 0
};
/** /** @brief @copybrief ImporterFeatures
* @brief Features supported by this importer * @m_deprecated_since_latest Use @ref ImporterFeatures instead.
*
* @see @ref features()
*/ */
typedef Containers::EnumSet<Feature> Features; typedef CORRADE_DEPRECATED("use ImporterFeatures instead") ImporterFeatures Features;
#endif
/** /**
* @brief Plugin interface * @brief Plugin interface
@ -136,7 +158,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi
explicit AbstractImporter(PluginManager::AbstractManager& manager, const std::string& plugin); explicit AbstractImporter(PluginManager::AbstractManager& manager, const std::string& plugin);
/** @brief Features supported by this importer */ /** @brief Features supported by this importer */
Features features() const { return doFeatures(); } ImporterFeatures features() const { return doFeatures(); }
/** @brief Whether any file is opened */ /** @brief Whether any file is opened */
bool isOpened() const { return doIsOpened(); } bool isOpened() const { return doIsOpened(); }
@ -145,8 +167,8 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* @brief Open raw data * @brief Open raw data
* *
* Closes previous file, if it was opened, and tries to open given * Closes previous file, if it was opened, and tries to open given
* file. Available only if @ref Feature::OpenData is supported. Returns * file. Available only if @ref ImporterFeature::OpenData is supported.
* @cpp true @ce on success, @cpp false @ce otherwise. * Returns @cpp true @ce on success, @cpp false @ce otherwise.
* @see @ref features(), @ref openFile() * @see @ref features(), @ref openFile()
*/ */
bool openData(Containers::ArrayView<const char> data); bool openData(Containers::ArrayView<const char> data);
@ -178,7 +200,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi
private: private:
/** @brief Implementation for @ref features() */ /** @brief Implementation for @ref features() */
virtual Features doFeatures() const = 0; virtual ImporterFeatures doFeatures() const = 0;
/** @brief Implementation for @ref isOpened() */ /** @brief Implementation for @ref isOpened() */
virtual bool doIsOpened() const = 0; virtual bool doIsOpened() const = 0;
@ -189,8 +211,9 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi
/** /**
* @brief Implementation for @ref openFile() * @brief Implementation for @ref openFile()
* *
* If @ref Feature::OpenData is supported, default implementation opens * If @ref ImporterFeature::OpenData is supported, default
* the file and calls @ref doOpenData() with its contents. * implementation opens the file and calls @ref doOpenData() with its
* contents.
*/ */
virtual void doOpenFile(const std::string& filename); virtual void doOpenFile(const std::string& filename);
@ -207,14 +230,6 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi
virtual Containers::Array<char> doData() = 0; virtual Containers::Array<char> doData() = 0;
}; };
CORRADE_ENUMSET_OPERATORS(AbstractImporter::Features)
/** @debugoperatorclassenum{AbstractImporter,AbstractImporter::Feature} */
MAGNUM_AUDIO_EXPORT Debug& operator<<(Debug& debug, AbstractImporter::Feature value);
/** @debugoperatorclassenum{AbstractImporter,AbstractImporter::Features} */
MAGNUM_AUDIO_EXPORT Debug& operator<<(Debug& debug, AbstractImporter::Features value);
}} }}
#endif #endif

38
src/Magnum/Audio/Test/AbstractImporterTest.cpp

@ -94,7 +94,7 @@ AbstractImporterTest::AbstractImporterTest() {
void AbstractImporterTest::construct() { void AbstractImporterTest::construct() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -103,7 +103,7 @@ void AbstractImporterTest::construct() {
Containers::Array<char> doData() override { return nullptr; } Containers::Array<char> doData() override { return nullptr; }
} importer; } importer;
CORRADE_COMPARE(importer.features(), AbstractImporter::Features{}); CORRADE_COMPARE(importer.features(), ImporterFeatures{});
CORRADE_VERIFY(!importer.isOpened()); CORRADE_VERIFY(!importer.isOpened());
importer.close(); importer.close();
@ -112,7 +112,7 @@ void AbstractImporterTest::construct() {
void AbstractImporterTest::openData() { void AbstractImporterTest::openData() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return Feature::OpenData; } ImporterFeatures doFeatures() const override { return ImporterFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } void doClose() override { _opened = false; }
@ -138,7 +138,7 @@ void AbstractImporterTest::openData() {
void AbstractImporterTest::openFileAsData() { void AbstractImporterTest::openFileAsData() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return Feature::OpenData; } ImporterFeatures doFeatures() const override { return ImporterFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } void doClose() override { _opened = false; }
@ -164,7 +164,7 @@ void AbstractImporterTest::openFileAsData() {
void AbstractImporterTest::openFileAsDataNotFound() { void AbstractImporterTest::openFileAsDataNotFound() {
struct Importer: AbstractImporter { struct Importer: AbstractImporter {
Features doFeatures() const override { return Feature::OpenData; } ImporterFeatures doFeatures() const override { return ImporterFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } void doClose() override { _opened = false; }
@ -189,7 +189,7 @@ void AbstractImporterTest::openFileAsDataNotFound() {
void AbstractImporterTest::openFileNotImplemented() { void AbstractImporterTest::openFileNotImplemented() {
struct Importer: AbstractImporter { struct Importer: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -207,7 +207,7 @@ void AbstractImporterTest::openFileNotImplemented() {
void AbstractImporterTest::openDataNotSupported() { void AbstractImporterTest::openDataNotSupported() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -225,7 +225,7 @@ void AbstractImporterTest::openDataNotSupported() {
void AbstractImporterTest::openDataNotImplemented() { void AbstractImporterTest::openDataNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return Feature::OpenData; } ImporterFeatures doFeatures() const override { return ImporterFeature::OpenData; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -243,7 +243,7 @@ void AbstractImporterTest::openDataNotImplemented() {
void AbstractImporterTest::format() { void AbstractImporterTest::format() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -257,7 +257,7 @@ void AbstractImporterTest::format() {
void AbstractImporterTest::formatNoFile() { void AbstractImporterTest::formatNoFile() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -275,7 +275,7 @@ void AbstractImporterTest::formatNoFile() {
void AbstractImporterTest::frequency() { void AbstractImporterTest::frequency() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -289,7 +289,7 @@ void AbstractImporterTest::frequency() {
void AbstractImporterTest::frequencyNoFile() { void AbstractImporterTest::frequencyNoFile() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -307,7 +307,7 @@ void AbstractImporterTest::frequencyNoFile() {
void AbstractImporterTest::data() { void AbstractImporterTest::data() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -325,7 +325,7 @@ void AbstractImporterTest::data() {
void AbstractImporterTest::dataNoFile() { void AbstractImporterTest::dataNoFile() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -343,7 +343,7 @@ void AbstractImporterTest::dataNoFile() {
void AbstractImporterTest::dataCustomDeleter() { void AbstractImporterTest::dataCustomDeleter() {
struct: AbstractImporter { struct: AbstractImporter {
Features doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -364,15 +364,15 @@ void AbstractImporterTest::dataCustomDeleter() {
void AbstractImporterTest::debugFeature() { void AbstractImporterTest::debugFeature() {
std::ostringstream out; std::ostringstream out;
Debug{&out} << AbstractImporter::Feature::OpenData << AbstractImporter::Feature(0xf0); Debug{&out} << ImporterFeature::OpenData << ImporterFeature(0xf0);
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::Feature::OpenData Audio::AbstractImporter::Feature(0xf0)\n"); CORRADE_COMPARE(out.str(), "Audio::ImporterFeature::OpenData Audio::ImporterFeature(0xf0)\n");
} }
void AbstractImporterTest::debugFeatures() { void AbstractImporterTest::debugFeatures() {
std::ostringstream out; std::ostringstream out;
Debug{&out} << AbstractImporter::Feature::OpenData << AbstractImporter::Features{}; Debug{&out} << ImporterFeature::OpenData << ImporterFeatures{};
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::Feature::OpenData Audio::AbstractImporter::Features{}\n"); CORRADE_COMPARE(out.str(), "Audio::ImporterFeature::OpenData Audio::ImporterFeatures{}\n");
} }
}}}} }}}}

30
src/Magnum/Text/AbstractFont.cpp

@ -85,7 +85,7 @@ AbstractFont::AbstractFont(PluginManager::AbstractManager& manager, const std::s
void AbstractFont::setFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*callback)(const std::string&, InputFileCallbackPolicy, void*), void* const userData) { void AbstractFont::setFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*callback)(const std::string&, InputFileCallbackPolicy, void*), void* const userData) {
CORRADE_ASSERT(!isOpened(), "Text::AbstractFont::setFileCallback(): can't be set while a font is opened", ); CORRADE_ASSERT(!isOpened(), "Text::AbstractFont::setFileCallback(): can't be set while a font is opened", );
CORRADE_ASSERT(features() & (Feature::FileCallback|Feature::OpenData), "Text::AbstractFont::setFileCallback(): font plugin supports neither loading from data nor via callbacks, callbacks can't be used", ); CORRADE_ASSERT(features() & (FontFeature::FileCallback|FontFeature::OpenData), "Text::AbstractFont::setFileCallback(): font plugin supports neither loading from data nor via callbacks, callbacks can't be used", );
_fileCallback = callback; _fileCallback = callback;
_fileCallbackUserData = userData; _fileCallbackUserData = userData;
@ -95,7 +95,7 @@ void AbstractFont::setFileCallback(Containers::Optional<Containers::ArrayView<co
void AbstractFont::doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) {} void AbstractFont::doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) {}
bool AbstractFont::openData(Containers::ArrayView<const char> data, const Float size) { bool AbstractFont::openData(Containers::ArrayView<const char> data, const Float size) {
CORRADE_ASSERT(features() & Feature::OpenData, CORRADE_ASSERT(features() & FontFeature::OpenData,
"Text::AbstractFont::openData(): feature not supported", false); "Text::AbstractFont::openData(): feature not supported", false);
/* We accept empty data here (instead of checking for them and failing so /* We accept empty data here (instead of checking for them and failing so
@ -139,13 +139,13 @@ bool AbstractFont::openFile(const std::string& filename, const Float size) {
/* If file loading callbacks are not set or the font implementation /* If file loading callbacks are not set or the font implementation
supports handling them directly, call into the implementation */ supports handling them directly, call into the implementation */
if(!_fileCallback || (doFeatures() & Feature::FileCallback)) { if(!_fileCallback || (doFeatures() & FontFeature::FileCallback)) {
metrics = doOpenFile(filename, size); metrics = doOpenFile(filename, size);
/* Otherwise, if loading from data is supported, use the callback and pass /* Otherwise, if loading from data is supported, use the callback and pass
the data through to openData(). Mark the file as ready to be closed once the data through to openData(). Mark the file as ready to be closed once
opening is finished. */ opening is finished. */
} else if(doFeatures() & Feature::OpenData) { } else if(doFeatures() & FontFeature::OpenData) {
/* This needs to be duplicated here and in the doOpenFile() /* This needs to be duplicated here and in the doOpenFile()
implementation in order to support both following cases: implementation in order to support both following cases:
- plugins that don't support FileCallback but have their own - plugins that don't support FileCallback but have their own
@ -176,7 +176,7 @@ bool AbstractFont::openFile(const std::string& filename, const Float size) {
} }
auto AbstractFont::doOpenFile(const std::string& filename, const Float size) -> Metrics { auto AbstractFont::doOpenFile(const std::string& filename, const Float size) -> Metrics {
CORRADE_ASSERT(features() & Feature::OpenData, "Text::AbstractFont::openFile(): not implemented", {}); CORRADE_ASSERT(features() & FontFeature::OpenData, "Text::AbstractFont::openFile(): not implemented", {});
Metrics metrics; Metrics metrics;
@ -248,7 +248,7 @@ Vector2 AbstractFont::glyphAdvance(const UnsignedInt glyph) {
void AbstractFont::fillGlyphCache(AbstractGlyphCache& cache, const std::string& characters) { void AbstractFont::fillGlyphCache(AbstractGlyphCache& cache, const std::string& characters) {
CORRADE_ASSERT(isOpened(), CORRADE_ASSERT(isOpened(),
"Text::AbstractFont::fillGlyphCache(): no font opened", ); "Text::AbstractFont::fillGlyphCache(): no font opened", );
CORRADE_ASSERT(!(features() & Feature::PreparedGlyphCache), CORRADE_ASSERT(!(features() & FontFeature::PreparedGlyphCache),
"Text::AbstractFont::fillGlyphCache(): feature not supported", ); "Text::AbstractFont::fillGlyphCache(): feature not supported", );
doFillGlyphCache(cache, Utility::Unicode::utf32(characters)); doFillGlyphCache(cache, Utility::Unicode::utf32(characters));
@ -261,7 +261,7 @@ void AbstractFont::doFillGlyphCache(AbstractGlyphCache&, const std::u32string&)
Containers::Pointer<AbstractGlyphCache> AbstractFont::createGlyphCache() { Containers::Pointer<AbstractGlyphCache> AbstractFont::createGlyphCache() {
CORRADE_ASSERT(isOpened(), CORRADE_ASSERT(isOpened(),
"Text::AbstractFont::createGlyphCache(): no font opened", nullptr); "Text::AbstractFont::createGlyphCache(): no font opened", nullptr);
CORRADE_ASSERT(features() & Feature::PreparedGlyphCache, CORRADE_ASSERT(features() & FontFeature::PreparedGlyphCache,
"Text::AbstractFont::createGlyphCache(): feature not supported", nullptr); "Text::AbstractFont::createGlyphCache(): feature not supported", nullptr);
return doCreateGlyphCache(); return doCreateGlyphCache();
@ -278,12 +278,12 @@ Containers::Pointer<AbstractLayouter> AbstractFont::layout(const AbstractGlyphCa
return doLayout(cache, size, text); return doLayout(cache, size, text);
} }
Debug& operator<<(Debug& debug, const AbstractFont::Feature value) { Debug& operator<<(Debug& debug, const FontFeature value) {
debug << "Text::AbstractFont::Feature" << Debug::nospace; debug << "Text::FontFeature" << Debug::nospace;
switch(value) { switch(value) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
#define _c(v) case AbstractFont::Feature::v: return debug << "::" #v; #define _c(v) case FontFeature::v: return debug << "::" #v;
_c(OpenData) _c(OpenData)
_c(FileCallback) _c(FileCallback)
_c(PreparedGlyphCache) _c(PreparedGlyphCache)
@ -294,11 +294,11 @@ Debug& operator<<(Debug& debug, const AbstractFont::Feature value) {
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")"; return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
} }
Debug& operator<<(Debug& debug, const AbstractFont::Features value) { Debug& operator<<(Debug& debug, const FontFeatures value) {
return Containers::enumSetDebugOutput(debug, value, "Text::AbstractFont::Features{}", { return Containers::enumSetDebugOutput(debug, value, "Text::FontFeatures{}", {
AbstractFont::Feature::OpenData, FontFeature::OpenData,
AbstractFont::Feature::FileCallback, FontFeature::FileCallback,
AbstractFont::Feature::PreparedGlyphCache}); FontFeature::PreparedGlyphCache});
} }
AbstractLayouter::AbstractLayouter(UnsignedInt glyphCount): _glyphCount(glyphCount) {} AbstractLayouter::AbstractLayouter(UnsignedInt glyphCount): _glyphCount(glyphCount) {}

185
src/Magnum/Text/AbstractFont.h

@ -44,6 +44,63 @@
namespace Magnum { namespace Text { namespace Magnum { namespace Text {
/**
@brief Features supported by a font implementation
@m_since_latest
@see @ref FontFeatures, @ref AbstractFont::features()
*/
enum class FontFeature: UnsignedByte {
/** Opening fonts from raw data using @ref AbstractFont::openData() */
OpenData = 1 << 0,
/**
* Specifying callbacks for loading additional files referenced from the
* main file using @ref AbstractFont::setFileCallback(). If the font
* doesn't expose this feature, the format is either single-file or loading
* via callbacks is not supported.
*
* See @ref Text-AbstractFont-usage-callbacks and particular font plugin
* documentation for more information.
* @m_since{2019,10}
*/
FileCallback = 1 << 1,
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* The format is multi-file, thus @ref AbstractFont::openSingleData()
* convenience function cannot be used.
* @m_deprecated_since{2019,10} Obsolete, use file callbacks
* instead.
*/
MultiFile CORRADE_DEPRECATED_ENUM("obsolete, use file callbacks instead") = FileCallback,
#endif
/**
* The font contains prepared glyph cache.
*
* @see @ref AbstractFont::fillGlyphCache(),
* @ref AbstractFont::createGlyphCache()
*/
PreparedGlyphCache = 1 << 2
};
/**
@brief Set of features supported by a font implementation
@m_since_latest
@see @ref AbstractFont::features()
*/
typedef Containers::EnumSet<FontFeature> FontFeatures;
CORRADE_ENUMSET_OPERATORS(FontFeatures)
/** @debugoperatorenum{FontFeature} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, FontFeature value);
/** @debugoperatorenum{FontFeatures} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, FontFeatures value);
/** /**
@brief Base for font plugins @brief Base for font plugins
@ -68,13 +125,13 @@ information about actual text rendering.
Besides loading data directly from the filesystem using @ref openFile() like Besides loading data directly from the filesystem using @ref openFile() like
shown above, it's possible to use @ref openData() to import data from memory. shown above, it's possible to use @ref openData() to import data from memory.
Note that the particular importer implementation must support Note that the particular importer implementation must support
@ref Feature::OpenData for this method to work. @ref FontFeature::OpenData for this method to work.
Some font formats consist of more than one file and in that case you may want Some font formats consist of more than one file and in that case you may want
to intercept those references and load them in a custom way as well. For font to intercept those references and load them in a custom way as well. For font
plugins that advertise support for this with @ref Feature::FileCallback this is plugins that advertise support for this with @ref FontFeature::FileCallback
done by specifying a file loading callback using @ref setFileCallback(). The this is done by specifying a file loading callback using @ref setFileCallback().
callback gets a filename, @ref InputFileCallbackPolicy and an user The callback gets a filename, @ref InputFileCallbackPolicy and an user
pointer as parameters; returns a non-owning view on the loaded data or a pointer as parameters; returns a non-owning view on the loaded data or a
@ref Corrade::Containers::NullOpt "Containers::NullOpt" to indicate the file @ref Corrade::Containers::NullOpt "Containers::NullOpt" to indicate the file
loading failed. For example, loading a memory-mapped font could look like loading failed. For example, loading a memory-mapped font could look like
@ -85,12 +142,12 @@ correctly.
@snippet MagnumText.cpp AbstractFont-usage-callbacks @snippet MagnumText.cpp AbstractFont-usage-callbacks
For importers that don't support @ref Feature::FileCallback directly, the base For importers that don't support @ref FontFeature::FileCallback directly, the
@ref openFile() implementation will use the file callback to pass the loaded base @ref openFile() implementation will use the file callback to pass the
data through to @ref openData(), in case the importer supports at least loaded data through to @ref openData(), in case the importer supports at least
@ref Feature::OpenData. If the importer supports neither @ref Feature::FileCallback @ref FontFeature::OpenData. If the importer supports neither
nor @ref Feature::OpenData, @ref setFileCallback() doesn't allow the callbacks @ref FontFeature::FileCallback nor @ref FontFeature::OpenData,
to be set. @ref setFileCallback() doesn't allow the callbacks to be set.
The input file callback signature is the same for @ref Text::AbstractFont and The input file callback signature is the same for @ref Text::AbstractFont and
@ref Trade::AbstractImporter to allow code reuse. @ref Trade::AbstractImporter to allow code reuse.
@ -107,56 +164,26 @@ checked by the implementation:
- Functions @ref doOpenData() and @ref doOpenFile() are called after the - Functions @ref doOpenData() and @ref doOpenFile() are called after the
previous file was closed, function @ref doClose() is called only if there previous file was closed, function @ref doClose() is called only if there
is any file opened. is any file opened.
- Function @ref doOpenData() is called only if @ref Feature::OpenData is - Function @ref doOpenData() is called only if @ref FontFeature::OpenData is
supported. supported.
- The @ref doSetFileCallback() function is called only if - The @ref doSetFileCallback() function is called only if
@ref Feature::FileCallback is supported and there is no file opened. @ref FontFeature::FileCallback is supported and there is no file opened.
- All `do*()` implementations working on opened file are called only if - All `do*()` implementations working on opened file are called only if
there is any file opened. there is any file opened.
*/ */
class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
public: public:
/** #ifdef MAGNUM_BUILD_DEPRECATED
* @brief Features supported by this font implementation /** @brief @copybrief FontFeature
* * @m_deprecated_since_latest Use @ref FontFeature instead.
* @see @ref Features, @ref features()
*/ */
enum class Feature: UnsignedByte { typedef CORRADE_DEPRECATED("use FontFeature instead") FontFeature Feature;
/** Opening fonts from raw data using @ref openData() */
OpenData = 1 << 0,
/** /** @brief @copybrief FontFeatures
* Specifying callbacks for loading additional files referenced * @m_deprecated_since_latest Use @ref FontFeatures instead.
* from the main file using @ref setFileCallback(). If the font */
* doesn't expose this feature, the format is either single-file or typedef CORRADE_DEPRECATED("use FontFeatures instead") FontFeatures Features;
* loading via callbacks is not supported. #endif
*
* See @ref Text-AbstractFont-usage-callbacks and particular font
* plugin documentation for more information.
* @m_since{2019,10}
*/
FileCallback = 1 << 1,
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* The format is multi-file, thus @ref openSingleData() convenience
* function cannot be used.
* @m_deprecated_since{2019,10} Obsolete, use file callbacks
* instead.
*/
MultiFile CORRADE_DEPRECATED_ENUM("obsolete, use file callbacks instead") = FileCallback,
#endif
/**
* The font contains prepared glyph cache.
*
* @see @ref fillGlyphCache(), @ref createGlyphCache()
*/
PreparedGlyphCache = 1 << 2
};
/** @brief Set of features supported by this font implementation */
typedef Containers::EnumSet<Feature> Features;
/** /**
* @brief Plugin interface * @brief Plugin interface
@ -193,7 +220,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
explicit AbstractFont(PluginManager::AbstractManager& manager, const std::string& plugin); explicit AbstractFont(PluginManager::AbstractManager& manager, const std::string& plugin);
/** @brief Features supported by this font */ /** @brief Features supported by this font */
Features features() const { return doFeatures(); } FontFeatures features() const { return doFeatures(); }
/** /**
* @brief File opening callback function * @brief File opening callback function
@ -215,22 +242,22 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @brief Set file opening callback * @brief Set file opening callback
* @m_since{2019,10} * @m_since{2019,10}
* *
* In case the font plugin supports @ref Feature::FileCallback, files * In case the font plugin supports @ref FontFeature::FileCallback,
* opened through @ref openFile() will be loaded through the provided * files opened through @ref openFile() will be loaded through the
* callback. Besides that, all external files referenced by the * provided callback. Besides that, all external files referenced by
* top-level file will be loaded through the callback function as well, * the top-level file will be loaded through the callback function as
* usually on demand. The callback function gets a filename, * well, usually on demand. The callback function gets a filename,
* @ref InputFileCallbackPolicy and the @p userData pointer as input * @ref InputFileCallbackPolicy and the @p userData pointer as input
* and returns a non-owning view on the loaded data as output or a * and returns a non-owning view on the loaded data as output or a
* @ref Corrade::Containers::NullOpt if loading failed --- because * @ref Corrade::Containers::NullOpt if loading failed --- because
* empty files might also be valid in some circumstances, @cpp nullptr @ce * empty files might also be valid in some circumstances, @cpp nullptr @ce
* can't be used to indicate a failure. * can't be used to indicate a failure.
* *
* In case the font plugin doesn't support @ref Feature::FileCallback but * In case the font plugin doesn't support @ref FontFeature::FileCallback
* supports at least @ref Feature::OpenData, a file opened through * but supports at least @ref FontFeature::OpenData, a file opened
* @ref openFile() will be internally loaded through the provided * through @ref openFile() will be internally loaded through the
* callback and then passed to @ref openData(). First the file is * provided callback and then passed to @ref openData(). First the file
* loaded with @ref InputFileCallbackPolicy::LoadTemporary passed to * is loaded with @ref InputFileCallbackPolicy::LoadTemporary passed to
* the callback, then the returned memory view is passed to * the callback, then the returned memory view is passed to
* @ref openData() (sidestepping the potential @ref openFile() * @ref openData() (sidestepping the potential @ref openFile()
* implementation of that particular font plugin) and after that the * implementation of that particular font plugin) and after that the
@ -241,8 +268,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* *
* In case @p callback is @cpp nullptr @ce, the current callback (if * In case @p callback is @cpp nullptr @ce, the current callback (if
* any) is reset. This function expects that the font plugin supports * any) is reset. This function expects that the font plugin supports
* either @ref Feature::FileCallback or @ref Feature::OpenData. If an * either @ref FontFeature::FileCallback or @ref FontFeature::OpenData.
* font plugin supports neither, callbacks can't be used. * If a font plugin supports neither, callbacks can't be used.
* *
* It's expected that this function is called *before* a file is * It's expected that this function is called *before* a file is
* opened. It's also expected that the loaded data are kept in scope * opened. It's also expected that the loaded data are kept in scope
@ -292,8 +319,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param size Font size * @param size Font size
* *
* Closes previous file, if it was opened, and tries to open given * Closes previous file, if it was opened, and tries to open given
* file. Available only if @ref Feature::OpenData is supported. Returns * file. Available only if @ref FontFeature::OpenData is supported.
* @cpp true @ce on success, @cpp false @ce otherwise. * Returns @cpp true @ce on success, @cpp false @ce otherwise.
* @see @ref features(), @ref openFile() * @see @ref features(), @ref openFile()
*/ */
bool openData(Containers::ArrayView<const char> data, Float size); bool openData(Containers::ArrayView<const char> data, Float size);
@ -318,8 +345,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param size Font size * @param size Font size
* *
* Closes previous file, if it was opened, and tries to open given * Closes previous file, if it was opened, and tries to open given
* file. If the plugin has @ref Feature::MultiFile, the function will * file. If the plugin has @ref FontFeature::MultiFile, the function
* use additional files in given path, all sharing common basename * will use additional files in given path, all sharing common basename
* derived from @p filename. Returns @cpp true @ce on success, * derived from @p filename. Returns @cpp true @ce on success,
* @cpp false @ce otherwise. * @cpp false @ce otherwise.
*/ */
@ -393,9 +420,9 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param characters UTF-8 characters to render * @param characters UTF-8 characters to render
* *
* Fills the cache with given characters. Fonts having * Fills the cache with given characters. Fonts having
* @ref Feature::PreparedGlyphCache do not support partial glyph cache * @ref FontFeature::PreparedGlyphCache do not support partial glyph
* filling, use @ref createGlyphCache() instead. Expects that a font is * cache filling, use @ref createGlyphCache() instead. Expects that a
* opened. * font is opened.
*/ */
void fillGlyphCache(AbstractGlyphCache& cache, const std::string& characters); void fillGlyphCache(AbstractGlyphCache& cache, const std::string& characters);
@ -403,7 +430,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @brief Create glyph cache * @brief Create glyph cache
* *
* Configures and fills glyph cache with the contents of whole font. * Configures and fills glyph cache with the contents of whole font.
* Available only if @ref Feature::PreparedGlyphCache is supported. * Available only if @ref FontFeature::PreparedGlyphCache is supported.
* Other fonts support only partial glyph cache filling, see * Other fonts support only partial glyph cache filling, see
* @ref fillGlyphCache(). Expects that a font is opened. * @ref fillGlyphCache(). Expects that a font is opened.
*/ */
@ -465,7 +492,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @brief Implementation for @ref openFile() * @brief Implementation for @ref openFile()
* *
* Return metrics of opened font on successful opening, zeros * Return metrics of opened font on successful opening, zeros
* otherwise. If @ref Feature::OpenData is supported, default * otherwise. If @ref FontFeature::OpenData is supported, default
* implementation opens the file and calls @ref doOpenData() with its * implementation opens the file and calls @ref doOpenData() with its
* contents. It is allowed to call this function from your * contents. It is allowed to call this function from your
* @ref doOpenFile() implementation --- in particular, this * @ref doOpenFile() implementation --- in particular, this
@ -473,7 +500,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @ref setFileCallback(). * @ref setFileCallback().
* *
* This function is not called when file callbacks are set through * This function is not called when file callbacks are set through
* @ref setFileCallback() and @ref Feature::FileCallback is not * @ref setFileCallback() and @ref FontFeature::FileCallback is not
* supported --- instead, file is loaded though the callback and data * supported --- instead, file is loaded though the callback and data
* passed through to @ref doOpenData(). * passed through to @ref doOpenData().
*/ */
@ -481,7 +508,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
private: private:
/** @brief Implementation for @ref features() */ /** @brief Implementation for @ref features() */
virtual Features doFeatures() const = 0; virtual FontFeatures doFeatures() const = 0;
/** /**
* @brief Implementation for @ref setFileCallback() * @brief Implementation for @ref setFileCallback()
@ -541,14 +568,6 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
Float _size{}, _ascent{}, _descent{}, _lineHeight{}; Float _size{}, _ascent{}, _descent{}, _lineHeight{};
}; };
CORRADE_ENUMSET_OPERATORS(AbstractFont::Features)
/** @debugoperatorclassenum{AbstractFont,AbstractFont::Feature} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, AbstractFont::Feature value);
/** @debugoperatorclassenum{AbstractFont,AbstractFont::Features} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, AbstractFont::Features value);
/** /**
@brief Base for text layouters @brief Base for text layouters

64
src/Magnum/Text/AbstractFontConverter.cpp

@ -27,6 +27,7 @@
#include <algorithm> #include <algorithm>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
@ -98,14 +99,14 @@ AbstractFontConverter::AbstractFontConverter() = default;
AbstractFontConverter::AbstractFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin): PluginManager::AbstractPlugin{manager, plugin} {} AbstractFontConverter::AbstractFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin): PluginManager::AbstractPlugin{manager, plugin} {}
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::exportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::string& characters) const { std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::exportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::string& characters) const {
CORRADE_ASSERT(features() >= (Feature::ExportFont|Feature::ConvertData), CORRADE_ASSERT(features() >= (FontConverterFeature::ExportFont|FontConverterFeature::ConvertData),
"Text::AbstractFontConverter::exportFontToData(): feature not supported", {}); "Text::AbstractFontConverter::exportFontToData(): feature not supported", {});
return doExportFontToData(font, cache, filename, uniqueUnicode(characters)); return doExportFontToData(font, cache, filename, uniqueUnicode(characters));
} }
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const { std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const {
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & FontConverterFeature::MultiFile),
"Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", {}); "Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", {});
std::vector<std::pair<std::string, Containers::Array<char>>> out; std::vector<std::pair<std::string, Containers::Array<char>>> out;
@ -114,9 +115,9 @@ std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConvert
} }
Containers::Array<char> AbstractFontConverter::exportFontToSingleData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& characters) const { Containers::Array<char> AbstractFontConverter::exportFontToSingleData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& characters) const {
CORRADE_ASSERT(features() >= (Feature::ExportFont|Feature::ConvertData), CORRADE_ASSERT(features() >= (FontConverterFeature::ExportFont|FontConverterFeature::ConvertData),
"Text::AbstractFontConverter::exportFontToSingleData(): feature not supported", nullptr); "Text::AbstractFontConverter::exportFontToSingleData(): feature not supported", nullptr);
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & FontConverterFeature::MultiFile),
"Text::AbstractFontConverter::exportFontToSingleData(): the format is not single-file", nullptr); "Text::AbstractFontConverter::exportFontToSingleData(): the format is not single-file", nullptr);
return doExportFontToSingleData(font, cache, uniqueUnicode(characters)); return doExportFontToSingleData(font, cache, uniqueUnicode(characters));
@ -129,14 +130,14 @@ Containers::Array<char> AbstractFontConverter::doExportFontToSingleData(Abstract
} }
bool AbstractFontConverter::exportFontToFile(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::string& characters) const { bool AbstractFontConverter::exportFontToFile(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::string& characters) const {
CORRADE_ASSERT(features() & Feature::ExportFont, CORRADE_ASSERT(features() & FontConverterFeature::ExportFont,
"Text::AbstractFontConverter::exportFontToFile(): feature not supported", false); "Text::AbstractFontConverter::exportFontToFile(): feature not supported", false);
return doExportFontToFile(font, cache, filename, uniqueUnicode(characters)); return doExportFontToFile(font, cache, filename, uniqueUnicode(characters));
} }
bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const { bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const {
CORRADE_ASSERT(features() & Feature::ConvertData, CORRADE_ASSERT(features() & FontConverterFeature::ConvertData,
"Text::AbstractFontConverter::exportFontToFile(): not implemented", false); "Text::AbstractFontConverter::exportFontToFile(): not implemented", false);
/* Export all data */ /* Export all data */
@ -152,14 +153,14 @@ bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, AbstractGlyph
} }
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::exportGlyphCacheToData(AbstractGlyphCache& cache, const std::string& filename) const { std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::exportGlyphCacheToData(AbstractGlyphCache& cache, const std::string& filename) const {
CORRADE_ASSERT(features() >= (Feature::ExportGlyphCache|Feature::ConvertData), CORRADE_ASSERT(features() >= (FontConverterFeature::ExportGlyphCache|FontConverterFeature::ConvertData),
"Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported", {}); "Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported", {});
return doExportGlyphCacheToData(cache, filename); return doExportGlyphCacheToData(cache, filename);
} }
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportGlyphCacheToData(AbstractGlyphCache& cache, const std::string& filename) const { std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportGlyphCacheToData(AbstractGlyphCache& cache, const std::string& filename) const {
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & FontConverterFeature::MultiFile),
"Text::AbstractFontConverter::exportGlyphCacheToData(): feature advertised but not implemented", {}); "Text::AbstractFontConverter::exportGlyphCacheToData(): feature advertised but not implemented", {});
std::vector<std::pair<std::string, Containers::Array<char>>> out; std::vector<std::pair<std::string, Containers::Array<char>>> out;
@ -168,9 +169,9 @@ std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConvert
} }
Containers::Array<char> AbstractFontConverter::exportGlyphCacheToSingleData(AbstractGlyphCache& cache) const { Containers::Array<char> AbstractFontConverter::exportGlyphCacheToSingleData(AbstractGlyphCache& cache) const {
CORRADE_ASSERT(features() >= (Feature::ExportGlyphCache|Feature::ConvertData), CORRADE_ASSERT(features() >= (FontConverterFeature::ExportGlyphCache|FontConverterFeature::ConvertData),
"Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature not supported", nullptr); "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature not supported", nullptr);
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & FontConverterFeature::MultiFile),
"Text::AbstractFontConverter::exportGlyphCacheToSingleData(): the format is not single-file", nullptr); "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): the format is not single-file", nullptr);
return doExportGlyphCacheToSingleData(cache); return doExportGlyphCacheToSingleData(cache);
@ -183,14 +184,14 @@ Containers::Array<char> AbstractFontConverter::doExportGlyphCacheToSingleData(Ab
} }
bool AbstractFontConverter::exportGlyphCacheToFile(AbstractGlyphCache& cache, const std::string& filename) const { bool AbstractFontConverter::exportGlyphCacheToFile(AbstractGlyphCache& cache, const std::string& filename) const {
CORRADE_ASSERT(features() & Feature::ExportGlyphCache, CORRADE_ASSERT(features() & FontConverterFeature::ExportGlyphCache,
"Text::AbstractFontConverter::exportGlyphCacheToFile(): feature not supported", false); "Text::AbstractFontConverter::exportGlyphCacheToFile(): feature not supported", false);
return doExportGlyphCacheToFile(cache, filename); return doExportGlyphCacheToFile(cache, filename);
} }
bool AbstractFontConverter::doExportGlyphCacheToFile(AbstractGlyphCache& cache, const std::string& filename) const { bool AbstractFontConverter::doExportGlyphCacheToFile(AbstractGlyphCache& cache, const std::string& filename) const {
CORRADE_ASSERT(features() & Feature::ConvertData, CORRADE_ASSERT(features() & FontConverterFeature::ConvertData,
"Text::AbstractFontConverter::exportGlyphCacheToFile(): not implemented", false); "Text::AbstractFontConverter::exportGlyphCacheToFile(): not implemented", false);
/* Export all data */ /* Export all data */
@ -206,7 +207,7 @@ bool AbstractFontConverter::doExportGlyphCacheToFile(AbstractGlyphCache& cache,
} }
Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::importGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const { Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::importGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const {
CORRADE_ASSERT(features() >= (Feature::ImportGlyphCache|Feature::ConvertData), CORRADE_ASSERT(features() >= (FontConverterFeature::ImportGlyphCache|FontConverterFeature::ConvertData),
"Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported", nullptr);
CORRADE_ASSERT(!data.empty(), CORRADE_ASSERT(!data.empty(),
"Text::AbstractFontConverter::importGlyphCacheFromData(): no data passed", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromData(): no data passed", nullptr);
@ -215,7 +216,7 @@ Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::importGlyphCacheF
} }
Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const { Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const {
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & FontConverterFeature::MultiFile),
"Text::AbstractFontConverter::importGlyphCacheFromData(): feature advertised but not implemented", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromData(): feature advertised but not implemented", nullptr);
CORRADE_ASSERT(data.size() == 1, CORRADE_ASSERT(data.size() == 1,
"Text::AbstractFontConverter::importGlyphCacheFromData(): expected just one file for single-file format", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromData(): expected just one file for single-file format", nullptr);
@ -224,9 +225,9 @@ Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCach
} }
Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::importGlyphCacheFromSingleData(Containers::ArrayView<const char> data) const { Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::importGlyphCacheFromSingleData(Containers::ArrayView<const char> data) const {
CORRADE_ASSERT(features() >= (Feature::ImportGlyphCache|Feature::ConvertData), CORRADE_ASSERT(features() >= (FontConverterFeature::ImportGlyphCache|FontConverterFeature::ConvertData),
"Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported", nullptr);
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & FontConverterFeature::MultiFile),
"Text::AbstractFontConverter::importGlyphCacheFromSingleData(): the format is not single-file", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): the format is not single-file", nullptr);
return doImportGlyphCacheFromSingleData(data); return doImportGlyphCacheFromSingleData(data);
@ -239,14 +240,14 @@ Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCach
} }
Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::importGlyphCacheFromFile(const std::string& filename) const { Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::importGlyphCacheFromFile(const std::string& filename) const {
CORRADE_ASSERT(features() & Feature::ImportGlyphCache, CORRADE_ASSERT(features() & FontConverterFeature::ImportGlyphCache,
"Text::AbstractFontConverter::importGlyphCacheFromFile(): feature not supported", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromFile(): feature not supported", nullptr);
return doImportGlyphCacheFromFile(filename); return doImportGlyphCacheFromFile(filename);
} }
Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCacheFromFile(const std::string& filename) const { Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCacheFromFile(const std::string& filename) const {
CORRADE_ASSERT(features() & Feature::ConvertData && !(features() & Feature::MultiFile), CORRADE_ASSERT(features() & FontConverterFeature::ConvertData && !(features() & FontConverterFeature::MultiFile),
"Text::AbstractFontConverter::importGlyphCacheFromFile(): not implemented", nullptr); "Text::AbstractFontConverter::importGlyphCacheFromFile(): not implemented", nullptr);
/* Open file */ /* Open file */
@ -258,4 +259,31 @@ Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCach
return doImportGlyphCacheFromSingleData(Utility::Directory::read(filename)); return doImportGlyphCacheFromSingleData(Utility::Directory::read(filename));
} }
Debug& operator<<(Debug& debug, const FontConverterFeature value) {
debug << "Text::FontConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case FontConverterFeature::v: return debug << "::" #v;
_c(ExportFont)
_c(ExportGlyphCache)
_c(ImportGlyphCache)
_c(ConvertData)
_c(MultiFile)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(Containers::enumCastUnderlyingType(value)) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const FontConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, "Text::FontConverterFeatures{}", {
FontConverterFeature::ExportFont,
FontConverterFeature::ExportGlyphCache,
FontConverterFeature::ImportGlyphCache,
FontConverterFeature::ConvertData,
FontConverterFeature::MultiFile});
}
}} }}

261
src/Magnum/Text/AbstractFontConverter.h

@ -49,6 +49,76 @@
namespace Magnum { namespace Text { namespace Magnum { namespace Text {
/**
@brief Features supported by a font converter
@m_since_latest
@see @ref FontConverterFeatures, @ref AbstractFontConverter::features()
*/
enum class FontConverterFeature: UnsignedByte {
/**
* Exporting font using @ref AbstractFontConverter::exportFontToFile(),
* @ref AbstractFontConverter::exportFontToData() or
* @ref AbstractFontConverter::exportFontToSingleData()
* @see @ref FontConverterFeature::ConvertData
*/
ExportFont = 1 << 0,
/**
* Export glyph cache using
* @ref AbstractFontConverter::exportGlyphCacheToFile(),
* @ref AbstractFontConverter::exportGlyphCacheToData() or
* @ref AbstractFontConverter::exportGlyphCacheToSingleData()
* @see @ref FontConverterFeature::ConvertData
*/
ExportGlyphCache = 1 << 1,
/**
* Import glyph cache using
* @ref AbstractFontConverter::importGlyphCacheFromFile(),
* @ref AbstractFontConverter::importGlyphCacheFromData() or
* @ref AbstractFontConverter::importGlyphCacheFromSingleData()
* @see @ref FontConverterFeature::ConvertData
*/
ImportGlyphCache = 1 << 2,
/**
* Convert from/to data using
* @ref AbstractFontConverter::exportFontToData(),
* @ref AbstractFontConverter::exportFontToSingleData(),
* @ref AbstractFontConverter::exportGlyphCacheToData(),
* @ref AbstractFontConverter::exportGlyphCacheToSingleData(),
* @ref AbstractFontConverter::importGlyphCacheFromData() or
* @ref AbstractFontConverter::importGlyphCacheFromSingleData()
*/
ConvertData = 1 << 4,
/**
* The format is multi-file, thus
* @ref AbstractFontConverter::exportFontToSingleData(),
* @ref AbstractFontConverter::exportGlyphCacheToSingleData() and
* @ref AbstractFontConverter::importGlyphCacheFromSingleData() convenience
* functions cannot be used.
*/
MultiFile = 1 << 5
};
/**
@brief Features supported by a font converter
@m_since_latest
@see @ref AbstractFontConverter::features()
*/
typedef Containers::EnumSet<FontConverterFeature> FontConverterFeatures;
CORRADE_ENUMSET_OPERATORS(FontConverterFeatures)
/** @debugoperatorenum{FontConverterFeature} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, FontConverterFeature value);
/** @debugoperatorenum{FontConverterFeatures} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, FontConverterFeatures value);
/** /**
@brief Base for font converter plugins @brief Base for font converter plugins
@ -69,13 +139,14 @@ characters.
You don't need to do most of the redundant sanity checks, these things are You don't need to do most of the redundant sanity checks, these things are
checked by the implementation: checked by the implementation:
- Functions `doExportFontTo*()` are called only if @ref Feature::ExportFont - Functions `doExportFontTo*()` are called only if
is supported, functions `doExportGlyphCacheTo*()` are called only if @ref FontConverterFeature::ExportFont is supported, functions
@ref Feature::ExportGlyphCache is supported. `doExportGlyphCacheTo*()` are called only if
@ref FontConverterFeature::ExportGlyphCache is supported.
- Functions `doImportGlyphCacheFrom*()` are called only if - Functions `doImportGlyphCacheFrom*()` are called only if
@ref Feature::ImportGlyphCache is supported. @ref FontConverterFeature::ImportGlyphCache is supported.
- Functions `doExport*To*Data()` and `doImport*From*Data()` are called only - Functions `doExport*To*Data()` and `doImport*From*Data()` are called only
if @ref Feature::ConvertData is supported. if @ref FontConverterFeature::ConvertData is supported.
- Function `doImport*FromData()` is called only if there is at least one data - Function `doImport*FromData()` is called only if there is at least one data
array passed. array passed.
@ -86,55 +157,17 @@ checked by the implementation:
*/ */
class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPlugin { class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPlugin {
public: public:
/** #ifdef MAGNUM_BUILD_DEPRECATED
* @brief Features supported by this converter /** @brief @copybrief FontConverterFeature
* * @m_deprecated_since_latest Use @ref FontConverterFeature instead.
* @see @ref Features, @ref features()
*/ */
enum class Feature: UnsignedByte { typedef CORRADE_DEPRECATED("use FontConverterFeature instead") FontConverterFeature Feature;
/**
* Exporting font using @ref exportFontToFile(), @ref exportFontToData()
* or @ref exportFontToSingleData()
* @see @ref Feature::ConvertData
*/
ExportFont = 1 << 0,
/**
* Export glyph cache using @ref exportGlyphCacheToFile(),
* @ref exportGlyphCacheToData() or @ref exportGlyphCacheToSingleData()
* @see @ref Feature::ConvertData
*/
ExportGlyphCache = 1 << 1,
/**
* Import glyph cache using @ref importGlyphCacheFromFile(),
* @ref importGlyphCacheFromData() or @ref importGlyphCacheFromSingleData()
* @see @ref Feature::ConvertData
*/
ImportGlyphCache = 1 << 2,
/**
* Convert from/to data using @ref exportFontToData(),
* @ref exportFontToSingleData(), @ref exportGlyphCacheToData(),
* @ref exportGlyphCacheToSingleData(), @ref importGlyphCacheFromData()
* or @ref importGlyphCacheFromSingleData()
*/
ConvertData = 1 << 4,
/**
* The format is multi-file, thus @ref exportFontToSingleData(),
* @ref exportGlyphCacheToSingleData() and @ref importGlyphCacheFromSingleData()
* convenience functions cannot be used.
*/
MultiFile = 1 << 5
};
/** /** @brief @copybrief FontConverterFeatures
* @brief Features supported by this converter * @m_deprecated_since_latest Use @ref FontConverterFeatures instead.
*
* @see @ref features()
*/ */
typedef Containers::EnumSet<Feature> Features; typedef CORRADE_DEPRECATED("use FontConverterFeatures instead") FontConverterFeatures Features;
#endif
/** /**
* @brief Plugin interface * @brief Plugin interface
@ -171,7 +204,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
explicit AbstractFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin); explicit AbstractFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin);
/** @brief Features supported by this converter */ /** @brief Features supported by this converter */
Features features() const { return doFeatures(); } FontConverterFeatures features() const { return doFeatures(); }
/** /**
* @brief Export font to raw data * @brief Export font to raw data
@ -180,12 +213,13 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* @param filename Output filename * @param filename Output filename
* @param characters Characters to export * @param characters Characters to export
* *
* Available only if @ref Feature::ConvertData and @ref Feature::ExportFont * Available only if @ref FontConverterFeature::ConvertData and
* is supported. Returns pairs of filename and data on success, empty * @ref FontConverterFeature::ExportFont is supported. Returns pairs of
* vector otherwise. All data will be sharing common basename derived * filename and data on success, empty vector otherwise. All data will
* from @p filename. If the plugin doesn't have @ref Feature::MultiFile, * be sharing common basename derived from @p filename. If the plugin
* only one pair is returned, thus using @ref exportFontToSingleData() * doesn't have @ref FontConverterFeature::MultiFile, only one pair is
* might be more convenient in that case. * returned, thus using @ref exportFontToSingleData() might be more
* convenient in that case.
* @see @ref features(), @ref exportFontToFile(), * @see @ref features(), @ref exportFontToFile(),
* @ref exportGlyphCacheToData() * @ref exportGlyphCacheToData()
*/ */
@ -194,10 +228,11 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Export font to single raw data * @brief Export font to single raw data
* *
* Available only if @ref Feature::ConvertData and @ref Feature::ExportFont * Available only if @ref FontConverterFeature::ConvertData and
* is supported and the plugin doesn't have @ref Feature::MultiFile. * @ref FontConverterFeature::ExportFont is supported and the plugin
* Returns data on success, zero-sized array otherwise. See * doesn't have @ref FontConverterFeature::MultiFile. Returns data on
* @ref exportFontToData() for more information. * success, zero-sized array otherwise. See @ref exportFontToData() for
* more information.
* @see @ref features(), @ref exportFontToFile(), * @see @ref features(), @ref exportFontToFile(),
* @ref exportGlyphCacheToSingleData() * @ref exportGlyphCacheToSingleData()
*/ */
@ -206,11 +241,12 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Export font to file * @brief Export font to file
* *
* Available only if @ref Feature::ExportFont is supported. If the * Available only if @ref FontConverterFeature::ExportFont is
* plugin has @ref Feature::MultiFile, the function will create more * supported. If the plugin has @ref FontConverterFeature::MultiFile,
* than one file in given path, all sharing common basename derived * the function will create more than one file in given path, all
* from @p filename. Returns @cpp true @ce on success, @cpp false @ce * sharing common basename derived from @p filename. Returns
* otherwise. See @ref exportFontToData() for more information. * @cpp true @ce on success, @cpp false @ce otherwise. See
* @ref exportFontToData() for more information.
* @see @ref features(), @ref exportFontToData(), * @see @ref features(), @ref exportFontToData(),
* @ref exportGlyphCacheToFile() * @ref exportGlyphCacheToFile()
*/ */
@ -221,11 +257,12 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* @param cache Populated glyph cache * @param cache Populated glyph cache
* @param filename Output filename * @param filename Output filename
* *
* Available only if @ref Feature::ConvertData and @ref Feature::ExportGlyphCache * Available only if @ref FontConverterFeature::ConvertData and
* is supported. Returns pairs of filename and data on success, empty * @ref FontConverterFeature::ExportGlyphCache is supported. Returns
* vector otherwise. All data will be sharing common basename derived * pairs of filename and data on success, empty vector otherwise. All
* from @p filename. If the plugin doesn't have @ref Feature::MultiFile, * data will be sharing common basename derived from @p filename. If
* only one pair is returned, thus using @ref exportGlyphCacheToSingleData() * the plugin doesn't have @ref FontConverterFeature::MultiFile, only
* one pair is returned, thus using @ref exportGlyphCacheToSingleData()
* might be more convenient in that case. * might be more convenient in that case.
* *
* All glyphs from given cache will be exported. If you want to export * All glyphs from given cache will be exported. If you want to export
@ -238,9 +275,10 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Export glyph cache to single raw data * @brief Export glyph cache to single raw data
* *
* Available only if @ref Feature::ConvertData and @ref Feature::ExportGlyphCache * Available only if @ref FontConverterFeature::ConvertData and
* is supported and the plugin doesn't have @ref Feature::MultiFile. * @ref FontConverterFeature::ExportGlyphCache is supported and the
* Returns data on success, zero-sized array otherwise. See * plugin doesn't have @ref FontConverterFeature::MultiFile. Returns
* data on success, zero-sized array otherwise. See
* @ref exportGlyphCacheToData() for more information. * @ref exportGlyphCacheToData() for more information.
* @see @ref features(), @ref exportGlyphCacheToFile(), * @see @ref features(), @ref exportGlyphCacheToFile(),
* @ref importGlyphCacheFromSingleData() * @ref importGlyphCacheFromSingleData()
@ -250,11 +288,11 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Export glyph cache to file * @brief Export glyph cache to file
* *
* Available only if @ref Feature::ExportGlyphCache is supported. If * Available only if @ref FontConverterFeature::ExportGlyphCache is
* the plugin has @ref Feature::MultiFile, the function will create * supported. If the plugin has @ref FontConverterFeature::MultiFile,
* more than one file in given path, all sharing common basename * the function will create more than one file in given path, all
* derived from @p filename. Returns @cpp true @ce on success, * sharing common basename derived from @p filename. Returns
* @cpp false @ce otherwise. * @cpp true @ce on success, @cpp false @ce otherwise.
* @see @ref features(), @ref exportGlyphCacheToData(), * @see @ref features(), @ref exportGlyphCacheToData(),
* @ref exportFontToFile() * @ref exportFontToFile()
*/ */
@ -264,11 +302,12 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* @brief Import glyph cache from raw data * @brief Import glyph cache from raw data
* @param data Pairs of filename and file data * @param data Pairs of filename and file data
* *
* Available only if @ref Feature::ConvertData and @ref Feature::ImportGlyphCache * Available only if @ref FontConverterFeature::ConvertData and
* is supported. Returns imported cache on success, @cpp nullptr @ce * @ref FontConverterFeature::ImportGlyphCache is supported. Returns
* otherwise. If the plugin doesn't have @ref Feature::MultiFile, only * imported cache on success, @cpp nullptr @ce otherwise. If the plugin
* one file is needed, thus using @ref importGlyphCacheFromSingleData() * doesn't have @ref FontConverterFeature::MultiFile, only one file is
* might be more convenient in that case. * needed, thus using @ref importGlyphCacheFromSingleData() might be
* more convenient in that case.
* @see @ref features(), @ref importGlyphCacheFromFile(), * @see @ref features(), @ref importGlyphCacheFromFile(),
* @ref exportGlyphCacheToData() * @ref exportGlyphCacheToData()
*/ */
@ -277,9 +316,10 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Import glyph cache from single raw data * @brief Import glyph cache from single raw data
* *
* Available only if @ref Feature::ConvertData and @ref Feature::ImportGlyphCache * Available only if @ref FontConverterFeature::ConvertData and
* is supported and the plugin doesn't have @ref Feature::MultiFile. * @ref FontConverterFeature::ImportGlyphCache is supported and the
* Returns imported cache on success, @cpp nullptr @ce otherwise. See * plugin doesn't have @ref FontConverterFeature::MultiFile. Returns
* imported cache on success, @cpp nullptr @ce otherwise. See
* @ref importGlyphCacheFromData() for multi-file conversion. * @ref importGlyphCacheFromData() for multi-file conversion.
* @see @ref features(), @ref importGlyphCacheFromFile(), * @see @ref features(), @ref importGlyphCacheFromFile(),
* @ref exportFontToSingleData() * @ref exportFontToSingleData()
@ -289,11 +329,11 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Import glyph cache from file * @brief Import glyph cache from file
* *
* Available only if @ref Feature::ImportGlyphCache is supported. If * Available only if @ref FontConverterFeature::ImportGlyphCache is
* the plugin has @ref Feature::MultiFile, the function will use * supported. If the plugin has @ref FontConverterFeature::MultiFile,
* additional files in given path, all sharing common basename derived * the function will use additional files in given path, all sharing
* from @p filename. Returns imported cache on success, @cpp nullptr @ce * common basename derived from @p filename. Returns imported cache on
* otherwise. * success, @cpp nullptr @ce otherwise.
* @see @ref features(), @ref importGlyphCacheFromData(), * @see @ref features(), @ref importGlyphCacheFromData(),
* @ref exportGlyphCacheToFile() * @ref exportGlyphCacheToFile()
*/ */
@ -301,13 +341,13 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
private: private:
/** @brief Implementation for @ref features() */ /** @brief Implementation for @ref features() */
virtual Features doFeatures() const = 0; virtual FontConverterFeatures doFeatures() const = 0;
/** /**
* @brief Implementation for @ref exportFontToData() * @brief Implementation for @ref exportFontToData()
* *
* If the plugin doesn't have @ref Feature::MultiFile, default * If the plugin doesn't have @ref FontConverterFeature::MultiFile,
* implementation calls @ref doExportFontToSingleData(). * default implementation calls @ref doExportFontToSingleData().
*/ */
virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const; virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const;
@ -317,17 +357,17 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Implementation for @ref exportFontToFile() * @brief Implementation for @ref exportFontToFile()
* *
* If @ref Feature::ConvertData is supported, default implementation * If @ref FontConverterFeature::ConvertData is supported, default
* calls @ref doExportFontToData() and saves the result to given * implementation calls @ref doExportFontToData() and saves the result
* file(s). * to given file(s).
*/ */
virtual bool doExportFontToFile(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const; virtual bool doExportFontToFile(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const;
/** /**
* @brief Implementation for @ref exportGlyphCacheToData() * @brief Implementation for @ref exportGlyphCacheToData()
* *
* If the plugin doesn't have @ref Feature::MultiFile, default * If the plugin doesn't have @ref FontConverterFeature::MultiFile,
* implementation calls @ref doExportGlyphCacheToSingleData(). * default implementation calls @ref doExportGlyphCacheToSingleData().
*/ */
virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportGlyphCacheToData(AbstractGlyphCache& cache, const std::string& filename) const; virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportGlyphCacheToData(AbstractGlyphCache& cache, const std::string& filename) const;
@ -337,17 +377,17 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Implementation for @ref exportGlyphCacheToFile() * @brief Implementation for @ref exportGlyphCacheToFile()
* *
* If @ref Feature::ConvertData is supported, default implementation * If @ref FontConverterFeature::ConvertData is supported, default
* calls @ref doExportGlyphCacheToData() and saves the result to given * implementation calls @ref doExportGlyphCacheToData() and saves the
* file(s). * result to given file(s).
*/ */
virtual bool doExportGlyphCacheToFile(AbstractGlyphCache& cache, const std::string& filename) const; virtual bool doExportGlyphCacheToFile(AbstractGlyphCache& cache, const std::string& filename) const;
/** /**
* @brief Implementation for @ref importGlyphCacheFromData() * @brief Implementation for @ref importGlyphCacheFromData()
* *
* If the plugin doesn't have @ref Feature::MultiFile, default * If the plugin doesn't have @ref FontConverterFeature::MultiFile,
* implementation calls @ref doImportGlyphCacheFromSingleData(). * default implementation calls @ref doImportGlyphCacheFromSingleData().
*/ */
virtual Containers::Pointer<AbstractGlyphCache> doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const; virtual Containers::Pointer<AbstractGlyphCache> doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const;
@ -357,15 +397,14 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/** /**
* @brief Implementation for @ref importGlyphCacheFromFile() * @brief Implementation for @ref importGlyphCacheFromFile()
* *
* If @ref Feature::ConvertData is supported and the plugin doesn't * If @ref FontConverterFeature::ConvertData is supported and the
* have @ref Feature::MultiFile, default implementation opens the file * plugin doesn't have @ref FontConverterFeature::MultiFile, default
* and calls @ref doImportGlyphCacheFromSingleData() with its contents. * implementation opens the file and calls
* @ref doImportGlyphCacheFromSingleData() with its contents.
*/ */
virtual Containers::Pointer<AbstractGlyphCache> doImportGlyphCacheFromFile(const std::string& filename) const; virtual Containers::Pointer<AbstractGlyphCache> doImportGlyphCacheFromFile(const std::string& filename) const;
}; };
CORRADE_ENUMSET_OPERATORS(AbstractFontConverter::Features)
}} }}
#endif #endif

41
src/Magnum/Text/Test/AbstractFontConverterTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/FileToString.h> #include <Corrade/TestSuite/Compare/FileToString.h>
@ -53,6 +54,9 @@ struct AbstractFontConverterTest: TestSuite::Tester {
void importGlyphCacheFromSingleData(); void importGlyphCacheFromSingleData();
void importGlyphCacheFromFile(); void importGlyphCacheFromFile();
void debugFeature();
void debugFeatures();
}; };
AbstractFontConverterTest::AbstractFontConverterTest() { AbstractFontConverterTest::AbstractFontConverterTest() {
@ -67,14 +71,17 @@ AbstractFontConverterTest::AbstractFontConverterTest() {
&AbstractFontConverterTest::exportGlyphCacheToFileFailed, &AbstractFontConverterTest::exportGlyphCacheToFileFailed,
&AbstractFontConverterTest::importGlyphCacheFromSingleData, &AbstractFontConverterTest::importGlyphCacheFromSingleData,
&AbstractFontConverterTest::importGlyphCacheFromFile}); &AbstractFontConverterTest::importGlyphCacheFromFile,
&AbstractFontConverterTest::debugFeature,
&AbstractFontConverterTest::debugFeatures});
/* Create testing dir */ /* Create testing dir */
Utility::Directory::mkpath(TEXT_TEST_OUTPUT_DIR); Utility::Directory::mkpath(TEXT_TEST_OUTPUT_DIR);
} }
struct DummyFont: AbstractFont { struct DummyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -99,7 +106,7 @@ void AbstractFontConverterTest::convertGlyphs() {
GlyphExporter(std::u32string& characters): _characters(characters) {} GlyphExporter(std::u32string& characters): _characters(characters) {}
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ExportFont; }
Containers::Array<char> doExportFontToSingleData(AbstractFont&, AbstractGlyphCache&, const std::u32string& characters) const override { Containers::Array<char> doExportFontToSingleData(AbstractFont&, AbstractGlyphCache&, const std::u32string& characters) const override {
_characters = characters; _characters = characters;
@ -118,7 +125,7 @@ void AbstractFontConverterTest::convertGlyphs() {
void AbstractFontConverterTest::exportFontToSingleData() { void AbstractFontConverterTest::exportFontToSingleData() {
class SingleDataExporter: public Text::AbstractFontConverter { class SingleDataExporter: public Text::AbstractFontConverter {
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ExportFont; }
Containers::Array<char> doExportFontToSingleData(AbstractFont&, AbstractGlyphCache&, const std::u32string&) const override { Containers::Array<char> doExportFontToSingleData(AbstractFont&, AbstractGlyphCache&, const std::u32string&) const override {
Containers::Array<char> data(1); Containers::Array<char> data(1);
@ -139,7 +146,7 @@ void AbstractFontConverterTest::exportFontToSingleData() {
void AbstractFontConverterTest::exportFontToFile() { void AbstractFontConverterTest::exportFontToFile() {
class DataExporter: public Text::AbstractFontConverter { class DataExporter: public Text::AbstractFontConverter {
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont|Feature::MultiFile; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ExportFont|FontConverterFeature::MultiFile; }
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, AbstractGlyphCache&, const std::string& filename, const std::u32string&) const override { std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, AbstractGlyphCache&, const std::string& filename, const std::u32string&) const override {
/* Why the hell GCC 4.9 fails to do proper move so I need to /* Why the hell GCC 4.9 fails to do proper move so I need to
@ -167,7 +174,7 @@ void AbstractFontConverterTest::exportFontToFile() {
void AbstractFontConverterTest::exportFontToFileFailed() { void AbstractFontConverterTest::exportFontToFileFailed() {
struct: AbstractFontConverter { struct: AbstractFontConverter {
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont|Feature::MultiFile; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ExportFont|FontConverterFeature::MultiFile; }
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, AbstractGlyphCache&, const std::string&, const std::u32string&) const override { return {}; } std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, AbstractGlyphCache&, const std::string&, const std::u32string&) const override { return {}; }
} exporter; } exporter;
@ -177,7 +184,7 @@ void AbstractFontConverterTest::exportFontToFileFailed() {
void AbstractFontConverterTest::exportGlyphCacheToSingleData() { void AbstractFontConverterTest::exportGlyphCacheToSingleData() {
struct: Text::AbstractFontConverter { struct: Text::AbstractFontConverter {
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportGlyphCache; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ExportGlyphCache; }
Containers::Array<char> doExportGlyphCacheToSingleData(AbstractGlyphCache&) const override { Containers::Array<char> doExportGlyphCacheToSingleData(AbstractGlyphCache&) const override {
return Containers::Array<char>{Containers::InPlaceInit, {'\xee'}}; return Containers::Array<char>{Containers::InPlaceInit, {'\xee'}};
@ -196,7 +203,7 @@ void AbstractFontConverterTest::exportGlyphCacheToSingleData() {
void AbstractFontConverterTest::exportGlyphCacheToFile() { void AbstractFontConverterTest::exportGlyphCacheToFile() {
class DataExporter: public Text::AbstractFontConverter { class DataExporter: public Text::AbstractFontConverter {
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportGlyphCache|Feature::MultiFile; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ExportGlyphCache|FontConverterFeature::MultiFile; }
std::vector<std::pair<std::string, Containers::Array<char>>> doExportGlyphCacheToData(AbstractGlyphCache&, const std::string& filename) const override { std::vector<std::pair<std::string, Containers::Array<char>>> doExportGlyphCacheToData(AbstractGlyphCache&, const std::string& filename) const override {
/* Why the hell GCC 4.9 fails to do proper move so I need to /* Why the hell GCC 4.9 fails to do proper move so I need to
@ -224,7 +231,7 @@ void AbstractFontConverterTest::exportGlyphCacheToFile() {
void AbstractFontConverterTest::exportGlyphCacheToFileFailed() { void AbstractFontConverterTest::exportGlyphCacheToFileFailed() {
struct: Text::AbstractFontConverter { struct: Text::AbstractFontConverter {
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportGlyphCache|Feature::MultiFile; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ExportGlyphCache|FontConverterFeature::MultiFile; }
std::vector<std::pair<std::string, Containers::Array<char>>> doExportGlyphCacheToData(AbstractGlyphCache&, const std::string&) const override { return {}; } std::vector<std::pair<std::string, Containers::Array<char>>> doExportGlyphCacheToData(AbstractGlyphCache&, const std::string&) const override { return {}; }
} exporter; } exporter;
@ -235,7 +242,7 @@ void AbstractFontConverterTest::exportGlyphCacheToFileFailed() {
class SingleGlyphCacheDataImporter: public Text::AbstractFontConverter { class SingleGlyphCacheDataImporter: public Text::AbstractFontConverter {
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ImportGlyphCache; } FontConverterFeatures doFeatures() const override { return FontConverterFeature::ConvertData|FontConverterFeature::ImportGlyphCache; }
Containers::Pointer<AbstractGlyphCache> doImportGlyphCacheFromSingleData(const Containers::ArrayView<const char> data) const override { Containers::Pointer<AbstractGlyphCache> doImportGlyphCacheFromSingleData(const Containers::ArrayView<const char> data) const override {
if(data.size() == 1 && data[0] == '\xa5') if(data.size() == 1 && data[0] == '\xa5')
@ -259,6 +266,20 @@ void AbstractFontConverterTest::importGlyphCacheFromFile() {
CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345})); CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345}));
} }
void AbstractFontConverterTest::debugFeature() {
std::ostringstream out;
Debug{&out} << FontConverterFeature::ExportFont << FontConverterFeature(0xf0);
CORRADE_COMPARE(out.str(), "Text::FontConverterFeature::ExportFont Text::FontConverterFeature(0xf0)\n");
}
void AbstractFontConverterTest::debugFeatures() {
std::ostringstream out;
Debug{&out} << (FontConverterFeature::ExportFont|FontConverterFeature::ImportGlyphCache) << FontConverterFeatures{};
CORRADE_COMPARE(out.str(), "Text::FontConverterFeature::ExportFont|Text::FontConverterFeature::ImportGlyphCache Text::FontConverterFeatures{}\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontConverterTest) CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontConverterTest)

84
src/Magnum/Text/Test/AbstractFontTest.cpp

@ -153,7 +153,7 @@ AbstractFontTest::AbstractFontTest() {
void AbstractFontTest::construct() { void AbstractFontTest::construct() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -164,7 +164,7 @@ void AbstractFontTest::construct() {
} }
} font; } font;
CORRADE_COMPARE(font.features(), AbstractFont::Features{}); CORRADE_COMPARE(font.features(), FontFeatures{});
CORRADE_VERIFY(!font.isOpened()); CORRADE_VERIFY(!font.isOpened());
font.close(); font.close();
@ -173,7 +173,7 @@ void AbstractFontTest::construct() {
void AbstractFontTest::openData() { void AbstractFontTest::openData() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
@ -203,7 +203,7 @@ void AbstractFontTest::openData() {
void AbstractFontTest::openFileAsData() { void AbstractFontTest::openFileAsData() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
@ -233,7 +233,7 @@ void AbstractFontTest::openFileAsData() {
void AbstractFontTest::openFileAsDataNotFound() { void AbstractFontTest::openFileAsDataNotFound() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -253,7 +253,7 @@ void AbstractFontTest::openFileAsDataNotFound() {
void AbstractFontTest::openFileNotImplemented() { void AbstractFontTest::openFileNotImplemented() {
struct: AbstractFont { struct: AbstractFont {
/* Supports neither file nor data opening */ /* Supports neither file nor data opening */
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -273,7 +273,7 @@ void AbstractFontTest::openFileNotImplemented() {
void AbstractFontTest::openDataNotSupported() { void AbstractFontTest::openDataNotSupported() {
struct: AbstractFont { struct: AbstractFont {
/* Supports neither file nor data opening */ /* Supports neither file nor data opening */
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -292,7 +292,7 @@ void AbstractFontTest::openDataNotSupported() {
void AbstractFontTest::openDataNotImplemented() { void AbstractFontTest::openDataNotImplemented() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -312,7 +312,7 @@ void AbstractFontTest::openDataNotImplemented() {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
void AbstractFontTest::openSingleDataDeprecated() { void AbstractFontTest::openSingleDataDeprecated() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
@ -344,7 +344,7 @@ void AbstractFontTest::openSingleDataDeprecated() {
void AbstractFontTest::openMultiDataDeprecated() { void AbstractFontTest::openMultiDataDeprecated() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
@ -382,7 +382,7 @@ void AbstractFontTest::openMultiDataDeprecated() {
void AbstractFontTest::setFileCallback() { void AbstractFontTest::setFileCallback() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData|Feature::FileCallback; } FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void* userData) override { void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void* userData) override {
@ -408,7 +408,7 @@ void AbstractFontTest::setFileCallback() {
void AbstractFontTest::setFileCallbackTemplate() { void AbstractFontTest::setFileCallbackTemplate() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData|Feature::FileCallback; } FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) override { void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) override {
@ -440,7 +440,7 @@ void AbstractFontTest::setFileCallbackTemplate() {
void AbstractFontTest::setFileCallbackTemplateNull() { void AbstractFontTest::setFileCallbackTemplateNull() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData|Feature::FileCallback; } FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*callback)(const std::string&, InputFileCallbackPolicy, void*), void* userData) override { void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*callback)(const std::string&, InputFileCallbackPolicy, void*), void* userData) override {
@ -465,7 +465,7 @@ void AbstractFontTest::setFileCallbackTemplateNull() {
void AbstractFontTest::setFileCallbackTemplateConst() { void AbstractFontTest::setFileCallbackTemplateConst() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData|Feature::FileCallback; } FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) override { void doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) override {
@ -493,7 +493,7 @@ void AbstractFontTest::setFileCallbackTemplateConst() {
void AbstractFontTest::setFileCallbackFileOpened() { void AbstractFontTest::setFileCallbackFileOpened() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -515,7 +515,7 @@ void AbstractFontTest::setFileCallbackFileOpened() {
void AbstractFontTest::setFileCallbackNotImplemented() { void AbstractFontTest::setFileCallbackNotImplemented() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::FileCallback; } FontFeatures doFeatures() const override { return FontFeature::FileCallback; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -538,7 +538,7 @@ void AbstractFontTest::setFileCallbackNotImplemented() {
void AbstractFontTest::setFileCallbackNotSupported() { void AbstractFontTest::setFileCallbackNotSupported() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -561,7 +561,7 @@ void AbstractFontTest::setFileCallbackNotSupported() {
void AbstractFontTest::setFileCallbackOpenFileDirectly() { void AbstractFontTest::setFileCallbackOpenFileDirectly() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::FileCallback|Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::FileCallback|FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } void doClose() override { _opened = false; }
@ -604,7 +604,7 @@ void AbstractFontTest::setFileCallbackOpenFileDirectly() {
void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementation() { void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementation() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::FileCallback|Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::FileCallback|FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } void doClose() override { _opened = false; }
@ -662,7 +662,7 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementation() {
void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementationFailed() { void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementationFailed() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::FileCallback|Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::FileCallback|FontFeature::OpenData; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -694,7 +694,7 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementationFailed()
void AbstractFontTest::setFileCallbackOpenFileAsData() { void AbstractFontTest::setFileCallbackOpenFileAsData() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } void doClose() override { _opened = false; }
@ -753,7 +753,7 @@ void AbstractFontTest::setFileCallbackOpenFileAsData() {
void AbstractFontTest::setFileCallbackOpenFileAsDataFailed() { void AbstractFontTest::setFileCallbackOpenFileAsDataFailed() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -785,7 +785,7 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataFailed() {
void AbstractFontTest::properties() { void AbstractFontTest::properties() {
struct: AbstractFont { struct: AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
@ -812,7 +812,7 @@ void AbstractFontTest::properties() {
void AbstractFontTest::propertiesNoFont() { void AbstractFontTest::propertiesNoFont() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -838,7 +838,7 @@ void AbstractFontTest::propertiesNoFont() {
void AbstractFontTest::glyphId() { void AbstractFontTest::glyphId() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -854,7 +854,7 @@ void AbstractFontTest::glyphId() {
void AbstractFontTest::glyphIdNoFont() { void AbstractFontTest::glyphIdNoFont() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -873,7 +873,7 @@ void AbstractFontTest::glyphIdNoFont() {
void AbstractFontTest::glyphAdvance() { void AbstractFontTest::glyphAdvance() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -889,7 +889,7 @@ void AbstractFontTest::glyphAdvance() {
void AbstractFontTest::glyphAdvanceNoFont() { void AbstractFontTest::glyphAdvanceNoFont() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -920,7 +920,7 @@ void AbstractFontTest::layout() {
}; };
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -938,7 +938,7 @@ void AbstractFontTest::layout() {
void AbstractFontTest::layoutNoFont() { void AbstractFontTest::layoutNoFont() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -956,7 +956,7 @@ void AbstractFontTest::layoutNoFont() {
void AbstractFontTest::fillGlyphCache() { void AbstractFontTest::fillGlyphCache() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -983,7 +983,7 @@ void AbstractFontTest::fillGlyphCache() {
void AbstractFontTest::fillGlyphCacheNotSupported() { void AbstractFontTest::fillGlyphCacheNotSupported() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return Feature::PreparedGlyphCache; } FontFeatures doFeatures() const override { return FontFeature::PreparedGlyphCache; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -1001,7 +1001,7 @@ void AbstractFontTest::fillGlyphCacheNotSupported() {
void AbstractFontTest::fillGlyphCacheNotImplemented() { void AbstractFontTest::fillGlyphCacheNotImplemented() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -1019,7 +1019,7 @@ void AbstractFontTest::fillGlyphCacheNotImplemented() {
void AbstractFontTest::fillGlyphCacheNoFont() { void AbstractFontTest::fillGlyphCacheNoFont() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -1037,7 +1037,7 @@ void AbstractFontTest::fillGlyphCacheNoFont() {
void AbstractFontTest::createGlyphCache() { void AbstractFontTest::createGlyphCache() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return Feature::PreparedGlyphCache; } FontFeatures doFeatures() const override { return FontFeature::PreparedGlyphCache; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -1063,7 +1063,7 @@ void AbstractFontTest::createGlyphCache() {
void AbstractFontTest::createGlyphCacheNotSupported() { void AbstractFontTest::createGlyphCacheNotSupported() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -1080,7 +1080,7 @@ void AbstractFontTest::createGlyphCacheNotSupported() {
void AbstractFontTest::createGlyphCacheNotImplemented() { void AbstractFontTest::createGlyphCacheNotImplemented() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return Feature::PreparedGlyphCache; } FontFeatures doFeatures() const override { return FontFeature::PreparedGlyphCache; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -1097,7 +1097,7 @@ void AbstractFontTest::createGlyphCacheNotImplemented() {
void AbstractFontTest::createGlyphCacheNoFont() { void AbstractFontTest::createGlyphCacheNoFont() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
Features doFeatures() const override { return Feature::PreparedGlyphCache; } FontFeatures doFeatures() const override { return FontFeature::PreparedGlyphCache; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
@ -1115,15 +1115,15 @@ void AbstractFontTest::createGlyphCacheNoFont() {
void AbstractFontTest::debugFeature() { void AbstractFontTest::debugFeature() {
std::ostringstream out; std::ostringstream out;
Debug{&out} << AbstractFont::Feature::OpenData << AbstractFont::Feature(0xf0); Debug{&out} << FontFeature::OpenData << FontFeature(0xf0);
CORRADE_COMPARE(out.str(), "Text::AbstractFont::Feature::OpenData Text::AbstractFont::Feature(0xf0)\n"); CORRADE_COMPARE(out.str(), "Text::FontFeature::OpenData Text::FontFeature(0xf0)\n");
} }
void AbstractFontTest::debugFeatures() { void AbstractFontTest::debugFeatures() {
std::ostringstream out; std::ostringstream out;
Debug{&out} << (AbstractFont::Feature::OpenData|AbstractFont::Feature::PreparedGlyphCache) << AbstractFont::Features{}; Debug{&out} << (FontFeature::OpenData|FontFeature::PreparedGlyphCache) << FontFeatures{};
CORRADE_COMPARE(out.str(), "Text::AbstractFont::Feature::OpenData|Text::AbstractFont::Feature::PreparedGlyphCache Text::AbstractFont::Features{}\n"); CORRADE_COMPARE(out.str(), "Text::FontFeature::OpenData|Text::FontFeature::PreparedGlyphCache Text::FontFeatures{}\n");
} }
}}}} }}}}

4
src/Magnum/Text/Test/RendererGLTest.cpp

@ -71,7 +71,7 @@ class TestLayouter: public Text::AbstractLayouter {
}; };
class TestFont: public Text::AbstractFont { class TestFont: public Text::AbstractFont {
Features doFeatures() const override { return Feature::OpenData; } FontFeatures doFeatures() const override { return FontFeature::OpenData; }
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
@ -340,7 +340,7 @@ void RendererGLTest::multiline() {
explicit Font(): _opened(false) {} explicit Font(): _opened(false) {}
private: private:
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } void doClose() override { _opened = false; }

38
src/Magnum/Trade/AbstractImageConverter.cpp

@ -86,7 +86,7 @@ AbstractImageConverter::AbstractImageConverter(PluginManager::Manager<AbstractIm
AbstractImageConverter::AbstractImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin): PluginManager::AbstractManagingPlugin<AbstractImageConverter>{manager, plugin} {} AbstractImageConverter::AbstractImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin): PluginManager::AbstractManagingPlugin<AbstractImageConverter>{manager, plugin} {}
Containers::Optional<Image2D> AbstractImageConverter::exportToImage(const ImageView2D& image) { Containers::Optional<Image2D> AbstractImageConverter::exportToImage(const ImageView2D& image) {
CORRADE_ASSERT(features() & Feature::ConvertImage, CORRADE_ASSERT(features() & ImageConverterFeature::ConvertImage,
"Trade::AbstractImageConverter::exportToImage(): feature not supported", {}); "Trade::AbstractImageConverter::exportToImage(): feature not supported", {});
Containers::Optional<Image2D> out = doExportToImage(image); Containers::Optional<Image2D> out = doExportToImage(image);
@ -99,7 +99,7 @@ Containers::Optional<Image2D> AbstractImageConverter::doExportToImage(const Imag
} }
Containers::Optional<CompressedImage2D> AbstractImageConverter::exportToCompressedImage(const ImageView2D& image) { Containers::Optional<CompressedImage2D> AbstractImageConverter::exportToCompressedImage(const ImageView2D& image) {
CORRADE_ASSERT(features() & Feature::ConvertCompressedImage, CORRADE_ASSERT(features() & ImageConverterFeature::ConvertCompressedImage,
"Trade::AbstractImageConverter::exportToCompressedImage(): feature not supported", {}); "Trade::AbstractImageConverter::exportToCompressedImage(): feature not supported", {});
Containers::Optional<CompressedImage2D> out = doExportToCompressedImage(image); Containers::Optional<CompressedImage2D> out = doExportToCompressedImage(image);
@ -112,7 +112,7 @@ Containers::Optional<CompressedImage2D> AbstractImageConverter::doExportToCompre
} }
Containers::Array<char> AbstractImageConverter::exportToData(const ImageView2D& image) { Containers::Array<char> AbstractImageConverter::exportToData(const ImageView2D& image) {
CORRADE_ASSERT(features() & Feature::ConvertData, CORRADE_ASSERT(features() & ImageConverterFeature::ConvertData,
"Trade::AbstractImageConverter::exportToData(): feature not supported", nullptr); "Trade::AbstractImageConverter::exportToData(): feature not supported", nullptr);
Containers::Array<char> out = doExportToData(image); Containers::Array<char> out = doExportToData(image);
@ -125,7 +125,7 @@ Containers::Array<char> AbstractImageConverter::doExportToData(const ImageView2D
} }
Containers::Array<char> AbstractImageConverter::exportToData(const CompressedImageView2D& image) { Containers::Array<char> AbstractImageConverter::exportToData(const CompressedImageView2D& image) {
CORRADE_ASSERT(features() & Feature::ConvertCompressedData, CORRADE_ASSERT(features() & ImageConverterFeature::ConvertCompressedData,
"Trade::AbstractImageConverter::exportToData(): feature not supported", nullptr); "Trade::AbstractImageConverter::exportToData(): feature not supported", nullptr);
Containers::Array<char> out = doExportToData(image); Containers::Array<char> out = doExportToData(image);
@ -142,14 +142,14 @@ Containers::Array<char> AbstractImageConverter::exportToData(const ImageData2D&
} }
bool AbstractImageConverter::exportToFile(const ImageView2D& image, const std::string& filename) { bool AbstractImageConverter::exportToFile(const ImageView2D& image, const std::string& filename) {
CORRADE_ASSERT(features() & Feature::ConvertFile, CORRADE_ASSERT(features() & ImageConverterFeature::ConvertFile,
"Trade::AbstractImageConverter::exportToFile(): feature not supported", {}); "Trade::AbstractImageConverter::exportToFile(): feature not supported", {});
return doExportToFile(image, filename); return doExportToFile(image, filename);
} }
bool AbstractImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) { bool AbstractImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) {
CORRADE_ASSERT(features() >= Feature::ConvertData, "Trade::AbstractImageConverter::exportToFile(): feature advertised but not implemented", false); CORRADE_ASSERT(features() >= ImageConverterFeature::ConvertData, "Trade::AbstractImageConverter::exportToFile(): feature advertised but not implemented", false);
const auto data = doExportToData(image); const auto data = doExportToData(image);
if(!data) return false; if(!data) return false;
@ -164,14 +164,14 @@ bool AbstractImageConverter::doExportToFile(const ImageView2D& image, const std:
} }
bool AbstractImageConverter::exportToFile(const CompressedImageView2D& image, const std::string& filename) { bool AbstractImageConverter::exportToFile(const CompressedImageView2D& image, const std::string& filename) {
CORRADE_ASSERT(features() & Feature::ConvertCompressedFile, CORRADE_ASSERT(features() & ImageConverterFeature::ConvertCompressedFile,
"Trade::AbstractImageConverter::exportToFile(): feature not supported", {}); "Trade::AbstractImageConverter::exportToFile(): feature not supported", {});
return doExportToFile(image, filename); return doExportToFile(image, filename);
} }
bool AbstractImageConverter::doExportToFile(const CompressedImageView2D& image, const std::string& filename) { bool AbstractImageConverter::doExportToFile(const CompressedImageView2D& image, const std::string& filename) {
CORRADE_ASSERT(features() >= Feature::ConvertCompressedData, "Trade::AbstractImageConverter::exportToFile(): feature advertised but not implemented", false); CORRADE_ASSERT(features() >= ImageConverterFeature::ConvertCompressedData, "Trade::AbstractImageConverter::exportToFile(): feature advertised but not implemented", false);
const auto data = doExportToData(image); const auto data = doExportToData(image);
if(!data) return false; if(!data) return false;
@ -189,12 +189,12 @@ bool AbstractImageConverter::exportToFile(const ImageData2D& image, const std::s
return image.isCompressed() ? exportToFile(CompressedImageView2D(image), filename) : exportToFile(ImageView2D(image), filename); return image.isCompressed() ? exportToFile(CompressedImageView2D(image), filename) : exportToFile(ImageView2D(image), filename);
} }
Debug& operator<<(Debug& debug, const AbstractImageConverter::Feature value) { Debug& operator<<(Debug& debug, const ImageConverterFeature value) {
debug << "Trade::AbstractImageConverter::Feature" << Debug::nospace; debug << "Trade::ImageConverterFeature" << Debug::nospace;
switch(value) { switch(value) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
#define _c(v) case AbstractImageConverter::Feature::v: return debug << "::" #v; #define _c(v) case ImageConverterFeature::v: return debug << "::" #v;
_c(ConvertImage) _c(ConvertImage)
_c(ConvertCompressedImage) _c(ConvertCompressedImage)
_c(ConvertFile) _c(ConvertFile)
@ -208,15 +208,15 @@ Debug& operator<<(Debug& debug, const AbstractImageConverter::Feature value) {
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")"; return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
} }
Debug& operator<<(Debug& debug, const AbstractImageConverter::Features value) { Debug& operator<<(Debug& debug, const ImageConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::AbstractImageConverter::Features{}", { return Containers::enumSetDebugOutput(debug, value, "Trade::ImageConverterFeatures{}", {
AbstractImageConverter::Feature::ConvertImage, ImageConverterFeature::ConvertImage,
AbstractImageConverter::Feature::ConvertCompressedImage, ImageConverterFeature::ConvertCompressedImage,
AbstractImageConverter::Feature::ConvertData, ImageConverterFeature::ConvertData,
AbstractImageConverter::Feature::ConvertCompressedData, ImageConverterFeature::ConvertCompressedData,
/* These are implied by Convert[Compressed]Data, so have to be last */ /* These are implied by Convert[Compressed]Data, so have to be last */
AbstractImageConverter::Feature::ConvertFile, ImageConverterFeature::ConvertFile,
AbstractImageConverter::Feature::ConvertCompressedFile}); ImageConverterFeature::ConvertCompressedFile});
} }
}} }}

166
src/Magnum/Trade/AbstractImageConverter.h

@ -37,6 +37,68 @@
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
/**
@brief Features supported by an image converter
@m_since_latest
@see @ref ImageConverterFeatures, @ref AbstractImageConverter::features()
*/
enum class ImageConverterFeature: UnsignedByte {
/**
* Conversion to image with different format with
* @ref AbstractImageConverter::exportToImage()
*/
ConvertImage = 1 << 0,
/**
* Conversion to compressed image with
* @ref AbstractImageConverter::exportToCompressedImage()
*/
ConvertCompressedImage = 1 << 1,
/**
* Exporting to file with
* @ref AbstractImageConverter::exportToFile(const ImageView2D&, const std::string&)
*/
ConvertFile = 1 << 2,
/**
* Exporting to file with
* @ref AbstractImageConverter::exportToFile(const CompressedImageView2D&, const std::string&)
*/
ConvertCompressedFile = 1 << 3,
/**
* Exporting to raw data with
* @ref AbstractImageConverter::exportToData(const ImageView2D&).
* Implies @ref ImageConverterFeature::ConvertFile.
*/
ConvertData = ConvertFile|(1 << 4),
/**
* Exporting compressed image to raw data with
* @ref AbstractImageConverter::exportToData(const CompressedImageView2D&).
* Implies @ref ImageConverterFeature::ConvertCompressedFile.
*/
ConvertCompressedData = ConvertCompressedFile|(1 << 4)
};
/**
@brief Features supported by an image converter
@m_since_latest
@see @ref AbstractImageConverter::features()
*/
typedef Containers::EnumSet<ImageConverterFeature> ImageConverterFeatures;
CORRADE_ENUMSET_OPERATORS(ImageConverterFeatures)
/** @debugoperatorenum{ImageConverterFeature} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, ImageConverterFeature value);
/** @debugoperatorenum{ImageConverterFeatures} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, ImageConverterFeatures value);
/** /**
@brief Base for image converter plugins @brief Base for image converter plugins
@ -65,14 +127,13 @@ You don't need to do most of the redundant sanity checks, these things are
checked by the implementation: checked by the implementation:
- The function @ref doExportToImage() is called only if - The function @ref doExportToImage() is called only if
@ref Feature::ConvertImage @ref ImageConverterFeature::ConvertImage is supported.
is supported.
- The function @ref doExportToCompressedImage() is called only if - The function @ref doExportToCompressedImage() is called only if
@ref Feature::ConvertCompressedImage is supported. @ref ImageConverterFeature::ConvertCompressedImage is supported.
- The function @ref doExportToData(const ImageView2D&) is called only if - The function @ref doExportToData(const ImageView2D&) is called only if
@ref Feature::ConvertData is supported. @ref ImageConverterFeature::ConvertData is supported.
- The function @ref doExportToData(const CompressedImageView2D&) is called - The function @ref doExportToData(const CompressedImageView2D&) is called
only if @ref Feature::ConvertCompressedData is supported. only if @ref ImageConverterFeature::ConvertCompressedData is supported.
@m_class{m-block m-warning} @m_class{m-block m-warning}
@ -86,44 +147,17 @@ checked by the implementation:
*/ */
class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::AbstractManagingPlugin<AbstractImageConverter> { class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::AbstractManagingPlugin<AbstractImageConverter> {
public: public:
/** #ifdef MAGNUM_BUILD_DEPRECATED
* @brief Features supported by this converter /** @brief @copybrief ImageConverterFeature
* * @m_deprecated_since_latest Use @ref ImageConverterFeature instead.
* @see @ref Features, @ref features()
*/ */
enum class Feature: UnsignedByte { typedef CORRADE_DEPRECATED("use ImageConverterFeature instead") ImageConverterFeature Feature;
/** Conversion to image with different format with @ref exportToImage() */
ConvertImage = 1 << 0,
/** Conversion to compressed image with @ref exportToCompressedImage() */
ConvertCompressedImage = 1 << 1,
/** Exporting to file with @ref exportToFile(const ImageView2D&, const std::string&) */
ConvertFile = 1 << 2,
/** Exporting to file with @ref exportToFile(const CompressedImageView2D&, const std::string&) */
ConvertCompressedFile = 1 << 3,
/**
* Exporting to raw data with @ref exportToData(const ImageView2D&).
* Implies @ref Feature::ConvertFile.
*/
ConvertData = ConvertFile|(1 << 4),
/**
* Exporting compressed image to raw data with
* @ref exportToData(const CompressedImageView2D&). Implies
* @ref Feature::ConvertCompressedFile.
*/
ConvertCompressedData = ConvertCompressedFile|(1 << 4)
};
/** /** @brief @copybrief ImageConverterFeatures
* @brief Features supported by this converter * @m_deprecated_since_latest Use @ref ImageConverterFeatures instead.
*
* @see @ref features()
*/ */
typedef Containers::EnumSet<Feature> Features; typedef CORRADE_DEPRECATED("use ImageConverterFeatures instead") ImageConverterFeatures Features;
#endif
/** /**
* @brief Plugin interface * @brief Plugin interface
@ -163,13 +197,14 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
explicit AbstractImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin); explicit AbstractImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin);
/** @brief Features supported by this converter */ /** @brief Features supported by this converter */
Features features() const { return doFeatures(); } ImageConverterFeatures features() const { return doFeatures(); }
/** /**
* @brief Convert image to different format * @brief Convert image to different format
* *
* Available only if @ref Feature::ConvertImage is supported. Returns * Available only if @ref ImageConverterFeature::ConvertImage is
* converted image on success, @ref Containers::NullOpt otherwise. * supported. Returns converted image on success,
* @ref Containers::NullOpt otherwise.
* @see @ref features(), @ref exportToData(), @ref exportToFile() * @see @ref features(), @ref exportToData(), @ref exportToFile()
*/ */
Containers::Optional<Image2D> exportToImage(const ImageView2D& image); Containers::Optional<Image2D> exportToImage(const ImageView2D& image);
@ -177,8 +212,9 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
/** /**
* @brief Convert image to compressed format * @brief Convert image to compressed format
* *
* Available only if @ref Feature::ConvertCompressedImage is supported. * Available only if @ref ImageConverterFeature::ConvertCompressedImage
* Returns converted image on success, @ref Containers::NullOpt otherwise. * is supported. Returns converted image on success,
* @ref Containers::NullOpt otherwise.
* @see @ref features(), @ref exportToData(), @ref exportToFile() * @see @ref features(), @ref exportToData(), @ref exportToFile()
*/ */
Containers::Optional<CompressedImage2D> exportToCompressedImage(const ImageView2D& image); Containers::Optional<CompressedImage2D> exportToCompressedImage(const ImageView2D& image);
@ -186,8 +222,8 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
/** /**
* @brief Export image to raw data * @brief Export image to raw data
* *
* Available only if @ref Feature::ConvertData is supported. Returns * Available only if @ref ImageConverterFeature::ConvertData is
* data on success, zero-sized array otherwise. * supported. Returns data on success, zero-sized array otherwise.
* @see @ref features(), @ref exportToImage(), * @see @ref features(), @ref exportToImage(),
* @ref exportToFile(const ImageView2D&, const std::string&) * @ref exportToFile(const ImageView2D&, const std::string&)
*/ */
@ -196,8 +232,8 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
/** /**
* @brief Export compressed image to raw data * @brief Export compressed image to raw data
* *
* Available only if @ref Feature::ConvertCompressedData is supported. * Available only if @ref ImageConverterFeature::ConvertCompressedData
* Returns data on success, zero-sized array otherwise. * is supported. Returns data on success, zero-sized array otherwise.
* @see @ref features(), @ref exportToCompressedImage(), * @see @ref features(), @ref exportToCompressedImage(),
* @ref exportToFile(const CompressedImageView2D&, const std::string&) * @ref exportToFile(const CompressedImageView2D&, const std::string&)
*/ */
@ -216,9 +252,9 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
/** /**
* @brief Export image to file * @brief Export image to file
* *
* Available only if @ref Feature::ConvertFile or * Available only if @ref ImageConverterFeature::ConvertFile or
* @ref Feature::ConvertData is supported. Returns `true` on success, * @ref ImageConverterFeature::ConvertData is supported. Returns
* `false` otherwise. * @cpp true @ce on success, @cpp false @ce otherwise.
* @see @ref features(), @ref exportToImage(), * @see @ref features(), @ref exportToImage(),
* @ref exportToData(const ImageView2D&) * @ref exportToData(const ImageView2D&)
*/ */
@ -227,9 +263,9 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
/** /**
* @brief Export compressed image to file * @brief Export compressed image to file
* *
* Available only if @ref Feature::ConvertCompressedFile or * Available only if @ref ImageConverterFeature::ConvertCompressedFile
* @ref Feature::ConvertCompressedData is supported. Returns `true` on * or @ref ImageConverterFeature::ConvertCompressedData is supported.
* success, `false` otherwise. * Returns @cpp true @ce on success, @cpp false @ce otherwise.
* @see @ref features(), @ref exportToCompressedImage(), * @see @ref features(), @ref exportToCompressedImage(),
* @ref exportToData(const CompressedImageView2D&) * @ref exportToData(const CompressedImageView2D&)
*/ */
@ -247,7 +283,7 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
private: private:
/** @brief Implementation of @ref features() */ /** @brief Implementation of @ref features() */
virtual Features doFeatures() const = 0; virtual ImageConverterFeatures doFeatures() const = 0;
/** @brief Implementation of @ref exportToImage() */ /** @brief Implementation of @ref exportToImage() */
virtual Containers::Optional<Image2D> doExportToImage(const ImageView2D& image); virtual Containers::Optional<Image2D> doExportToImage(const ImageView2D& image);
@ -264,30 +300,22 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract
/** /**
* @brief Implementation of @ref exportToFile(const ImageView2D&, const std::string&) * @brief Implementation of @ref exportToFile(const ImageView2D&, const std::string&)
* *
* If @ref Feature::ConvertData is supported, default implementation * If @ref ImageConverterFeature::ConvertData is supported, default
* calls @ref doExportToData(const ImageView2D&) and saves the result * implementation calls @ref doExportToData(const ImageView2D&) and
* to given file. * saves the result to given file.
*/ */
virtual bool doExportToFile(const ImageView2D& image, const std::string& filename); virtual bool doExportToFile(const ImageView2D& image, const std::string& filename);
/** /**
* @brief Implementation of @ref exportToFile(const CompressedImageView2D&, const std::string&) * @brief Implementation of @ref exportToFile(const CompressedImageView2D&, const std::string&)
* *
* If @ref Feature::ConvertCompressedData is supported, default * If @ref ImageConverterFeature::ConvertCompressedData is supported,
* implementation calls @ref doExportToData(const CompressedImageView2D&) * default implementation calls @ref doExportToData(const CompressedImageView2D&)
* and saves the result to given file. * and saves the result to given file.
*/ */
virtual bool doExportToFile(const CompressedImageView2D& image, const std::string& filename); virtual bool doExportToFile(const CompressedImageView2D& image, const std::string& filename);
}; };
CORRADE_ENUMSET_OPERATORS(AbstractImageConverter::Features)
/** @debugoperatorclassenum{AbstractImageConverter,AbstractImageConverter::Feature} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AbstractImageConverter::Feature value);
/** @debugoperatorclassenum{AbstractImageConverter,AbstractImageConverter::Features} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AbstractImageConverter::Features value);
}} }}
#endif #endif

28
src/Magnum/Trade/AbstractImporter.cpp

@ -96,7 +96,7 @@ AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, cons
void AbstractImporter::setFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*callback)(const std::string&, InputFileCallbackPolicy, void*), void* const userData) { void AbstractImporter::setFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*callback)(const std::string&, InputFileCallbackPolicy, void*), void* const userData) {
CORRADE_ASSERT(!isOpened(), "Trade::AbstractImporter::setFileCallback(): can't be set while a file is opened", ); CORRADE_ASSERT(!isOpened(), "Trade::AbstractImporter::setFileCallback(): can't be set while a file is opened", );
CORRADE_ASSERT(features() & (Feature::FileCallback|Feature::OpenData), "Trade::AbstractImporter::setFileCallback(): importer supports neither loading from data nor via callbacks, callbacks can't be used", ); CORRADE_ASSERT(features() & (ImporterFeature::FileCallback|ImporterFeature::OpenData), "Trade::AbstractImporter::setFileCallback(): importer supports neither loading from data nor via callbacks, callbacks can't be used", );
_fileCallback = callback; _fileCallback = callback;
_fileCallbackUserData = userData; _fileCallbackUserData = userData;
@ -106,7 +106,7 @@ void AbstractImporter::setFileCallback(Containers::Optional<Containers::ArrayVie
void AbstractImporter::doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) {} void AbstractImporter::doSetFileCallback(Containers::Optional<Containers::ArrayView<const char>>(*)(const std::string&, InputFileCallbackPolicy, void*), void*) {}
bool AbstractImporter::openData(Containers::ArrayView<const char> data) { bool AbstractImporter::openData(Containers::ArrayView<const char> data) {
CORRADE_ASSERT(features() & Feature::OpenData, CORRADE_ASSERT(features() & ImporterFeature::OpenData,
"Trade::AbstractImporter::openData(): feature not supported", {}); "Trade::AbstractImporter::openData(): feature not supported", {});
/* We accept empty data here (instead of checking for them and failing so /* We accept empty data here (instead of checking for them and failing so
@ -122,7 +122,7 @@ void AbstractImporter::doOpenData(Containers::ArrayView<const char>) {
} }
bool AbstractImporter::openState(const void* state, const std::string& filePath) { bool AbstractImporter::openState(const void* state, const std::string& filePath) {
CORRADE_ASSERT(features() & Feature::OpenState, CORRADE_ASSERT(features() & ImporterFeature::OpenState,
"Trade::AbstractImporter::openState(): feature not supported", {}); "Trade::AbstractImporter::openState(): feature not supported", {});
close(); close();
@ -139,13 +139,13 @@ bool AbstractImporter::openFile(const std::string& filename) {
/* If file loading callbacks are not set or the importer supports handling /* If file loading callbacks are not set or the importer supports handling
them directly, call into the implementation */ them directly, call into the implementation */
if(!_fileCallback || (doFeatures() & Feature::FileCallback)) { if(!_fileCallback || (doFeatures() & ImporterFeature::FileCallback)) {
doOpenFile(filename); doOpenFile(filename);
/* Otherwise, if loading from data is supported, use the callback and pass /* Otherwise, if loading from data is supported, use the callback and pass
the data through to openData(). Mark the file as ready to be closed once the data through to openData(). Mark the file as ready to be closed once
opening is finished. */ opening is finished. */
} else if(doFeatures() & Feature::OpenData) { } else if(doFeatures() & ImporterFeature::OpenData) {
/* This needs to be duplicated here and in the doOpenFile() /* This needs to be duplicated here and in the doOpenFile()
implementation in order to support both following cases: implementation in order to support both following cases:
- plugins that don't support FileCallback but have their own - plugins that don't support FileCallback but have their own
@ -171,7 +171,7 @@ bool AbstractImporter::openFile(const std::string& filename) {
} }
void AbstractImporter::doOpenFile(const std::string& filename) { void AbstractImporter::doOpenFile(const std::string& filename) {
CORRADE_ASSERT(features() & Feature::OpenData, "Trade::AbstractImporter::openFile(): not implemented", ); CORRADE_ASSERT(features() & ImporterFeature::OpenData, "Trade::AbstractImporter::openFile(): not implemented", );
/* If callbacks are set, use them. This is the same implementation as in /* If callbacks are set, use them. This is the same implementation as in
openFile(), see the comment there for details. */ openFile(), see the comment there for details. */
@ -640,12 +640,12 @@ const void* AbstractImporter::importerState() const {
const void* AbstractImporter::doImporterState() const { return nullptr; } const void* AbstractImporter::doImporterState() const { return nullptr; }
Debug& operator<<(Debug& debug, const AbstractImporter::Feature value) { Debug& operator<<(Debug& debug, const ImporterFeature value) {
debug << "Trade::AbstractImporter::Feature" << Debug::nospace; debug << "Trade::ImporterFeature" << Debug::nospace;
switch(value) { switch(value) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
#define _c(v) case AbstractImporter::Feature::v: return debug << "::" #v; #define _c(v) case ImporterFeature::v: return debug << "::" #v;
_c(OpenData) _c(OpenData)
_c(OpenState) _c(OpenState)
_c(FileCallback) _c(FileCallback)
@ -656,11 +656,11 @@ Debug& operator<<(Debug& debug, const AbstractImporter::Feature value) {
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")"; return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
} }
Debug& operator<<(Debug& debug, const AbstractImporter::Features value) { Debug& operator<<(Debug& debug, const ImporterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::AbstractImporter::Features{}", { return Containers::enumSetDebugOutput(debug, value, "Trade::ImporterFeatures{}", {
AbstractImporter::Feature::OpenData, ImporterFeature::OpenData,
AbstractImporter::Feature::OpenState, ImporterFeature::OpenState,
AbstractImporter::Feature::FileCallback}); ImporterFeature::FileCallback});
} }
}} }}

194
src/Magnum/Trade/AbstractImporter.h

@ -44,6 +44,47 @@
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
/**
@brief Features supported by an importer
@m_since_latest
@see @ref ImporterFeatures, @ref AbstractImporter::features()
*/
enum class ImporterFeature: UnsignedByte {
/** Opening files from raw data using @ref AbstractImporter::openData() */
OpenData = 1 << 0,
/** Opening already loaded state using @ref AbstractImporter::openState() */
OpenState = 1 << 1,
/**
* Specifying callbacks for loading additional files referenced
* from the main file using @ref AbstractImporter::setFileCallback(). If
* the importer * doesn't expose this feature, the format is either
* single-file or loading via callbacks is not supported.
*
* See @ref Trade-AbstractImporter-usage-callbacks and particular importer
* documentation for more information.
*/
FileCallback = 1 << 2
};
/**
@brief Set of features supported by an importer
@m_since_latest
@see @ref AbstractImporter::features()
*/
typedef Containers::EnumSet<ImporterFeature> ImporterFeatures;
CORRADE_ENUMSET_OPERATORS(ImporterFeatures)
/** @debugoperatorenum{ImporterFeatures} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, ImporterFeature value);
/** @debugoperatorenum{ImporterFeatures} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, ImporterFeatures value);
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief InputFileCallbackPolicy /** @brief @copybrief InputFileCallbackPolicy
* @m_deprecated_since{2019,10} Use @ref InputFileCallbackPolicy instead. * @m_deprecated_since{2019,10} Use @ref InputFileCallbackPolicy instead.
@ -73,14 +114,15 @@ See @ref plugins for more information about general plugin usage and
Besides loading data directly from the filesystem using @ref openFile() like Besides loading data directly from the filesystem using @ref openFile() like
shown above, it's possible to use @ref openData() to import data from memory. shown above, it's possible to use @ref openData() to import data from memory.
Note that the particular importer implementation must support Note that the particular importer implementation must support
@ref Feature::OpenData for this method to work. @ref ImporterFeature::OpenData for this method to work.
Complex scene files often reference other files such as images and in that case Complex scene files often reference other files such as images and in that case
you may want to intercept those references and load them in a custom way as you may want to intercept those references and load them in a custom way as
well. For importers that advertise support for this with @ref Feature::FileCallback well. For importers that advertise support for this with
this is done by specifying a file loading callback using @ref setFileCallback(). @ref ImporterFeature::FileCallback this is done by specifying a file loading
The callback gets a filename, @ref InputFileCallbackPolicy and an user callback using @ref setFileCallback(). The callback gets a filename,
pointer as parameters; returns a non-owning view on the loaded data or a @ref InputFileCallbackPolicy and an user pointer as parameters; returns a
non-owning view on the loaded data or a
@ref Corrade::Containers::NullOpt "Containers::NullOpt" to indicate the file @ref Corrade::Containers::NullOpt "Containers::NullOpt" to indicate the file
loading failed. For example, loading a scene from memory-mapped files could loading failed. For example, loading a scene from memory-mapped files could
look like below. Note that the file loading callback affects @ref openFile() as look like below. Note that the file loading callback affects @ref openFile() as
@ -90,12 +132,12 @@ correctly.
@snippet MagnumTrade.cpp AbstractImporter-usage-callbacks @snippet MagnumTrade.cpp AbstractImporter-usage-callbacks
For importers that don't support @ref Feature::FileCallback directly, the base For importers that don't support @ref ImporterFeature::FileCallback directly,
@ref openFile() implementation will use the file callback to pass the loaded the base @ref openFile() implementation will use the file callback to pass the
data through to @ref openData(), in case the importer supports at least loaded data through to @ref openData(), in case the importer supports at least
@ref Feature::OpenData. If the importer supports neither @ref Feature::FileCallback @ref ImporterFeature::OpenData. If the importer supports neither
nor @ref Feature::OpenData, @ref setFileCallback() doesn't allow the callbacks @ref ImporterFeature::FileCallback nor @ref ImporterFeature::OpenData,
to be set. @ref setFileCallback() doesn't allow the callbacks to be set.
The input file callback signature is the same for @ref Trade::AbstractImporter The input file callback signature is the same for @ref Trade::AbstractImporter
and @ref Text::AbstractFont to allow code reuse. and @ref Text::AbstractFont to allow code reuse.
@ -127,9 +169,9 @@ expose internal state through various accessors:
imported by @ref texture() imported by @ref texture()
Besides exposing internal state, importers that support the Besides exposing internal state, importers that support the
@ref Feature::OpenState feature can also attach to existing importer state @ref ImporterFeature::OpenState feature can also attach to existing importer
using @ref openState(). See documentation of a particular importer for details state using @ref openState(). See documentation of a particular importer for
about concrete types returned and accepted by these functions. details about concrete types returned and accepted by these functions.
@subsection Trade-AbstractImporter-usage-casting Polymorphic imported data types @subsection Trade-AbstractImporter-usage-casting Polymorphic imported data types
@ -170,11 +212,11 @@ functions, at least one of @ref doOpenData() / @ref doOpenFile() /
@ref doOpenState() functions, function @ref doClose() and one or more tuples of @ref doOpenState() functions, function @ref doClose() and one or more tuples of
data access functions, based on what features are supported in given format. data access functions, based on what features are supported in given format.
In order to support @ref Feature::FileCallback, the importer needs to properly In order to support @ref ImporterFeature::FileCallback, the importer needs to
use the callbacks to both load the top-level file in @ref doOpenFile() and also properly use the callbacks to both load the top-level file in @ref doOpenFile()
load any external files when needed. The @ref doOpenFile() can delegate back and also load any external files when needed. The @ref doOpenFile() can
into the base implementation, but it should remember at least the base file delegate back into the base implementation, but it should remember at least the
path to pass correct paths to subsequent file callbacks. The base file path to pass correct paths to subsequent file callbacks. The
@ref doSetFileCallback() can be overriden in case it's desired to respond to @ref doSetFileCallback() can be overriden in case it's desired to respond to
file loading callback setup, but doesn't have to be. file loading callback setup, but doesn't have to be.
@ -190,12 +232,13 @@ checked by the implementation:
- The @ref doOpenData(), @ref doOpenFile() and @ref doOpenState() functions - The @ref doOpenData(), @ref doOpenFile() and @ref doOpenState() functions
are called after the previous file was closed, function @ref doClose() is are called after the previous file was closed, function @ref doClose() is
called only if there is any file opened. called only if there is any file opened.
- The @ref doOpenData() function is called only if @ref Feature::OpenData is - The @ref doOpenData() function is called only if
supported. @ref ImporterFeature::OpenData is supported.
- The @ref doOpenState() function is called only if @ref Feature::OpenState - The @ref doOpenState() function is called only if
is supported. @ref ImporterFeature::OpenState is supported.
- The @ref doSetFileCallback() function is called only if - The @ref doSetFileCallback() function is called only if
@ref Feature::FileCallback is supported and there is no file opened. @ref ImporterFeature::FileCallback is supported and there is no file
opened.
- All `do*()` implementations working on an opened file are called only if - All `do*()` implementations working on an opened file are called only if
there is any file opened. there is any file opened.
- All `do*()` implementations taking data ID as parameter are called only if - All `do*()` implementations taking data ID as parameter are called only if
@ -223,36 +266,17 @@ checked by the implementation:
*/ */
class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlugin<AbstractImporter> { class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlugin<AbstractImporter> {
public: public:
/** #ifdef MAGNUM_BUILD_DEPRECATED
* @brief Features supported by this importer /** @brief @copybrief ImporterFeature
* * @m_deprecated_since_latest Use @ref ImporterFeature instead.
* @see @ref Features, @ref features()
*/ */
enum class Feature: UnsignedByte { typedef CORRADE_DEPRECATED("use ImporterFeature instead") ImporterFeature Feature;
/** Opening files from raw data using @ref openData() */
OpenData = 1 << 0,
/** Opening already loaded state using @ref openState() */
OpenState = 1 << 1,
/** /** @brief @copybrief ImporterFeatures
* Specifying callbacks for loading additional files referenced * @m_deprecated_since_latest Use @ref ImporterFeatures instead.
* from the main file using @ref setFileCallback(). If the importer
* doesn't expose this feature, the format is either single-file or
* loading via callbacks is not supported.
*
* See @ref Trade-AbstractImporter-usage-callbacks and particular
* importer documentation for more information.
*/
FileCallback = 1 << 2
};
/**
* @brief Set of features supported by this importer
*
* @see @ref features()
*/ */
typedef Containers::EnumSet<Feature> Features; typedef CORRADE_DEPRECATED("use ImporterFeature instead") ImporterFeatures Features;
#endif
/** /**
* @brief Plugin interface * @brief Plugin interface
@ -292,7 +316,7 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
explicit AbstractImporter(PluginManager::AbstractManager& manager, const std::string& plugin); explicit AbstractImporter(PluginManager::AbstractManager& manager, const std::string& plugin);
/** @brief Features supported by this importer */ /** @brief Features supported by this importer */
Features features() const { return doFeatures(); } ImporterFeatures features() const { return doFeatures(); }
/** /**
* @brief File opening callback function * @brief File opening callback function
@ -311,22 +335,22 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
/** /**
* @brief Set file opening callback * @brief Set file opening callback
* *
* In case the importer supports @ref Feature::FileCallback, files * In case the importer supports @ref ImporterFeature::FileCallback,
* opened through @ref openFile() will be loaded through the provided * files opened through @ref openFile() will be loaded through the
* callback. Besides that, all external files referenced by the * provided callback. Besides that, all external files referenced by
* top-level file will be loaded through the callback function as well, * the top-level file will be loaded through the callback function as
* usually on demand. The callback function gets a filename, * well, usually on demand. The callback function gets a filename,
* @ref InputFileCallbackPolicy and the @p userData pointer as input * @ref InputFileCallbackPolicy and the @p userData pointer as input
* and returns a non-owning view on the loaded data as output or a * and returns a non-owning view on the loaded data as output or a
* @ref Corrade::Containers::NullOpt if loading failed --- because * @ref Corrade::Containers::NullOpt if loading failed --- because
* empty files might also be valid in some circumstances, @cpp nullptr @ce * empty files might also be valid in some circumstances, @cpp nullptr @ce
* can't be used to indicate a failure. * can't be used to indicate a failure.
* *
* In case the importer doesn't support @ref Feature::FileCallback but * In case the importer doesn't support @ref ImporterFeature::FileCallback
* supports at least @ref Feature::OpenData, a file opened through * but supports at least @ref ImporterFeature::OpenData, a file opened
* @ref openFile() will be internally loaded through the provided * through @ref openFile() will be internally loaded through the
* callback and then passed to @ref openData(). First the file is * provided callback and then passed to @ref openData(). First the file
* loaded with @ref InputFileCallbackPolicy::LoadTemporary passed to * is loaded with @ref InputFileCallbackPolicy::LoadTemporary passed to
* the callback, then the returned memory view is passed to * the callback, then the returned memory view is passed to
* @ref openData() (sidestepping the potential @ref openFile() * @ref openData() (sidestepping the potential @ref openFile()
* implementation of that particular importer) and after that the * implementation of that particular importer) and after that the
@ -337,8 +361,9 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* *
* In case @p callback is @cpp nullptr @ce, the current callback (if * In case @p callback is @cpp nullptr @ce, the current callback (if
* any) is reset. This function expects that the importer supports * any) is reset. This function expects that the importer supports
* either @ref Feature::FileCallback or @ref Feature::OpenData. If an * either @ref ImporterFeature::FileCallback or
* importer supports neither, callbacks can't be used. * @ref ImporterFeature::OpenData. If an importer supports neither,
* callbacks can't be used.
* *
* It's expected that this function is called *before* a file is * It's expected that this function is called *before* a file is
* opened. It's also expected that the loaded data are kept in scope * opened. It's also expected that the loaded data are kept in scope
@ -385,9 +410,9 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* @brief Open raw data * @brief Open raw data
* *
* Closes previous file, if it was opened, and tries to open given raw * Closes previous file, if it was opened, and tries to open given raw
* data. Available only if @ref Feature::OpenData is supported. Returns * data. Available only if @ref ImporterFeature::OpenData is supported.
* @cpp true @ce on success, @cpp false @ce otherwise. The @p data is * Returns @cpp true @ce on success, @cpp false @ce otherwise. The
* not expected to be alive after the function exits. * @p data is not expected to be alive after the function exits.
* @see @ref features(), @ref openFile() * @see @ref features(), @ref openFile()
*/ */
bool openData(Containers::ArrayView<const char> data); bool openData(Containers::ArrayView<const char> data);
@ -399,8 +424,9 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* textures and materials. * textures and materials.
* *
* Closes previous file, if it was opened, and tries to open given * Closes previous file, if it was opened, and tries to open given
* state. Available only if @ref Feature::OpenState is supported. Returns * state. Available only if @ref ImporterFeature::OpenState is
* @cpp true @ce on success, @cpp false @ce otherwise. * supported. Returns @cpp true @ce on success, @cpp false @ce
* otherwise.
* *
* See documentation of a particular plugin for more information about * See documentation of a particular plugin for more information about
* type and contents of the @p state parameter. * type and contents of the @p state parameter.
@ -414,9 +440,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* Closes previous file, if it was opened, and tries to open given * Closes previous file, if it was opened, and tries to open given
* file. Returns @cpp true @ce on success, @cpp false @ce otherwise. * file. Returns @cpp true @ce on success, @cpp false @ce otherwise.
* If file loading callbacks are set via @ref setFileCallback() and * If file loading callbacks are set via @ref setFileCallback() and
* @ref Feature::OpenData is supported, this function uses the callback * @ref ImporterFeature::OpenData is supported, this function uses the
* to load the file and passes the memory view to @ref openData() * callback to load the file and passes the memory view to
* instead. See @ref setFileCallback() for more information. * @ref openData() instead. See @ref setFileCallback() for more
* information.
* @see @ref features(), @ref openData() * @see @ref features(), @ref openData()
*/ */
bool openFile(const std::string& filename); bool openFile(const std::string& filename);
@ -906,14 +933,15 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
/** /**
* @brief Implementation for @ref openFile() * @brief Implementation for @ref openFile()
* *
* If @ref Feature::OpenData is supported, default implementation opens * If @ref ImporterFeature::OpenData is supported, default
* the file and calls @ref doOpenData() with its contents. It is * implementation opens the file and calls @ref doOpenData() with its
* allowed to call this function from your @ref doOpenFile() * contents. It is allowed to call this function from your
* implementation --- in particular, this implementation will also * @ref doOpenFile() implementation --- in particular, this
* correctly handle callbacks set through @ref setFileCallback(). * implementation will also correctly handle callbacks set through
* @ref setFileCallback().
* *
* This function is not called when file callbacks are set through * This function is not called when file callbacks are set through
* @ref setFileCallback() and @ref Feature::FileCallback is not * @ref setFileCallback() and @ref ImporterFeature::FileCallback is not
* supported --- instead, file is loaded though the callback and data * supported --- instead, file is loaded though the callback and data
* passed through to @ref doOpenData(). * passed through to @ref doOpenData().
*/ */
@ -921,7 +949,7 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
private: private:
/** @brief Implementation for @ref features() */ /** @brief Implementation for @ref features() */
virtual Features doFeatures() const = 0; virtual ImporterFeatures doFeatures() const = 0;
/** /**
* @brief Implementation for @ref setFileCallback() * @brief Implementation for @ref setFileCallback()
@ -1294,14 +1322,6 @@ template<class Callback, class T> void AbstractImporter::setFileCallback(Callbac
} }
#endif #endif
CORRADE_ENUMSET_OPERATORS(AbstractImporter::Features)
/** @debugoperatorclassenum{AbstractImporter,AbstractImporter::Feature} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AbstractImporter::Feature value);
/** @debugoperatorclassenum{AbstractImporter,AbstractImporter::Features} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AbstractImporter::Features value);
}} }}
#endif #endif

70
src/Magnum/Trade/Test/AbstractImageConverterTest.cpp

@ -138,11 +138,11 @@ AbstractImageConverterTest::AbstractImageConverterTest() {
void AbstractImageConverterTest::construct() { void AbstractImageConverterTest::construct() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
Converter converter; Converter converter;
CORRADE_COMPARE(converter.features(), AbstractImageConverter::Features{}); CORRADE_COMPARE(converter.features(), ImageConverterFeatures{});
} }
void AbstractImageConverterTest::constructWithPluginManagerReference() { void AbstractImageConverterTest::constructWithPluginManagerReference() {
@ -151,17 +151,17 @@ void AbstractImageConverterTest::constructWithPluginManagerReference() {
explicit Converter(PluginManager::Manager<AbstractImageConverter>& manager): AbstractImageConverter{manager} {} explicit Converter(PluginManager::Manager<AbstractImageConverter>& manager): AbstractImageConverter{manager} {}
private: private:
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
PluginManager::Manager<AbstractImageConverter> manager; PluginManager::Manager<AbstractImageConverter> manager;
Converter converter{manager}; Converter converter{manager};
CORRADE_COMPARE(converter.features(), AbstractImageConverter::Features{}); CORRADE_COMPARE(converter.features(), ImageConverterFeatures{});
} }
void AbstractImageConverterTest::exportToImage() { void AbstractImageConverterTest::exportToImage() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertImage; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertImage; }
Containers::Optional<Image2D> doExportToImage(const ImageView2D& image) override { Containers::Optional<Image2D> doExportToImage(const ImageView2D& image) override {
return Image2D{PixelFormat::RGBA8Unorm, image.size(), Containers::Array<char>{96}}; return Image2D{PixelFormat::RGBA8Unorm, image.size(), Containers::Array<char>{96}};
} }
@ -176,7 +176,7 @@ void AbstractImageConverterTest::exportToImage() {
void AbstractImageConverterTest::exportToImageNotSupported() { void AbstractImageConverterTest::exportToImageNotSupported() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
std::ostringstream out; std::ostringstream out;
@ -189,7 +189,7 @@ void AbstractImageConverterTest::exportToImageNotSupported() {
void AbstractImageConverterTest::exportToImageNotImplemented() { void AbstractImageConverterTest::exportToImageNotImplemented() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertImage; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertImage; }
}; };
std::ostringstream out; std::ostringstream out;
@ -202,7 +202,7 @@ void AbstractImageConverterTest::exportToImageNotImplemented() {
void AbstractImageConverterTest::exportToImageCustomDeleter() { void AbstractImageConverterTest::exportToImageCustomDeleter() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertImage; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertImage; }
Containers::Optional<Image2D> doExportToImage(const ImageView2D&) override { Containers::Optional<Image2D> doExportToImage(const ImageView2D&) override {
return Image2D{PixelFormat::RGBA8Unorm, {}, Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}}; return Image2D{PixelFormat::RGBA8Unorm, {}, Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}};
} }
@ -218,7 +218,7 @@ void AbstractImageConverterTest::exportToImageCustomDeleter() {
void AbstractImageConverterTest::exportToCompressedImage() { void AbstractImageConverterTest::exportToCompressedImage() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedImage; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedImage; }
Containers::Optional<CompressedImage2D> doExportToCompressedImage(const ImageView2D& image) override { Containers::Optional<CompressedImage2D> doExportToCompressedImage(const ImageView2D& image) override {
return CompressedImage2D{CompressedPixelFormat::Bc1RGBAUnorm, image.size(), Containers::Array<char>{64}}; return CompressedImage2D{CompressedPixelFormat::Bc1RGBAUnorm, image.size(), Containers::Array<char>{64}};
} }
@ -233,7 +233,7 @@ void AbstractImageConverterTest::exportToCompressedImage() {
void AbstractImageConverterTest::exportToCompressedImageNotSupported() { void AbstractImageConverterTest::exportToCompressedImageNotSupported() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
std::ostringstream out; std::ostringstream out;
@ -246,7 +246,7 @@ void AbstractImageConverterTest::exportToCompressedImageNotSupported() {
void AbstractImageConverterTest::exportToCompressedImageNotImplemented() { void AbstractImageConverterTest::exportToCompressedImageNotImplemented() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedImage; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedImage; }
}; };
std::ostringstream out; std::ostringstream out;
@ -259,7 +259,7 @@ void AbstractImageConverterTest::exportToCompressedImageNotImplemented() {
void AbstractImageConverterTest::exportToCompressedImageCustomDeleter() { void AbstractImageConverterTest::exportToCompressedImageCustomDeleter() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedImage; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedImage; }
Containers::Optional<CompressedImage2D> doExportToCompressedImage(const ImageView2D&) override { Containers::Optional<CompressedImage2D> doExportToCompressedImage(const ImageView2D&) override {
return CompressedImage2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}}; return CompressedImage2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}};
} }
@ -275,7 +275,7 @@ void AbstractImageConverterTest::exportToCompressedImageCustomDeleter() {
void AbstractImageConverterTest::exportToData() { void AbstractImageConverterTest::exportToData() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; }
Containers::Array<char> doExportToData(const ImageView2D& image) override { Containers::Array<char> doExportToData(const ImageView2D& image) override {
return Containers::Array<char>{nullptr, std::size_t(image.size().product())}; return Containers::Array<char>{nullptr, std::size_t(image.size().product())};
} }
@ -288,7 +288,7 @@ void AbstractImageConverterTest::exportToData() {
void AbstractImageConverterTest::exportToDataNotSupported() { void AbstractImageConverterTest::exportToDataNotSupported() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
std::ostringstream out; std::ostringstream out;
@ -301,7 +301,7 @@ void AbstractImageConverterTest::exportToDataNotSupported() {
void AbstractImageConverterTest::exportToDataNotImplemented() { void AbstractImageConverterTest::exportToDataNotImplemented() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; }
}; };
std::ostringstream out; std::ostringstream out;
@ -314,7 +314,7 @@ void AbstractImageConverterTest::exportToDataNotImplemented() {
void AbstractImageConverterTest::exportToDataCustomDeleter() { void AbstractImageConverterTest::exportToDataCustomDeleter() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; }
Containers::Array<char> doExportToData(const ImageView2D&) override { Containers::Array<char> doExportToData(const ImageView2D&) override {
return Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}; return Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}};
} }
@ -330,7 +330,7 @@ void AbstractImageConverterTest::exportToDataCustomDeleter() {
void AbstractImageConverterTest::exportCompressedToData() { void AbstractImageConverterTest::exportCompressedToData() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedData; }
Containers::Array<char> doExportToData(const CompressedImageView2D& image) override { Containers::Array<char> doExportToData(const CompressedImageView2D& image) override {
return Containers::Array<char>{nullptr, std::size_t(image.size().product())}; return Containers::Array<char>{nullptr, std::size_t(image.size().product())};
} }
@ -343,7 +343,7 @@ void AbstractImageConverterTest::exportCompressedToData() {
void AbstractImageConverterTest::exportCompressedToDataNotSupported() { void AbstractImageConverterTest::exportCompressedToDataNotSupported() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
std::ostringstream out; std::ostringstream out;
@ -356,7 +356,7 @@ void AbstractImageConverterTest::exportCompressedToDataNotSupported() {
void AbstractImageConverterTest::exportCompressedToDataNotImplemented() { void AbstractImageConverterTest::exportCompressedToDataNotImplemented() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; }
}; };
std::ostringstream out; std::ostringstream out;
@ -369,7 +369,7 @@ void AbstractImageConverterTest::exportCompressedToDataNotImplemented() {
void AbstractImageConverterTest::exportCompressedToDataCustomDeleter() { void AbstractImageConverterTest::exportCompressedToDataCustomDeleter() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedData; }
Containers::Array<char> doExportToData(const CompressedImageView2D&) override { Containers::Array<char> doExportToData(const CompressedImageView2D&) override {
return Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}; return Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}};
} }
@ -385,7 +385,7 @@ void AbstractImageConverterTest::exportCompressedToDataCustomDeleter() {
class ImageDataExporter: public Trade::AbstractImageConverter { class ImageDataExporter: public Trade::AbstractImageConverter {
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ConvertCompressedData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData|ImageConverterFeature::ConvertCompressedData; }
Containers::Array<char> doExportToData(const ImageView2D&) override { Containers::Array<char> doExportToData(const ImageView2D&) override {
/* DirectInit / InPlaceInit is unfortunately causing a custom /* DirectInit / InPlaceInit is unfortunately causing a custom
@ -426,7 +426,7 @@ void AbstractImageConverterTest::exportImageDataToData() {
void AbstractImageConverterTest::exportToFile() { void AbstractImageConverterTest::exportToFile() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; }
bool doExportToFile(const ImageView2D& image, const std::string& filename) override { bool doExportToFile(const ImageView2D& image, const std::string& filename) override {
return Utility::Directory::write(filename, Containers::Array<char>{Containers::InPlaceInit, return Utility::Directory::write(filename, Containers::Array<char>{Containers::InPlaceInit,
{char(image.size().x()), char(image.size().y())}}); {char(image.size().x()), char(image.size().y())}});
@ -444,7 +444,7 @@ void AbstractImageConverterTest::exportToFile() {
void AbstractImageConverterTest::exportToFileThroughData() { void AbstractImageConverterTest::exportToFileThroughData() {
class DataExporter: public AbstractImageConverter { class DataExporter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; }
Containers::Array<char> doExportToData(const ImageView2D& image) override { Containers::Array<char> doExportToData(const ImageView2D& image) override {
return Containers::Array<char>{Containers::InPlaceInit, return Containers::Array<char>{Containers::InPlaceInit,
@ -465,7 +465,7 @@ void AbstractImageConverterTest::exportToFileThroughData() {
void AbstractImageConverterTest::exportToFileThroughDataNotWritable() { void AbstractImageConverterTest::exportToFileThroughDataNotWritable() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertData; }
Containers::Array<char> doExportToData(const ImageView2D& image) override { Containers::Array<char> doExportToData(const ImageView2D& image) override {
return Containers::Array<char>{Containers::InPlaceInit, return Containers::Array<char>{Containers::InPlaceInit,
@ -485,7 +485,7 @@ void AbstractImageConverterTest::exportToFileThroughDataNotWritable() {
void AbstractImageConverterTest::exportToFileNotSupported() { void AbstractImageConverterTest::exportToFileNotSupported() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
std::ostringstream out; std::ostringstream out;
@ -498,7 +498,7 @@ void AbstractImageConverterTest::exportToFileNotSupported() {
void AbstractImageConverterTest::exportToFileNotImplemented() { void AbstractImageConverterTest::exportToFileNotImplemented() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertFile; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertFile; }
}; };
std::ostringstream out; std::ostringstream out;
@ -511,7 +511,7 @@ void AbstractImageConverterTest::exportToFileNotImplemented() {
void AbstractImageConverterTest::exportCompressedToFile() { void AbstractImageConverterTest::exportCompressedToFile() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedFile; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedFile; }
bool doExportToFile(const CompressedImageView2D& image, const std::string& filename) override { bool doExportToFile(const CompressedImageView2D& image, const std::string& filename) override {
return Utility::Directory::write(filename, Containers::Array<char>{Containers::InPlaceInit, return Utility::Directory::write(filename, Containers::Array<char>{Containers::InPlaceInit,
{char(image.size().x()), char(image.size().y())}}); {char(image.size().x()), char(image.size().y())}});
@ -526,7 +526,7 @@ void AbstractImageConverterTest::exportCompressedToFile() {
void AbstractImageConverterTest::exportCompressedToFileThroughData() { void AbstractImageConverterTest::exportCompressedToFileThroughData() {
class DataExporter: public AbstractImageConverter { class DataExporter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedData; }
Containers::Array<char> doExportToData(const CompressedImageView2D& image) override { Containers::Array<char> doExportToData(const CompressedImageView2D& image) override {
return Containers::Array<char>{Containers::InPlaceInit, return Containers::Array<char>{Containers::InPlaceInit,
@ -546,7 +546,7 @@ void AbstractImageConverterTest::exportCompressedToFileThroughData() {
void AbstractImageConverterTest::exportCompressedToFileThroughDataNotWritable() { void AbstractImageConverterTest::exportCompressedToFileThroughDataNotWritable() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedData; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedData; }
Containers::Array<char> doExportToData(const CompressedImageView2D& image) override { Containers::Array<char> doExportToData(const CompressedImageView2D& image) override {
return Containers::Array<char>{Containers::InPlaceInit, return Containers::Array<char>{Containers::InPlaceInit,
@ -566,7 +566,7 @@ void AbstractImageConverterTest::exportCompressedToFileThroughDataNotWritable()
void AbstractImageConverterTest::exportCompressedToFileNotSupported() { void AbstractImageConverterTest::exportCompressedToFileNotSupported() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
}; };
std::ostringstream out; std::ostringstream out;
@ -579,7 +579,7 @@ void AbstractImageConverterTest::exportCompressedToFileNotSupported() {
void AbstractImageConverterTest::exportCompressedToFileNotImplemented() { void AbstractImageConverterTest::exportCompressedToFileNotImplemented() {
class Converter: public AbstractImageConverter { class Converter: public AbstractImageConverter {
Features doFeatures() const override { return Feature::ConvertCompressedFile; } ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedFile; }
}; };
std::ostringstream out; std::ostringstream out;
@ -611,15 +611,15 @@ void AbstractImageConverterTest::exportImageDataToFile() {
void AbstractImageConverterTest::debugFeature() { void AbstractImageConverterTest::debugFeature() {
std::ostringstream out; std::ostringstream out;
Debug{&out} << AbstractImageConverter::Feature::ConvertCompressedImage << AbstractImageConverter::Feature(0xf0); Debug{&out} << ImageConverterFeature::ConvertCompressedImage << ImageConverterFeature(0xf0);
CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::Feature::ConvertCompressedImage Trade::AbstractImageConverter::Feature(0xf0)\n"); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertCompressedImage Trade::ImageConverterFeature(0xf0)\n");
} }
void AbstractImageConverterTest::debugFeatures() { void AbstractImageConverterTest::debugFeatures() {
std::ostringstream out; std::ostringstream out;
Debug{&out} << (AbstractImageConverter::Feature::ConvertData|AbstractImageConverter::Feature::ConvertCompressedFile) << AbstractImageConverter::Features{}; Debug{&out} << (ImageConverterFeature::ConvertData|ImageConverterFeature::ConvertCompressedFile) << ImageConverterFeatures{};
CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::Feature::ConvertData|Trade::AbstractImageConverter::Feature::ConvertCompressedFile Trade::AbstractImageConverter::Features{}\n"); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertData|Trade::ImageConverterFeature::ConvertCompressedFile Trade::ImageConverterFeatures{}\n");
} }
}}}} }}}}

362
src/Magnum/Trade/Test/AbstractImporterTest.cpp

File diff suppressed because it is too large Load Diff

2
src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp

@ -39,7 +39,7 @@ AnyImporter::AnyImporter(PluginManager::AbstractManager& manager, const std::str
AnyImporter::~AnyImporter() = default; AnyImporter::~AnyImporter() = default;
auto AnyImporter::doFeatures() const -> Features { return {}; } ImporterFeatures AnyImporter::doFeatures() const { return {}; }
bool AnyImporter::doIsOpened() const { return !!_in; } bool AnyImporter::doIsOpened() const { return !!_in; }

2
src/MagnumPlugins/AnyAudioImporter/AnyImporter.h

@ -111,7 +111,7 @@ class MAGNUM_ANYAUDIOIMPORTER_EXPORT AnyImporter: public AbstractImporter {
~AnyImporter(); ~AnyImporter();
private: private:
MAGNUM_ANYAUDIOIMPORTER_LOCAL Features doFeatures() const override; MAGNUM_ANYAUDIOIMPORTER_LOCAL ImporterFeatures doFeatures() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL bool doIsOpened() const override; MAGNUM_ANYAUDIOIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL void doClose() override; MAGNUM_ANYAUDIOIMPORTER_LOCAL void doClose() override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL void doOpenFile(const std::string& filename) override; MAGNUM_ANYAUDIOIMPORTER_LOCAL void doOpenFile(const std::string& filename) override;

4
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp

@ -40,8 +40,8 @@ AnyImageConverter::AnyImageConverter(PluginManager::AbstractManager& manager, co
AnyImageConverter::~AnyImageConverter() = default; AnyImageConverter::~AnyImageConverter() = default;
auto AnyImageConverter::doFeatures() const -> Features { ImageConverterFeatures AnyImageConverter::doFeatures() const {
return Feature::ConvertFile|Feature::ConvertCompressedFile; return ImageConverterFeature::ConvertFile|ImageConverterFeature::ConvertCompressedFile;
} }
bool AnyImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) { bool AnyImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) {

2
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h

@ -115,7 +115,7 @@ class MAGNUM_ANYIMAGECONVERTER_EXPORT AnyImageConverter: public AbstractImageCon
~AnyImageConverter(); ~AnyImageConverter();
private: private:
MAGNUM_ANYIMAGECONVERTER_LOCAL Features doFeatures() const override; MAGNUM_ANYIMAGECONVERTER_LOCAL ImageConverterFeatures doFeatures() const override;
MAGNUM_ANYIMAGECONVERTER_LOCAL bool doExportToFile(const ImageView2D& image, const std::string& filename) override; MAGNUM_ANYIMAGECONVERTER_LOCAL bool doExportToFile(const ImageView2D& image, const std::string& filename) override;
MAGNUM_ANYIMAGECONVERTER_LOCAL bool doExportToFile(const CompressedImageView2D& image, const std::string& filename) override; MAGNUM_ANYIMAGECONVERTER_LOCAL bool doExportToFile(const CompressedImageView2D& image, const std::string& filename) override;
}; };

2
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp

@ -41,7 +41,7 @@ AnyImageImporter::AnyImageImporter(PluginManager::AbstractManager& manager, cons
AnyImageImporter::~AnyImageImporter() = default; AnyImageImporter::~AnyImageImporter() = default;
auto AnyImageImporter::doFeatures() const -> Features { return Feature::OpenData; } ImporterFeatures AnyImageImporter::doFeatures() const { return ImporterFeature::OpenData; }
bool AnyImageImporter::doIsOpened() const { return !!_in; } bool AnyImageImporter::doIsOpened() const { return !!_in; }

2
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h

@ -136,7 +136,7 @@ class MAGNUM_ANYIMAGEIMPORTER_EXPORT AnyImageImporter: public AbstractImporter {
~AnyImageImporter(); ~AnyImageImporter();
private: private:
MAGNUM_ANYIMAGEIMPORTER_LOCAL Features doFeatures() const override; MAGNUM_ANYIMAGEIMPORTER_LOCAL ImporterFeatures doFeatures() const override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL bool doIsOpened() const override; MAGNUM_ANYIMAGEIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL void doClose() override; MAGNUM_ANYIMAGEIMPORTER_LOCAL void doClose() override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL void doOpenFile(const std::string& filename) override; MAGNUM_ANYIMAGEIMPORTER_LOCAL void doOpenFile(const std::string& filename) override;

2
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp

@ -51,7 +51,7 @@ AnySceneImporter::AnySceneImporter(PluginManager::AbstractManager& manager, cons
AnySceneImporter::~AnySceneImporter() = default; AnySceneImporter::~AnySceneImporter() = default;
auto AnySceneImporter::doFeatures() const -> Features { return {}; } ImporterFeatures AnySceneImporter::doFeatures() const { return {}; }
bool AnySceneImporter::doIsOpened() const { return !!_in; } bool AnySceneImporter::doIsOpened() const { return !!_in; }

2
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h

@ -138,7 +138,7 @@ class MAGNUM_ANYSCENEIMPORTER_EXPORT AnySceneImporter: public AbstractImporter {
~AnySceneImporter(); ~AnySceneImporter();
private: private:
MAGNUM_ANYSCENEIMPORTER_LOCAL Features doFeatures() const override; MAGNUM_ANYSCENEIMPORTER_LOCAL ImporterFeatures doFeatures() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL bool doIsOpened() const override; MAGNUM_ANYSCENEIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL void doClose() override; MAGNUM_ANYSCENEIMPORTER_LOCAL void doClose() override;
MAGNUM_ANYSCENEIMPORTER_LOCAL void doOpenFile(const std::string& filename) override; MAGNUM_ANYSCENEIMPORTER_LOCAL void doOpenFile(const std::string& filename) override;

2
src/MagnumPlugins/MagnumFont/MagnumFont.cpp

@ -74,7 +74,7 @@ MagnumFont::MagnumFont(PluginManager::AbstractManager& manager, const std::strin
MagnumFont::~MagnumFont() { close(); } MagnumFont::~MagnumFont() { close(); }
auto MagnumFont::doFeatures() const -> Features { return Feature::OpenData|Feature::FileCallback|Feature::PreparedGlyphCache; } FontFeatures MagnumFont::doFeatures() const { return FontFeature::OpenData|FontFeature::FileCallback|FontFeature::PreparedGlyphCache; }
bool MagnumFont::doIsOpened() const { return _opened && _opened->image; } bool MagnumFont::doIsOpened() const { return _opened && _opened->image; }

2
src/MagnumPlugins/MagnumFont/MagnumFont.h

@ -157,7 +157,7 @@ class MAGNUM_MAGNUMFONT_EXPORT MagnumFont: public AbstractFont {
~MagnumFont(); ~MagnumFont();
private: private:
MAGNUM_MAGNUMFONT_LOCAL Features doFeatures() const override; MAGNUM_MAGNUMFONT_LOCAL FontFeatures doFeatures() const override;
MAGNUM_MAGNUMFONT_LOCAL bool doIsOpened() const override; MAGNUM_MAGNUMFONT_LOCAL bool doIsOpened() const override;
MAGNUM_MAGNUMFONT_LOCAL Metrics doOpenData(Containers::ArrayView<const char> data, Float) override; MAGNUM_MAGNUMFONT_LOCAL Metrics doOpenData(Containers::ArrayView<const char> data, Float) override;
MAGNUM_MAGNUMFONT_LOCAL Metrics doOpenFile(const std::string& filename, Float) override; MAGNUM_MAGNUMFONT_LOCAL Metrics doOpenFile(const std::string& filename, Float) override;

4
src/MagnumPlugins/MagnumFont/Test/MagnumFontTest.cpp

@ -141,7 +141,7 @@ void MagnumFontTest::layout() {
void MagnumFontTest::fileCallbackImage() { void MagnumFontTest::fileCallbackImage() {
Containers::Pointer<AbstractFont> font = _fontManager.instantiate("MagnumFont"); Containers::Pointer<AbstractFont> font = _fontManager.instantiate("MagnumFont");
CORRADE_VERIFY(font->features() & AbstractFont::Feature::FileCallback); CORRADE_VERIFY(font->features() & FontFeature::FileCallback);
std::unordered_map<std::string, Containers::Array<char>> files; std::unordered_map<std::string, Containers::Array<char>> files;
files["not/a/path/font.conf"] = Utility::Directory::read(Utility::Directory::join(MAGNUMFONT_TEST_DIR, "font.conf")); files["not/a/path/font.conf"] = Utility::Directory::read(Utility::Directory::join(MAGNUMFONT_TEST_DIR, "font.conf"));
@ -162,7 +162,7 @@ void MagnumFontTest::fileCallbackImage() {
void MagnumFontTest::fileCallbackImageNotFound() { void MagnumFontTest::fileCallbackImageNotFound() {
Containers::Pointer<AbstractFont> font = _fontManager.instantiate("MagnumFont"); Containers::Pointer<AbstractFont> font = _fontManager.instantiate("MagnumFont");
CORRADE_VERIFY(font->features() & AbstractFont::Feature::FileCallback); CORRADE_VERIFY(font->features() & FontFeature::FileCallback);
font->setFileCallback([](const std::string&, InputFileCallbackPolicy, void*) { font->setFileCallback([](const std::string&, InputFileCallbackPolicy, void*) {
return Containers::Optional<Containers::ArrayView<const char>>{}; return Containers::Optional<Containers::ArrayView<const char>>{};

4
src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp

@ -45,8 +45,8 @@ MagnumFontConverter::MagnumFontConverter() = default;
MagnumFontConverter::MagnumFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractFontConverter{manager, plugin} {} MagnumFontConverter::MagnumFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractFontConverter{manager, plugin} {}
auto MagnumFontConverter::doFeatures() const -> Features { FontConverterFeatures MagnumFontConverter::doFeatures() const {
return Feature::ExportFont|Feature::ConvertData|Feature::MultiFile; return FontConverterFeature::ExportFont|FontConverterFeature::ConvertData|FontConverterFeature::MultiFile;
} }
std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const { std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const {

2
src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h

@ -98,7 +98,7 @@ class MAGNUM_MAGNUMFONTCONVERTER_EXPORT MagnumFontConverter: public Text::Abstra
explicit MagnumFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin); explicit MagnumFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin);
private: private:
MAGNUM_MAGNUMFONTCONVERTER_LOCAL Features doFeatures() const override; MAGNUM_MAGNUMFONTCONVERTER_LOCAL FontConverterFeatures doFeatures() const override;
MAGNUM_MAGNUMFONTCONVERTER_LOCAL std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const override; MAGNUM_MAGNUMFONTCONVERTER_LOCAL std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const override;
}; };

4
src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp

@ -88,7 +88,7 @@ void MagnumFontConverterTest::exportFont() {
_opened = true; _opened = true;
return {16.0f, 25.0f, -10.0f, 39.7333f}; return {16.0f, 25.0f, -10.0f, 39.7333f};
} }
Features doFeatures() const { return {}; } FontFeatures doFeatures() const { return {}; }
Containers::Pointer<AbstractLayouter> doLayout(const AbstractGlyphCache&, Float, const std::string&) { return nullptr; } Containers::Pointer<AbstractLayouter> doLayout(const AbstractGlyphCache&, Float, const std::string&) { return nullptr; }
UnsignedInt doGlyphId(const char32_t character) { UnsignedInt doGlyphId(const char32_t character) {
@ -152,7 +152,7 @@ void MagnumFontConverterTest::exportFont() {
void MagnumFontConverterTest::exportFontNoGlyphCacheImageDownload() { void MagnumFontConverterTest::exportFontNoGlyphCacheImageDownload() {
struct MyFont: AbstractFont { struct MyFont: AbstractFont {
/* Supports neither file nor data opening */ /* Supports neither file nor data opening */
Features doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}

2
src/MagnumPlugins/ObjImporter/ObjImporter.cpp

@ -96,7 +96,7 @@ ObjImporter::ObjImporter(PluginManager::AbstractManager& manager, const std::str
ObjImporter::~ObjImporter() = default; ObjImporter::~ObjImporter() = default;
auto ObjImporter::doFeatures() const -> Features { return Feature::OpenData; } ImporterFeatures ObjImporter::doFeatures() const { return ImporterFeature::OpenData; }
void ObjImporter::doClose() { _file.reset(); } void ObjImporter::doClose() { _file.reset(); }

2
src/MagnumPlugins/ObjImporter/ObjImporter.h

@ -107,7 +107,7 @@ class MAGNUM_OBJIMPORTER_EXPORT ObjImporter: public AbstractImporter {
private: private:
struct File; struct File;
MAGNUM_OBJIMPORTER_LOCAL Features doFeatures() const override; MAGNUM_OBJIMPORTER_LOCAL ImporterFeatures doFeatures() const override;
MAGNUM_OBJIMPORTER_LOCAL bool doIsOpened() const override; MAGNUM_OBJIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_OBJIMPORTER_LOCAL void doOpenData(Containers::ArrayView<const char> data) override; MAGNUM_OBJIMPORTER_LOCAL void doOpenData(Containers::ArrayView<const char> data) override;

2
src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp

@ -43,7 +43,7 @@ TgaImageConverter::TgaImageConverter() = default;
TgaImageConverter::TgaImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImageConverter{manager, plugin} {} TgaImageConverter::TgaImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImageConverter{manager, plugin} {}
auto TgaImageConverter::doFeatures() const -> Features { return Feature::ConvertData; } ImageConverterFeatures TgaImageConverter::doFeatures() const { return ImageConverterFeature::ConvertData; }
Containers::Array<char> TgaImageConverter::doExportToData(const ImageView2D& image) { Containers::Array<char> TgaImageConverter::doExportToData(const ImageView2D& image) {
/* Initialize data buffer */ /* Initialize data buffer */

2
src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h

@ -97,7 +97,7 @@ class MAGNUM_TGAIMAGECONVERTER_EXPORT TgaImageConverter: public AbstractImageCon
explicit TgaImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin); explicit TgaImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin);
private: private:
Features MAGNUM_TGAIMAGECONVERTER_LOCAL doFeatures() const override; ImageConverterFeatures MAGNUM_TGAIMAGECONVERTER_LOCAL doFeatures() const override;
Containers::Array<char> MAGNUM_TGAIMAGECONVERTER_LOCAL doExportToData(const ImageView2D& image) override; Containers::Array<char> MAGNUM_TGAIMAGECONVERTER_LOCAL doExportToData(const ImageView2D& image) override;
}; };

2
src/MagnumPlugins/TgaImporter/TgaImporter.cpp

@ -46,7 +46,7 @@ TgaImporter::TgaImporter(PluginManager::AbstractManager& manager, const std::str
TgaImporter::~TgaImporter() = default; TgaImporter::~TgaImporter() = default;
auto TgaImporter::doFeatures() const -> Features { return Feature::OpenData; } ImporterFeatures TgaImporter::doFeatures() const { return ImporterFeature::OpenData; }
bool TgaImporter::doIsOpened() const { return _in; } bool TgaImporter::doIsOpened() const { return _in; }

2
src/MagnumPlugins/TgaImporter/TgaImporter.h

@ -105,7 +105,7 @@ class MAGNUM_TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter {
~TgaImporter(); ~TgaImporter();
private: private:
Features MAGNUM_TGAIMPORTER_LOCAL doFeatures() const override; ImporterFeatures MAGNUM_TGAIMPORTER_LOCAL doFeatures() const override;
bool MAGNUM_TGAIMPORTER_LOCAL doIsOpened() const override; bool MAGNUM_TGAIMPORTER_LOCAL doIsOpened() const override;
void MAGNUM_TGAIMPORTER_LOCAL doOpenData(Containers::ArrayView<const char> data) override; void MAGNUM_TGAIMPORTER_LOCAL doOpenData(Containers::ArrayView<const char> data) override;
void MAGNUM_TGAIMPORTER_LOCAL doClose() override; void MAGNUM_TGAIMPORTER_LOCAL doClose() override;

2
src/MagnumPlugins/WavAudioImporter/WavImporter.cpp

@ -43,7 +43,7 @@ WavImporter::WavImporter() = default;
WavImporter::WavImporter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImporter{manager, plugin} {} WavImporter::WavImporter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImporter{manager, plugin} {}
auto WavImporter::doFeatures() const -> Features { return Feature::OpenData; } ImporterFeatures WavImporter::doFeatures() const { return ImporterFeature::OpenData; }
bool WavImporter::doIsOpened() const { return !!_data; } bool WavImporter::doIsOpened() const { return !!_data; }

2
src/MagnumPlugins/WavAudioImporter/WavImporter.h

@ -118,7 +118,7 @@ class MAGNUM_WAVAUDIOIMPORTER_EXPORT WavImporter: public AbstractImporter {
explicit WavImporter(PluginManager::AbstractManager& manager, const std::string& plugin); explicit WavImporter(PluginManager::AbstractManager& manager, const std::string& plugin);
private: private:
MAGNUM_WAVAUDIOIMPORTER_LOCAL Features doFeatures() const override; MAGNUM_WAVAUDIOIMPORTER_LOCAL ImporterFeatures doFeatures() const override;
MAGNUM_WAVAUDIOIMPORTER_LOCAL bool doIsOpened() const override; MAGNUM_WAVAUDIOIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_WAVAUDIOIMPORTER_LOCAL void doOpenData(Containers::ArrayView<const char> data) override; MAGNUM_WAVAUDIOIMPORTER_LOCAL void doOpenData(Containers::ArrayView<const char> data) override;
MAGNUM_WAVAUDIOIMPORTER_LOCAL void doClose() override; MAGNUM_WAVAUDIOIMPORTER_LOCAL void doClose() override;

Loading…
Cancel
Save