diff --git a/src/db/Interface.hxx b/src/db/Interface.hxx index 67f67aa28..544162b9f 100644 --- a/src/db/Interface.hxx +++ b/src/db/Interface.hxx @@ -36,19 +36,19 @@ class Database { const DatabasePlugin &plugin; public: - Database(const DatabasePlugin &_plugin) + Database(const DatabasePlugin &_plugin) noexcept :plugin(_plugin) {} /** * Free instance data. */ - virtual ~Database() {} + virtual ~Database() noexcept = default; - const DatabasePlugin &GetPlugin() const { + const DatabasePlugin &GetPlugin() const noexcept { return plugin; } - bool IsPlugin(const DatabasePlugin &other) const { + bool IsPlugin(const DatabasePlugin &other) const noexcept { return &plugin == &other; } @@ -63,7 +63,7 @@ public: /** * Close the database, free allocated memory. */ - virtual void Close() {} + virtual void Close() noexcept {} /** * Look up a song (including tag data) in the database. When @@ -82,7 +82,7 @@ public: * Mark the song object as "unused". Call this on objects * returned by GetSong(). */ - virtual void ReturnSong(const LightSong *song) const = 0; + virtual void ReturnSong(const LightSong *song) const noexcept = 0; /** * Visit the selected entities. diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index f9d788a19..0f9e41165 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -118,9 +118,9 @@ public: const ConfigBlock &block); void Open() override; - void Close() override; + void Close() noexcept override; const LightSong *GetSong(const char *uri_utf8) const override; - void ReturnSong(const LightSong *song) const override; + void ReturnSong(const LightSong *song) const noexcept override; void Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, @@ -144,7 +144,7 @@ private: void CheckConnection(); void EnsureConnected(); - void Disconnect(); + void Disconnect() noexcept; /* virtual methods from SocketMonitor */ bool OnSocketReady(unsigned flags) noexcept override; @@ -193,7 +193,7 @@ static constexpr struct { static void Copy(TagBuilder &tag, TagType d_tag, - const struct mpd_song *song, enum mpd_tag_type s_tag) + const struct mpd_song *song, enum mpd_tag_type s_tag) noexcept { for (unsigned i = 0;; ++i) { @@ -440,7 +440,7 @@ ProxyDatabase::Open() } void -ProxyDatabase::Close() +ProxyDatabase::Close() noexcept { if (connection != nullptr) Disconnect(); @@ -522,7 +522,7 @@ ProxyDatabase::EnsureConnected() } void -ProxyDatabase::Disconnect() +ProxyDatabase::Disconnect() noexcept { assert(connection != nullptr); @@ -621,7 +621,7 @@ ProxyDatabase::GetSong(const char *uri) const } void -ProxyDatabase::ReturnSong(const LightSong *_song) const +ProxyDatabase::ReturnSong(const LightSong *_song) const noexcept { assert(_song != nullptr); @@ -700,30 +700,30 @@ class ProxyEntity { struct mpd_entity *entity; public: - explicit ProxyEntity(struct mpd_entity *_entity) + explicit ProxyEntity(struct mpd_entity *_entity) noexcept :entity(_entity) {} ProxyEntity(const ProxyEntity &other) = delete; - ProxyEntity(ProxyEntity &&other) + ProxyEntity(ProxyEntity &&other) noexcept :entity(other.entity) { other.entity = nullptr; } - ~ProxyEntity() { + ~ProxyEntity() noexcept { if (entity != nullptr) mpd_entity_free(entity); } ProxyEntity &operator=(const ProxyEntity &other) = delete; - operator const struct mpd_entity *() const { + operator const struct mpd_entity *() const noexcept { return entity; } }; static std::list -ReceiveEntities(struct mpd_connection *connection) +ReceiveEntities(struct mpd_connection *connection) noexcept { std::list entities; struct mpd_entity *entity; diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 52e46f76d..4d5601f63 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -72,7 +72,7 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path, #ifndef ENABLE_ZLIB gcc_unused #endif - bool _compress) + bool _compress) noexcept :Database(simple_db_plugin), path(std::move(_path)), path_utf8(path.ToUTF8()), @@ -187,7 +187,7 @@ SimpleDatabase::Open() } void -SimpleDatabase::Close() +SimpleDatabase::Close() noexcept { assert(root != nullptr); assert(prefixed_light_song == nullptr); @@ -247,7 +247,7 @@ SimpleDatabase::GetSong(const char *uri) const } void -SimpleDatabase::ReturnSong(gcc_unused const LightSong *song) const +SimpleDatabase::ReturnSong(gcc_unused const LightSong *song) const noexcept { assert(song != nullptr); assert(song == &light_song.Get() || song == prefixed_light_song); @@ -448,8 +448,8 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri) } } -Database * -SimpleDatabase::LockUmountSteal(const char *uri) +inline Database * +SimpleDatabase::LockUmountSteal(const char *uri) noexcept { ScopeDatabaseLock protect; @@ -465,7 +465,7 @@ SimpleDatabase::LockUmountSteal(const char *uri) } bool -SimpleDatabase::Unmount(const char *uri) +SimpleDatabase::Unmount(const char *uri) noexcept { Database *db = LockUmountSteal(uri); if (db == nullptr) diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx index ab9c77ab2..b95b7f5f6 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx @@ -70,7 +70,7 @@ class SimpleDatabase : public Database { SimpleDatabase(const ConfigBlock &block); - SimpleDatabase(AllocatedPath &&_path, bool _compress); + SimpleDatabase(AllocatedPath &&_path, bool _compress) noexcept; public: static Database *Create(EventLoop &main_event_loop, @@ -108,14 +108,14 @@ public: void Mount(const char *local_uri, const char *storage_uri); gcc_nonnull_all - bool Unmount(const char *uri); + bool Unmount(const char *uri) noexcept; /* virtual methods from class Database */ void Open() override; - void Close() override; + void Close() noexcept override; const LightSong *GetSong(const char *uri_utf8) const override; - void ReturnSong(const LightSong *song) const override; + void ReturnSong(const LightSong *song) const noexcept override; void Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, @@ -142,7 +142,7 @@ private: */ void Load(); - Database *LockUmountSteal(const char *uri); + Database *LockUmountSteal(const char *uri) noexcept; }; extern const DatabasePlugin simple_db_plugin; diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index b6ed6fdc5..1f7732da7 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -63,7 +63,7 @@ class UpnpSong : UpnpSongData, public LightSong { std::string real_uri2; public: - UpnpSong(UPnPDirObject &&object, std::string &&_uri) + UpnpSong(UPnPDirObject &&object, std::string &&_uri) noexcept :UpnpSongData(std::move(_uri), std::move(object.tag)), LightSong(UpnpSongData::uri.c_str(), UpnpSongData::tag), real_uri2(std::move(object.url)) { @@ -77,19 +77,19 @@ class UpnpDatabase : public Database { UPnPDeviceDirectory *discovery; public: - explicit UpnpDatabase(EventLoop &_event_loop) + explicit UpnpDatabase(EventLoop &_event_loop) noexcept :Database(upnp_db_plugin), event_loop(_event_loop) {} static Database *Create(EventLoop &main_event_loop, EventLoop &io_event_loop, DatabaseListener &listener, - const ConfigBlock &block); + const ConfigBlock &block) noexcept; void Open() override; - void Close() override; + void Close() noexcept override; const LightSong *GetSong(const char *uri_utf8) const override; - void ReturnSong(const LightSong *song) const override; + void ReturnSong(const LightSong *song) const noexcept override; void Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, @@ -148,7 +148,7 @@ private: Database * UpnpDatabase::Create(EventLoop &, EventLoop &io_event_loop, gcc_unused DatabaseListener &listener, - const ConfigBlock &) + const ConfigBlock &) noexcept { return new UpnpDatabase(io_event_loop); } @@ -169,14 +169,14 @@ UpnpDatabase::Open() } void -UpnpDatabase::Close() +UpnpDatabase::Close() noexcept { delete discovery; UpnpClientGlobalFinish(); } void -UpnpDatabase::ReturnSong(const LightSong *_song) const +UpnpDatabase::ReturnSong(const LightSong *_song) const noexcept { assert(_song != nullptr); @@ -220,7 +220,7 @@ UpnpDatabase::GetSong(const char *uri) const * Double-quote a string, adding internal backslash escaping. */ static void -dquote(std::string &out, const char *in) +dquote(std::string &out, const char *in) noexcept { out.push_back('"'); @@ -333,7 +333,7 @@ visitSong(const UPnPDirObject &meta, const char *path, */ static std::string songPath(const std::string &servername, - const std::string &objid) + const std::string &objid) noexcept { return servername + "/" + rootid + "/" + objid; }