Browse Source

Audio: port AbstractImporter away from std::string.

Yes, I plan to merge audio import into Trade::AbstractImporter, but
until that's done, it feels silly to have to pay for the std::string
cruft given that it's present in just two arguments.
next
Vladimír Vondruš 2 months ago
parent
commit
0f1099df0b
  1. 6
      src/Magnum/Audio/AbstractImporter.cpp
  2. 12
      src/Magnum/Audio/AbstractImporter.h
  3. 2
      src/Magnum/Audio/Test/AbstractImporterTest.cpp
  4. 2
      src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp
  5. 2
      src/MagnumPlugins/AnyAudioImporter/AnyImporter.h

6
src/Magnum/Audio/AbstractImporter.cpp

@ -31,10 +31,8 @@
#include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/PluginManager/Manager.hpp>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/Utility/Path.h>
#ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT
@ -97,13 +95,13 @@ void AbstractImporter::doOpenData(Containers::ArrayView<const char>) {
CORRADE_ASSERT_UNREACHABLE("Audio::AbstractImporter::openData(): feature advertised but not implemented", );
}
bool AbstractImporter::openFile(const std::string& filename) {
bool AbstractImporter::openFile(const Containers::StringView filename) {
close();
doOpenFile(filename);
return isOpened();
}
void AbstractImporter::doOpenFile(const std::string& filename) {
void AbstractImporter::doOpenFile(const Containers::StringView filename) {
CORRADE_ASSERT(features() & ImporterFeature::OpenData, "Audio::AbstractImporter::openFile(): not implemented", );
/* Open file */

12
src/Magnum/Audio/AbstractImporter.h

@ -31,11 +31,15 @@
*/
#include <Corrade/PluginManager/AbstractManagingPlugin.h>
#include <Corrade/Utility/StlForwardString.h>
#include "Magnum/Magnum.h"
#include "Magnum/Audio/BufferFormat.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For APIs that used to take a std::string */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace Audio {
/**
@ -185,7 +189,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* returns @cpp false @ce.
* @see @ref features(), @ref openData()
*/
bool openFile(const std::string& filename);
bool openFile(Containers::StringView filename);
/** @brief Close file */
void close();
@ -224,7 +228,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* implementation opens the file and calls @ref doOpenData() with its
* contents.
*/
virtual void doOpenFile(const std::string& filename);
virtual void doOpenFile(Containers::StringView filename);
/** @brief Implementation for @ref close() */
virtual void doClose() = 0;
@ -257,7 +261,7 @@ updated interface string.
*/
/* Silly indentation to make the string appear in pluginInterface() docs */
#define MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE /* [interface] */ \
"cz.mosra.magnum.Audio.AbstractImporter/0.1"
"cz.mosra.magnum.Audio.AbstractImporter/0.1.1"
/* [interface] */
}}

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

@ -24,10 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <string> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h>

2
src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp

@ -52,7 +52,7 @@ bool AnyImporter::doIsOpened() const { return !!_in; }
void AnyImporter::doClose() { _in = nullptr; }
void AnyImporter::doOpenFile(const std::string& filename) {
void AnyImporter::doOpenFile(const Containers::StringView filename) {
CORRADE_INTERNAL_ASSERT(manager());
/* We don't detect any double extensions yet, so we can normalize just the

2
src/MagnumPlugins/AnyAudioImporter/AnyImporter.h

@ -134,7 +134,7 @@ class MAGNUM_ANYAUDIOIMPORTER_EXPORT AnyImporter: public AbstractImporter {
MAGNUM_ANYAUDIOIMPORTER_LOCAL ImporterFeatures doFeatures() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL void doClose() override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL void doOpenFile(const std::string& filename) override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL void doOpenFile(const Containers::StringView filename) override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL BufferFormat doFormat() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL UnsignedInt doFrequency() const override;

Loading…
Cancel
Save