db/Interface: add "noexcept"
This commit is contained in:
parent
c59be7ced3
commit
81b734be10
@ -36,19 +36,19 @@ class Database {
|
|||||||
const DatabasePlugin &plugin;
|
const DatabasePlugin &plugin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Database(const DatabasePlugin &_plugin)
|
Database(const DatabasePlugin &_plugin) noexcept
|
||||||
:plugin(_plugin) {}
|
:plugin(_plugin) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free instance data.
|
* Free instance data.
|
||||||
*/
|
*/
|
||||||
virtual ~Database() {}
|
virtual ~Database() noexcept = default;
|
||||||
|
|
||||||
const DatabasePlugin &GetPlugin() const {
|
const DatabasePlugin &GetPlugin() const noexcept {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsPlugin(const DatabasePlugin &other) const {
|
bool IsPlugin(const DatabasePlugin &other) const noexcept {
|
||||||
return &plugin == &other;
|
return &plugin == &other;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Close the database, free allocated memory.
|
* Close the database, free allocated memory.
|
||||||
*/
|
*/
|
||||||
virtual void Close() {}
|
virtual void Close() noexcept {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look up a song (including tag data) in the database. When
|
* 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
|
* Mark the song object as "unused". Call this on objects
|
||||||
* returned by GetSong().
|
* returned by GetSong().
|
||||||
*/
|
*/
|
||||||
virtual void ReturnSong(const LightSong *song) const = 0;
|
virtual void ReturnSong(const LightSong *song) const noexcept = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visit the selected entities.
|
* Visit the selected entities.
|
||||||
|
@ -118,9 +118,9 @@ public:
|
|||||||
const ConfigBlock &block);
|
const ConfigBlock &block);
|
||||||
|
|
||||||
void Open() override;
|
void Open() override;
|
||||||
void Close() override;
|
void Close() noexcept override;
|
||||||
const LightSong *GetSong(const char *uri_utf8) const 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,
|
void Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
@ -144,7 +144,7 @@ private:
|
|||||||
void CheckConnection();
|
void CheckConnection();
|
||||||
void EnsureConnected();
|
void EnsureConnected();
|
||||||
|
|
||||||
void Disconnect();
|
void Disconnect() noexcept;
|
||||||
|
|
||||||
/* virtual methods from SocketMonitor */
|
/* virtual methods from SocketMonitor */
|
||||||
bool OnSocketReady(unsigned flags) noexcept override;
|
bool OnSocketReady(unsigned flags) noexcept override;
|
||||||
@ -193,7 +193,7 @@ static constexpr struct {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
Copy(TagBuilder &tag, TagType d_tag,
|
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) {
|
for (unsigned i = 0;; ++i) {
|
||||||
@ -440,7 +440,7 @@ ProxyDatabase::Open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProxyDatabase::Close()
|
ProxyDatabase::Close() noexcept
|
||||||
{
|
{
|
||||||
if (connection != nullptr)
|
if (connection != nullptr)
|
||||||
Disconnect();
|
Disconnect();
|
||||||
@ -522,7 +522,7 @@ ProxyDatabase::EnsureConnected()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProxyDatabase::Disconnect()
|
ProxyDatabase::Disconnect() noexcept
|
||||||
{
|
{
|
||||||
assert(connection != nullptr);
|
assert(connection != nullptr);
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ ProxyDatabase::GetSong(const char *uri) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProxyDatabase::ReturnSong(const LightSong *_song) const
|
ProxyDatabase::ReturnSong(const LightSong *_song) const noexcept
|
||||||
{
|
{
|
||||||
assert(_song != nullptr);
|
assert(_song != nullptr);
|
||||||
|
|
||||||
@ -700,30 +700,30 @@ class ProxyEntity {
|
|||||||
struct mpd_entity *entity;
|
struct mpd_entity *entity;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProxyEntity(struct mpd_entity *_entity)
|
explicit ProxyEntity(struct mpd_entity *_entity) noexcept
|
||||||
:entity(_entity) {}
|
:entity(_entity) {}
|
||||||
|
|
||||||
ProxyEntity(const ProxyEntity &other) = delete;
|
ProxyEntity(const ProxyEntity &other) = delete;
|
||||||
|
|
||||||
ProxyEntity(ProxyEntity &&other)
|
ProxyEntity(ProxyEntity &&other) noexcept
|
||||||
:entity(other.entity) {
|
:entity(other.entity) {
|
||||||
other.entity = nullptr;
|
other.entity = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ProxyEntity() {
|
~ProxyEntity() noexcept {
|
||||||
if (entity != nullptr)
|
if (entity != nullptr)
|
||||||
mpd_entity_free(entity);
|
mpd_entity_free(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyEntity &operator=(const ProxyEntity &other) = delete;
|
ProxyEntity &operator=(const ProxyEntity &other) = delete;
|
||||||
|
|
||||||
operator const struct mpd_entity *() const {
|
operator const struct mpd_entity *() const noexcept {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::list<ProxyEntity>
|
static std::list<ProxyEntity>
|
||||||
ReceiveEntities(struct mpd_connection *connection)
|
ReceiveEntities(struct mpd_connection *connection) noexcept
|
||||||
{
|
{
|
||||||
std::list<ProxyEntity> entities;
|
std::list<ProxyEntity> entities;
|
||||||
struct mpd_entity *entity;
|
struct mpd_entity *entity;
|
||||||
|
@ -72,7 +72,7 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path,
|
|||||||
#ifndef ENABLE_ZLIB
|
#ifndef ENABLE_ZLIB
|
||||||
gcc_unused
|
gcc_unused
|
||||||
#endif
|
#endif
|
||||||
bool _compress)
|
bool _compress) noexcept
|
||||||
:Database(simple_db_plugin),
|
:Database(simple_db_plugin),
|
||||||
path(std::move(_path)),
|
path(std::move(_path)),
|
||||||
path_utf8(path.ToUTF8()),
|
path_utf8(path.ToUTF8()),
|
||||||
@ -187,7 +187,7 @@ SimpleDatabase::Open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SimpleDatabase::Close()
|
SimpleDatabase::Close() noexcept
|
||||||
{
|
{
|
||||||
assert(root != nullptr);
|
assert(root != nullptr);
|
||||||
assert(prefixed_light_song == nullptr);
|
assert(prefixed_light_song == nullptr);
|
||||||
@ -247,7 +247,7 @@ SimpleDatabase::GetSong(const char *uri) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SimpleDatabase::ReturnSong(gcc_unused const LightSong *song) const
|
SimpleDatabase::ReturnSong(gcc_unused const LightSong *song) const noexcept
|
||||||
{
|
{
|
||||||
assert(song != nullptr);
|
assert(song != nullptr);
|
||||||
assert(song == &light_song.Get() || song == prefixed_light_song);
|
assert(song == &light_song.Get() || song == prefixed_light_song);
|
||||||
@ -448,8 +448,8 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Database *
|
inline Database *
|
||||||
SimpleDatabase::LockUmountSteal(const char *uri)
|
SimpleDatabase::LockUmountSteal(const char *uri) noexcept
|
||||||
{
|
{
|
||||||
ScopeDatabaseLock protect;
|
ScopeDatabaseLock protect;
|
||||||
|
|
||||||
@ -465,7 +465,7 @@ SimpleDatabase::LockUmountSteal(const char *uri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SimpleDatabase::Unmount(const char *uri)
|
SimpleDatabase::Unmount(const char *uri) noexcept
|
||||||
{
|
{
|
||||||
Database *db = LockUmountSteal(uri);
|
Database *db = LockUmountSteal(uri);
|
||||||
if (db == nullptr)
|
if (db == nullptr)
|
||||||
|
@ -70,7 +70,7 @@ class SimpleDatabase : public Database {
|
|||||||
|
|
||||||
SimpleDatabase(const ConfigBlock &block);
|
SimpleDatabase(const ConfigBlock &block);
|
||||||
|
|
||||||
SimpleDatabase(AllocatedPath &&_path, bool _compress);
|
SimpleDatabase(AllocatedPath &&_path, bool _compress) noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Database *Create(EventLoop &main_event_loop,
|
static Database *Create(EventLoop &main_event_loop,
|
||||||
@ -108,14 +108,14 @@ public:
|
|||||||
void Mount(const char *local_uri, const char *storage_uri);
|
void Mount(const char *local_uri, const char *storage_uri);
|
||||||
|
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
bool Unmount(const char *uri);
|
bool Unmount(const char *uri) noexcept;
|
||||||
|
|
||||||
/* virtual methods from class Database */
|
/* virtual methods from class Database */
|
||||||
void Open() override;
|
void Open() override;
|
||||||
void Close() override;
|
void Close() noexcept override;
|
||||||
|
|
||||||
const LightSong *GetSong(const char *uri_utf8) const 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,
|
void Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
@ -142,7 +142,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
void Load();
|
void Load();
|
||||||
|
|
||||||
Database *LockUmountSteal(const char *uri);
|
Database *LockUmountSteal(const char *uri) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const DatabasePlugin simple_db_plugin;
|
extern const DatabasePlugin simple_db_plugin;
|
||||||
|
@ -63,7 +63,7 @@ class UpnpSong : UpnpSongData, public LightSong {
|
|||||||
std::string real_uri2;
|
std::string real_uri2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpnpSong(UPnPDirObject &&object, std::string &&_uri)
|
UpnpSong(UPnPDirObject &&object, std::string &&_uri) noexcept
|
||||||
:UpnpSongData(std::move(_uri), std::move(object.tag)),
|
:UpnpSongData(std::move(_uri), std::move(object.tag)),
|
||||||
LightSong(UpnpSongData::uri.c_str(), UpnpSongData::tag),
|
LightSong(UpnpSongData::uri.c_str(), UpnpSongData::tag),
|
||||||
real_uri2(std::move(object.url)) {
|
real_uri2(std::move(object.url)) {
|
||||||
@ -77,19 +77,19 @@ class UpnpDatabase : public Database {
|
|||||||
UPnPDeviceDirectory *discovery;
|
UPnPDeviceDirectory *discovery;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit UpnpDatabase(EventLoop &_event_loop)
|
explicit UpnpDatabase(EventLoop &_event_loop) noexcept
|
||||||
:Database(upnp_db_plugin),
|
:Database(upnp_db_plugin),
|
||||||
event_loop(_event_loop) {}
|
event_loop(_event_loop) {}
|
||||||
|
|
||||||
static Database *Create(EventLoop &main_event_loop,
|
static Database *Create(EventLoop &main_event_loop,
|
||||||
EventLoop &io_event_loop,
|
EventLoop &io_event_loop,
|
||||||
DatabaseListener &listener,
|
DatabaseListener &listener,
|
||||||
const ConfigBlock &block);
|
const ConfigBlock &block) noexcept;
|
||||||
|
|
||||||
void Open() override;
|
void Open() override;
|
||||||
void Close() override;
|
void Close() noexcept override;
|
||||||
const LightSong *GetSong(const char *uri_utf8) const 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,
|
void Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
@ -148,7 +148,7 @@ private:
|
|||||||
Database *
|
Database *
|
||||||
UpnpDatabase::Create(EventLoop &, EventLoop &io_event_loop,
|
UpnpDatabase::Create(EventLoop &, EventLoop &io_event_loop,
|
||||||
gcc_unused DatabaseListener &listener,
|
gcc_unused DatabaseListener &listener,
|
||||||
const ConfigBlock &)
|
const ConfigBlock &) noexcept
|
||||||
{
|
{
|
||||||
return new UpnpDatabase(io_event_loop);
|
return new UpnpDatabase(io_event_loop);
|
||||||
}
|
}
|
||||||
@ -169,14 +169,14 @@ UpnpDatabase::Open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UpnpDatabase::Close()
|
UpnpDatabase::Close() noexcept
|
||||||
{
|
{
|
||||||
delete discovery;
|
delete discovery;
|
||||||
UpnpClientGlobalFinish();
|
UpnpClientGlobalFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UpnpDatabase::ReturnSong(const LightSong *_song) const
|
UpnpDatabase::ReturnSong(const LightSong *_song) const noexcept
|
||||||
{
|
{
|
||||||
assert(_song != nullptr);
|
assert(_song != nullptr);
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ UpnpDatabase::GetSong(const char *uri) const
|
|||||||
* Double-quote a string, adding internal backslash escaping.
|
* Double-quote a string, adding internal backslash escaping.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
dquote(std::string &out, const char *in)
|
dquote(std::string &out, const char *in) noexcept
|
||||||
{
|
{
|
||||||
out.push_back('"');
|
out.push_back('"');
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ visitSong(const UPnPDirObject &meta, const char *path,
|
|||||||
*/
|
*/
|
||||||
static std::string
|
static std::string
|
||||||
songPath(const std::string &servername,
|
songPath(const std::string &servername,
|
||||||
const std::string &objid)
|
const std::string &objid) noexcept
|
||||||
{
|
{
|
||||||
return servername + "/" + rootid + "/" + objid;
|
return servername + "/" + rootid + "/" + objid;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user