lib/expat: use C++ exceptions instead of class Error

This commit is contained in:
Max Kellermann
2016-02-06 08:45:19 +01:00
parent cd2f65aafc
commit 6c5bc9b4a3
11 changed files with 108 additions and 174 deletions

View File

@@ -76,17 +76,14 @@ public:
/** Read a container's children list into dirbuf.
*
* @param objectId the UPnP object Id for the container. Root has Id "0"
* @param[out] dirbuf stores the entries we read.
*/
bool readDir(UpnpClient_Handle handle,
const char *objectId, UPnPDirContent &dirbuf,
Error &error) const;
UPnPDirContent readDir(UpnpClient_Handle handle,
const char *objectId) const;
bool readDirSlice(UpnpClient_Handle handle,
void readDirSlice(UpnpClient_Handle handle,
const char *objectId, unsigned offset,
unsigned count, UPnPDirContent& dirbuf,
unsigned &didread, unsigned &total,
Error &error) const;
unsigned &didread, unsigned &total) const;
/** Search the content directory service.
*
@@ -96,22 +93,17 @@ public:
* @param searchstring an UPnP searchcriteria string. Check the
* UPnP document: UPnP-av-ContentDirectory-v1-Service-20020625.pdf
* section 2.5.5. Maybe we'll provide an easier way some day...
* @param[out] dirbuf stores the entries we read.
*/
bool search(UpnpClient_Handle handle,
const char *objectId, const char *searchstring,
UPnPDirContent &dirbuf,
Error &error) const;
UPnPDirContent search(UpnpClient_Handle handle,
const char *objectId,
const char *searchstring) const;
/** Read metadata for a given node.
*
* @param objectId the UPnP object Id. Root has Id "0"
* @param[out] dirbuf stores the entries we read. At most one entry will be
* returned.
*/
bool getMetadata(UpnpClient_Handle handle,
const char *objectId, UPnPDirContent &dirbuf,
Error &error) const;
UPnPDirContent getMetadata(UpnpClient_Handle handle,
const char *objectId) const;
/** Retrieve search capabilities
*

View File

@@ -21,7 +21,6 @@
#include "Device.hxx"
#include "Util.hxx"
#include "lib/expat/ExpatParser.hxx"
#include "util/Error.hxx"
#include <stdlib.h>
@@ -100,15 +99,12 @@ protected:
}
};
bool
UPnPDevice::Parse(const std::string &url, const char *description,
Error &error)
void
UPnPDevice::Parse(const std::string &url, const char *description)
{
{
UPnPDeviceParser mparser(*this);
if (!mparser.Parse(description, strlen(description),
true, error))
return false;
mparser.Parse(description, strlen(description), true);
}
if (URLBase.empty()) {
@@ -129,6 +125,4 @@ UPnPDevice::Parse(const std::string &url, const char *description,
}
}
}
return true;
}

View File

@@ -23,8 +23,6 @@
#include <vector>
#include <string>
class Error;
/**
* UPnP Description phase: interpreting the device description which we
* downloaded from the URL obtained by the discovery phase.
@@ -81,8 +79,7 @@ public:
* @param url where the description came from
* @param description the xml device description
*/
bool Parse(const std::string &url, const char *description,
Error &error);
void Parse(const std::string &url, const char *description);
};
#endif /* _UPNPDEV_HXX_INCLUDED_ */

View File

@@ -135,13 +135,10 @@ UPnPDeviceDirectory::Explore()
ContentDirectoryDescriptor d(std::move(tsk->device_id),
MonotonicClockS(), tsk->expires);
{
Error error2;
bool success = d.Parse(tsk->url, buf, error2);
if (!success) {
LogError(error2);
continue;
}
try {
d.Parse(tsk->url, buf);
} catch (const std::exception &e) {
LogError(e);
}
LockAdd(std::move(d));

View File

@@ -87,9 +87,8 @@ class UPnPDeviceDirectory final : UpnpCallback {
unsigned last, int exp)
:id(std::move(_id)), expires(last + exp + 20) {}
bool Parse(const std::string &url, const char *description,
Error &_error) {
return device.Parse(url, description, _error);
void Parse(const std::string &url, const char *description) {
device.Parse(url, description);
}
};