lib/upnp: add "noexcept"
This commit is contained in:
parent
fb01e41e8a
commit
4b2bb88375
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "Object.hxx"
|
#include "Object.hxx"
|
||||||
|
|
||||||
UPnPDirObject::~UPnPDirObject()
|
UPnPDirObject::~UPnPDirObject() noexcept
|
||||||
{
|
{
|
||||||
/* this destructor exists here just so it won't get inlined */
|
/* this destructor exists here just so it won't get inlined */
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
UPnPDirObject() = default;
|
UPnPDirObject() = default;
|
||||||
UPnPDirObject(UPnPDirObject &&) = default;
|
UPnPDirObject(UPnPDirObject &&) = default;
|
||||||
|
|
||||||
~UPnPDirObject();
|
~UPnPDirObject() noexcept;
|
||||||
|
|
||||||
UPnPDirObject &operator=(UPnPDirObject &&) = default;
|
UPnPDirObject &operator=(UPnPDirObject &&) = default;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class CurlSlist {
|
|||||||
struct curl_slist *head = nullptr;
|
struct curl_slist *head = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CurlSlist() noexcept = default;
|
CurlSlist() = default;
|
||||||
|
|
||||||
CurlSlist(CurlSlist &&src) noexcept
|
CurlSlist(CurlSlist &&src) noexcept
|
||||||
:head(std::exchange(src.head, nullptr)) {}
|
:head(std::exchange(src.head, nullptr)) {}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <upnp/upnptools.h>
|
#include <upnp/upnptools.h>
|
||||||
|
|
||||||
static inline constexpr unsigned
|
static inline constexpr unsigned
|
||||||
CountNameValuePairs()
|
CountNameValuePairs() noexcept
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ CountNameValuePairs()
|
|||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
static inline constexpr unsigned
|
static inline constexpr unsigned
|
||||||
CountNameValuePairs(gcc_unused const char *name, gcc_unused const char *value,
|
CountNameValuePairs(gcc_unused const char *name, gcc_unused const char *value,
|
||||||
Args... args)
|
Args... args) noexcept
|
||||||
{
|
{
|
||||||
return 1 + CountNameValuePairs(args...);
|
return 1 + CountNameValuePairs(args...);
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ CountNameValuePairs(gcc_unused const char *name, gcc_unused const char *value,
|
|||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
static inline IXML_Document *
|
static inline IXML_Document *
|
||||||
MakeActionHelper(const char *action_name, const char *service_type,
|
MakeActionHelper(const char *action_name, const char *service_type,
|
||||||
Args... args)
|
Args... args) noexcept
|
||||||
{
|
{
|
||||||
const unsigned n = CountNameValuePairs(args...);
|
const unsigned n = CountNameValuePairs(args...);
|
||||||
return UpnpMakeAction(action_name, service_type, n,
|
return UpnpMakeAction(action_name, service_type, n,
|
||||||
|
@ -32,15 +32,15 @@ public:
|
|||||||
* Pass this value as "cookie" pointer to libupnp asynchronous
|
* Pass this value as "cookie" pointer to libupnp asynchronous
|
||||||
* functions.
|
* functions.
|
||||||
*/
|
*/
|
||||||
void *GetUpnpCookie() {
|
void *GetUpnpCookie() noexcept {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UpnpCallback &FromUpnpCookie(void *cookie) {
|
static UpnpCallback &FromUpnpCookie(void *cookie) noexcept {
|
||||||
return *(UpnpCallback *)cookie;
|
return *(UpnpCallback *)cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int Invoke(Upnp_EventType et, void *evp) = 0;
|
virtual int Invoke(Upnp_EventType et, void *evp) noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,7 @@ static unsigned upnp_client_ref;
|
|||||||
static UpnpClient_Handle upnp_client_handle;
|
static UpnpClient_Handle upnp_client_handle;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
UpnpClientCallback(Upnp_EventType et, void *evp, void *cookie)
|
UpnpClientCallback(Upnp_EventType et, void *evp, void *cookie) noexcept
|
||||||
{
|
{
|
||||||
if (cookie == nullptr)
|
if (cookie == nullptr)
|
||||||
/* this is the cookie passed to UpnpRegisterClient();
|
/* this is the cookie passed to UpnpRegisterClient();
|
||||||
@ -74,7 +74,7 @@ UpnpClientGlobalInit(UpnpClient_Handle &handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UpnpClientGlobalFinish()
|
UpnpClientGlobalFinish() noexcept
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
const std::lock_guard<Mutex> protect(upnp_client_init_mutex);
|
const std::lock_guard<Mutex> protect(upnp_client_init_mutex);
|
||||||
|
@ -28,6 +28,6 @@ void
|
|||||||
UpnpClientGlobalInit(UpnpClient_Handle &handle);
|
UpnpClientGlobalInit(UpnpClient_Handle &handle);
|
||||||
|
|
||||||
void
|
void
|
||||||
UpnpClientGlobalFinish();
|
UpnpClientGlobalFinish() noexcept;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
|
|
||||||
ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device,
|
ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device,
|
||||||
const UPnPService &service)
|
const UPnPService &service) noexcept
|
||||||
:m_actionURL(uri_apply_base(service.controlURL, device.URLBase)),
|
:m_actionURL(uri_apply_base(service.controlURL, device.URLBase)),
|
||||||
m_serviceType(service.serviceType),
|
m_serviceType(service.serviceType),
|
||||||
m_deviceId(device.UDN),
|
m_deviceId(device.UDN),
|
||||||
@ -44,7 +44,7 @@ ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentDirectoryService::~ContentDirectoryService()
|
ContentDirectoryService::~ContentDirectoryService() noexcept
|
||||||
{
|
{
|
||||||
/* this destructor exists here just so it won't get inlined */
|
/* this destructor exists here just so it won't get inlined */
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,12 @@ public:
|
|||||||
* UPnPDeviceDirectory::GetDirectories()
|
* UPnPDeviceDirectory::GetDirectories()
|
||||||
*/
|
*/
|
||||||
ContentDirectoryService(const UPnPDevice &device,
|
ContentDirectoryService(const UPnPDevice &device,
|
||||||
const UPnPService &service);
|
const UPnPService &service) noexcept;
|
||||||
|
|
||||||
/** An empty one */
|
/** An empty one */
|
||||||
ContentDirectoryService() = default;
|
ContentDirectoryService() = default;
|
||||||
|
|
||||||
~ContentDirectoryService();
|
~ContentDirectoryService() noexcept;
|
||||||
|
|
||||||
/** Read a container's children list into dirbuf.
|
/** Read a container's children list into dirbuf.
|
||||||
*
|
*
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
UPnPDevice::~UPnPDevice()
|
UPnPDevice::~UPnPDevice() noexcept
|
||||||
{
|
{
|
||||||
/* this destructor exists here just so it won't get inlined */
|
/* this destructor exists here just so it won't get inlined */
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
UPnPDevice(UPnPDevice &&) = default;
|
UPnPDevice(UPnPDevice &&) = default;
|
||||||
UPnPDevice &operator=(UPnPDevice &&) = default;
|
UPnPDevice &operator=(UPnPDevice &&) = default;
|
||||||
|
|
||||||
~UPnPDevice();
|
~UPnPDevice() noexcept;
|
||||||
|
|
||||||
/** Build device from xml description downloaded from discovery
|
/** Build device from xml description downloaded from discovery
|
||||||
* @param url where the description came from
|
* @param url where the description came from
|
||||||
|
@ -45,7 +45,7 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UPnPDeviceDirectory::Downloader::Destroy()
|
UPnPDeviceDirectory::Downloader::Destroy() noexcept
|
||||||
{
|
{
|
||||||
parent.downloaders.erase_and_dispose(parent.downloaders.iterator_to(*this),
|
parent.downloaders.erase_and_dispose(parent.downloaders.iterator_to(*this),
|
||||||
DeleteDisposer());
|
DeleteDisposer());
|
||||||
@ -170,7 +170,7 @@ UPnPDeviceDirectory::LockRemove(const std::string &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco)
|
UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco) noexcept
|
||||||
{
|
{
|
||||||
if (isMSDevice(disco->DeviceType) ||
|
if (isMSDevice(disco->DeviceType) ||
|
||||||
isCDService(disco->ServiceType)) {
|
isCDService(disco->ServiceType)) {
|
||||||
@ -192,7 +192,7 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco)
|
UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco) noexcept
|
||||||
{
|
{
|
||||||
if (isMSDevice(disco->DeviceType) ||
|
if (isMSDevice(disco->DeviceType) ||
|
||||||
isCDService(disco->ServiceType)) {
|
isCDService(disco->ServiceType)) {
|
||||||
@ -208,7 +208,7 @@ UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco)
|
|||||||
// Example: ContentDirectories appearing and disappearing from the network
|
// Example: ContentDirectories appearing and disappearing from the network
|
||||||
// We queue a task for our worker thread(s)
|
// We queue a task for our worker thread(s)
|
||||||
int
|
int
|
||||||
UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp)
|
UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp) noexcept
|
||||||
{
|
{
|
||||||
switch (et) {
|
switch (et) {
|
||||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
case UPNP_DISCOVERY_SEARCH_RESULT:
|
||||||
@ -251,13 +251,13 @@ UPnPDeviceDirectory::ExpireDevices()
|
|||||||
|
|
||||||
UPnPDeviceDirectory::UPnPDeviceDirectory(EventLoop &event_loop,
|
UPnPDeviceDirectory::UPnPDeviceDirectory(EventLoop &event_loop,
|
||||||
UpnpClient_Handle _handle,
|
UpnpClient_Handle _handle,
|
||||||
UPnPDiscoveryListener *_listener)
|
UPnPDiscoveryListener *_listener) noexcept
|
||||||
:curl(event_loop), handle(_handle),
|
:curl(event_loop), handle(_handle),
|
||||||
listener(_listener)
|
listener(_listener)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UPnPDeviceDirectory::~UPnPDeviceDirectory()
|
UPnPDeviceDirectory::~UPnPDeviceDirectory() noexcept
|
||||||
{
|
{
|
||||||
BlockingCall(GetEventLoop(), [this](){
|
BlockingCall(GetEventLoop(), [this](){
|
||||||
downloaders.clear_and_dispose(DeleteDisposer());
|
downloaders.clear_and_dispose(DeleteDisposer());
|
||||||
@ -265,7 +265,7 @@ UPnPDeviceDirectory::~UPnPDeviceDirectory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline EventLoop &
|
inline EventLoop &
|
||||||
UPnPDeviceDirectory::GetEventLoop()
|
UPnPDeviceDirectory::GetEventLoop() noexcept
|
||||||
{
|
{
|
||||||
return curl->GetEventLoop();
|
return curl->GetEventLoop();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ class UPnPDeviceDirectory final : UpnpCallback {
|
|||||||
|
|
||||||
ContentDirectoryDescriptor(std::string &&_id,
|
ContentDirectoryDescriptor(std::string &&_id,
|
||||||
std::chrono::steady_clock::time_point last,
|
std::chrono::steady_clock::time_point last,
|
||||||
std::chrono::steady_clock::duration exp)
|
std::chrono::steady_clock::duration exp) noexcept
|
||||||
:id(std::move(_id)),
|
:id(std::move(_id)),
|
||||||
expires(last + exp + std::chrono::seconds(20)) {}
|
expires(last + exp + std::chrono::seconds(20)) {}
|
||||||
|
|
||||||
@ -102,14 +102,14 @@ class UPnPDeviceDirectory final : UpnpCallback {
|
|||||||
Downloader(UPnPDeviceDirectory &_parent,
|
Downloader(UPnPDeviceDirectory &_parent,
|
||||||
const Upnp_Discovery &disco);
|
const Upnp_Discovery &disco);
|
||||||
|
|
||||||
void Start() {
|
void Start() noexcept {
|
||||||
defer_start_event.Schedule();
|
defer_start_event.Schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Destroy();
|
void Destroy() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnDeferredStart() {
|
void OnDeferredStart() noexcept {
|
||||||
request.Start();
|
request.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,13 +147,13 @@ class UPnPDeviceDirectory final : UpnpCallback {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
UPnPDeviceDirectory(EventLoop &event_loop, UpnpClient_Handle _handle,
|
UPnPDeviceDirectory(EventLoop &event_loop, UpnpClient_Handle _handle,
|
||||||
UPnPDiscoveryListener *_listener=nullptr);
|
UPnPDiscoveryListener *_listener=nullptr) noexcept;
|
||||||
~UPnPDeviceDirectory();
|
~UPnPDeviceDirectory() noexcept;
|
||||||
|
|
||||||
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
|
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
|
||||||
UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
|
UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
|
||||||
|
|
||||||
EventLoop &GetEventLoop();
|
EventLoop &GetEventLoop() noexcept;
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
@ -180,11 +180,11 @@ private:
|
|||||||
void LockAdd(ContentDirectoryDescriptor &&d);
|
void LockAdd(ContentDirectoryDescriptor &&d);
|
||||||
void LockRemove(const std::string &id);
|
void LockRemove(const std::string &id);
|
||||||
|
|
||||||
int OnAlive(Upnp_Discovery *disco);
|
int OnAlive(Upnp_Discovery *disco) noexcept;
|
||||||
int OnByeBye(Upnp_Discovery *disco);
|
int OnByeBye(Upnp_Discovery *disco) noexcept;
|
||||||
|
|
||||||
/* virtual methods from class UpnpCallback */
|
/* virtual methods from class UpnpCallback */
|
||||||
virtual int Invoke(Upnp_EventType et, void *evp) override;
|
int Invoke(Upnp_EventType et, void *evp) noexcept override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ UpnpGlobalInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UpnpGlobalFinish()
|
UpnpGlobalFinish() noexcept
|
||||||
{
|
{
|
||||||
const std::lock_guard<Mutex> protect(upnp_init_mutex);
|
const std::lock_guard<Mutex> protect(upnp_init_mutex);
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ void
|
|||||||
UpnpGlobalInit();
|
UpnpGlobalInit();
|
||||||
|
|
||||||
void
|
void
|
||||||
UpnpGlobalFinish();
|
UpnpGlobalFinish() noexcept;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
struct UpnpIxmlDeleter {
|
struct UpnpIxmlDeleter {
|
||||||
void operator()(IXML_Document *doc) {
|
void operator()(IXML_Document *doc) noexcept {
|
||||||
ixmlDocument_free(doc);
|
ixmlDocument_free(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(IXML_NodeList *nl) {
|
void operator()(IXML_NodeList *nl) noexcept {
|
||||||
ixmlNodeList_free(nl);
|
ixmlNodeList_free(nl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
namespace ixmlwrap {
|
namespace ixmlwrap {
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
getFirstElementValue(IXML_Document *doc, const char *name)
|
getFirstElementValue(IXML_Document *doc, const char *name) noexcept
|
||||||
{
|
{
|
||||||
UniqueIxmlNodeList nodes(ixmlDocument_getElementsByTagName(doc, name));
|
UniqueIxmlNodeList nodes(ixmlDocument_getElementsByTagName(doc, name));
|
||||||
if (!nodes)
|
if (!nodes)
|
||||||
|
@ -28,7 +28,7 @@ namespace ixmlwrap {
|
|||||||
* contain a text node
|
* contain a text node
|
||||||
*/
|
*/
|
||||||
const char *getFirstElementValue(IXML_Document *doc,
|
const char *getFirstElementValue(IXML_Document *doc,
|
||||||
const char *name);
|
const char *name) noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user