db/upnp/Directory: merge m_containers and m_items
There is no use in duplicating these containers. It only means that we have to search both, duplicating the code.
This commit is contained in:
@@ -149,15 +149,9 @@ protected:
|
||||
|
||||
virtual void EndElement(const XML_Char *name)
|
||||
{
|
||||
if (!strcmp(name, "container")) {
|
||||
if (checkobjok()) {
|
||||
m_dir.m_containers.push_back(m_tobj);
|
||||
}
|
||||
} else if (!strcmp(name, "item")) {
|
||||
if (checkobjok()) {
|
||||
m_dir.m_items.push_back(m_tobj);
|
||||
}
|
||||
}
|
||||
if ((!strcmp(name, "container") || !strcmp(name, "item")) &&
|
||||
checkobjok())
|
||||
m_dir.objects.push_back(m_tobj);
|
||||
|
||||
m_path.pop_back();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define MPD_UPNP_DIRECTORY_HXX
|
||||
|
||||
#include "Object.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -33,8 +34,16 @@ class Error;
|
||||
*/
|
||||
class UPnPDirContent {
|
||||
public:
|
||||
std::vector<UPnPDirObject> m_containers;
|
||||
std::vector<UPnPDirObject> m_items;
|
||||
std::vector<UPnPDirObject> objects;
|
||||
|
||||
gcc_pure
|
||||
const UPnPDirObject *FindObject(const char *name) const {
|
||||
for (const auto &o : objects)
|
||||
if (o.name == name)
|
||||
return &o;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse from DIDL-Lite XML data.
|
||||
|
||||
Reference in New Issue
Block a user